use of com.axelor.apps.base.db.Company in project axelor-open-suite by axelor.
the class IrrecoverableService method createIrrecoverablePaymentScheduleLineLine.
/**
* Fonction permettant de créer une ligne Echéance rejetée
*
* @param icl Une ligne Client
* @param invoice Une échéance rejetée
* @param seq Un numéro de séquence
* @return
* @throws AxelorException
*/
public IrrecoverablePaymentScheduleLineLine createIrrecoverablePaymentScheduleLineLine(IrrecoverableCustomerLine icl, PaymentScheduleLine paymentScheduleLine, int seq) throws AxelorException {
IrrecoverablePaymentScheduleLineLine ipsll = new IrrecoverablePaymentScheduleLineLine();
ipsll.setPaymentScheduleLine(paymentScheduleLine);
ipsll.setIrrecoverableCustomerLine(icl);
Company company = paymentScheduleLine.getPaymentSchedule().getCompany();
Tax tax = accountConfigService.getIrrecoverableStandardRateTax(accountConfigService.getAccountConfig(company));
ipsll.setIrrecoverableReportLineList(this.createIrrecoverableReportLineList(ipsll, paymentScheduleLine, tax));
log.debug("Ligne échéance rejetée : {}", ipsll);
return ipsll;
}
use of com.axelor.apps.base.db.Company in project axelor-open-suite by axelor.
the class ReconcileServiceImpl method reconcilePreconditions.
public void reconcilePreconditions(Reconcile reconcile) throws AxelorException {
MoveLine debitMoveLine = reconcile.getDebitMoveLine();
MoveLine creditMoveLine = reconcile.getCreditMoveLine();
if (debitMoveLine == null || creditMoveLine == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.RECONCILE_1), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION));
}
// Check if move lines companies are the same as the reconcile company
Company reconcileCompany = reconcile.getCompany();
Company debitMoveLineCompany = debitMoveLine.getMove().getCompany();
Company creditMoveLineCompany = creditMoveLine.getMove().getCompany();
if (!debitMoveLineCompany.equals(reconcileCompany) && !creditMoveLineCompany.equals(reconcileCompany)) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, String.format(I18n.get(IExceptionMessage.RECONCILE_7), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION), debitMoveLineCompany, creditMoveLineCompany, reconcileCompany));
}
// Check if move lines accounts are the same (debit and credit)
if (!creditMoveLine.getAccount().equals(debitMoveLine.getAccount())) {
log.debug("Compte ligne de credit : {} , Compte ligne de debit : {}", creditMoveLine.getAccount(), debitMoveLine.getAccount());
// Check if move lines accounts are compatible
if (!debitMoveLine.getAccount().getCompatibleAccountSet().contains(creditMoveLine.getAccount())) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.RECONCILE_2), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION));
}
}
// Check if the amount to reconcile is != zero
if (reconcile.getAmount() == null || reconcile.getAmount().compareTo(BigDecimal.ZERO) == 0) {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.RECONCILE_4), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION), reconcile.getReconcileSeq(), debitMoveLine.getName(), debitMoveLine.getAccount().getLabel(), creditMoveLine.getName(), creditMoveLine.getAccount().getLabel());
}
if ((reconcile.getAmount().compareTo(creditMoveLine.getCredit().subtract(creditMoveLine.getAmountPaid())) > 0 || (reconcile.getAmount().compareTo(debitMoveLine.getDebit().subtract(debitMoveLine.getAmountPaid())) > 0))) {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.RECONCILE_5) + " " + I18n.get(IExceptionMessage.RECONCILE_3), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION), reconcile.getReconcileSeq(), reconcile.getAmount(), debitMoveLine.getName(), debitMoveLine.getAccount().getLabel(), debitMoveLine.getDebit().subtract(debitMoveLine.getAmountPaid()), creditMoveLine.getName(), creditMoveLine.getAccount().getLabel(), creditMoveLine.getCredit().subtract(creditMoveLine.getAmountPaid()));
}
}
use of com.axelor.apps.base.db.Company in project axelor-open-suite by axelor.
the class AnalyticMoveLineServiceImpl method createAnalyticMoveLine.
public AnalyticMoveLine createAnalyticMoveLine(AnalyticDistributionLine analyticDistributionLine, BigDecimal total, int typeSelect, LocalDate date) {
AnalyticMoveLine analyticMoveLine = new AnalyticMoveLine();
analyticMoveLine.setOriginalPieceAmount(total);
analyticMoveLine.setAnalyticAccount(analyticDistributionLine.getAnalyticAccount());
analyticMoveLine.setAnalyticAxis(analyticDistributionLine.getAnalyticAxis());
analyticMoveLine.setAnalyticJournal(analyticDistributionLine.getAnalyticJournal());
AnalyticJournal analyticJournal = analyticDistributionLine.getAnalyticJournal();
Company company = analyticJournal == null ? null : analyticJournal.getCompany();
if (company != null) {
analyticMoveLine.setCurrency(company.getCurrency());
}
analyticMoveLine.setDate(date);
analyticMoveLine.setPercentage(analyticDistributionLine.getPercentage());
analyticMoveLine.setAmount(computeAmount(analyticMoveLine));
analyticMoveLine.setTypeSelect(typeSelect);
return analyticMoveLine;
}
use of com.axelor.apps.base.db.Company in project axelor-open-suite by axelor.
the class PrintServiceImpl method generateHtml.
protected String generateHtml(Print print) {
StringBuilder htmlBuilder = new StringBuilder();
htmlBuilder.append("<!DOCTYPE html>");
htmlBuilder.append("<html>");
htmlBuilder.append("<head>");
htmlBuilder.append("<title></title>");
htmlBuilder.append("<meta charset=\"utf-8\"/>");
htmlBuilder.append("<style type=\"text/css\">");
htmlBuilder.append("</style>");
htmlBuilder.append("</head>");
htmlBuilder.append("<body>");
if (!print.getHidePrintSettings()) {
Company company = print.getCompany();
Integer logoPosition = print.getLogoPositionSelect();
String pdfHeader = print.getPrintPdfHeader() != null ? print.getPrintPdfHeader() : "";
String imageTag = "";
String logoWidth = print.getLogoWidth() != null ? "width: " + print.getLogoWidth() + ";" : "width: 50%;";
String headerWidth = print.getHeaderContentWidth() != null ? "width: " + print.getHeaderContentWidth() + ";" : "width: 40%;";
if (company != null && company.getLogo() != null && logoPosition != PrintRepository.LOGO_POSITION_NONE && new File(attachmentPath + company.getLogo().getFilePath()).exists()) {
String width = company.getWidth() != 0 ? "width='" + company.getWidth() + "px'" : "";
String height = company.getHeight() != 0 ? company.getHeight() + "px" : "71px";
imageTag = "<img src='" + company.getLogo().getFilePath() + "' height='" + height + "' " + width + "/>";
}
switch(logoPosition) {
case PrintRepository.LOGO_POSITION_LEFT:
htmlBuilder.append("<table style='width: 100%;'><tr><td valign='top' style='text-align: left; " + logoWidth + "'>" + imageTag + "</td><td valign='top' style='width: 10%'></td><td valign='top' style='text-align: left; " + headerWidth + "'>" + pdfHeader + "</td></tr></table>");
break;
case PrintRepository.LOGO_POSITION_CENTER:
htmlBuilder.append("<table style=\"width: 100%;\"><tr><td valign='top' style='width: 33.33%;'></td><td valign='top' style='text-align: center; width: 33.33%;'>" + imageTag + "</td><td valign='top' style='text-align: left; width: 33.33%;'>" + pdfHeader + "</td></tr></table>");
break;
case PrintRepository.LOGO_POSITION_RIGHT:
htmlBuilder.append("<table style='width: 100%;'><tr><td valign='top' style='text-align: left; " + headerWidth + "'>" + pdfHeader + "</td><td valign='top' style='width: 10%'></td><td valign='top' style='text-align: center; " + logoWidth + "'>" + imageTag + "</td></tr></table>");
break;
default:
htmlBuilder.append("<table style='width: 100%;'><tr><td style='width: 60%;'></td><td valign='top' style='text-align: left; width: 40%'>" + pdfHeader + "</td></tr></table>");
break;
}
if (!pdfHeader.isEmpty() || !imageTag.isEmpty()) {
htmlBuilder.append("<hr>");
}
}
if (ObjectUtils.notEmpty(print)) {
List<PrintLine> printLineList = print.getPrintLineList();
if (CollectionUtils.isNotEmpty(printLineList)) {
for (PrintLine printLine : printLineList) {
htmlBuilder.append(printLine.getIsWithPageBreakAfter() ? "<div style=\"page-break-after: always;\">" : "<div>");
htmlBuilder.append("<table>");
htmlBuilder.append("<tr>");
if (printLine.getIsSignature()) {
htmlBuilder.append("<td> </td></tr></table></div>");
continue;
}
Integer nbColumns = printLine.getNbColumns() == 0 ? 1 : printLine.getNbColumns();
for (int i = 0; i < nbColumns; i++) {
htmlBuilder.append("<td style=\"padding: 0px 10px 0px 10px\">");
if (StringUtils.notEmpty(printLine.getTitle())) {
htmlBuilder.append(printLine.getTitle());
}
if (StringUtils.notEmpty(printLine.getContent())) {
htmlBuilder.append(printLine.getContent());
}
htmlBuilder.append("</td>");
}
htmlBuilder.append("</tr>");
htmlBuilder.append("</table>");
htmlBuilder.append("</div>");
}
}
}
htmlBuilder.append("</body>");
htmlBuilder.append("</html>");
return htmlBuilder.toString();
}
use of com.axelor.apps.base.db.Company in project axelor-open-suite by axelor.
the class PrintTemplateLineServiceImpl method initMaker.
@SuppressWarnings("unchecked")
protected TemplateMaker initMaker(Long objectId, String model, String simpleModel, Locale locale) throws ClassNotFoundException {
String timezone = null;
Company activeCompany = Optional.ofNullable(AuthUtils.getUser()).map(User::getActiveCompany).orElse(null);
if (activeCompany != null) {
timezone = activeCompany.getTimezone();
}
TemplateMaker maker = new TemplateMaker(timezone, locale, TEMPLATE_DELIMITER, TEMPLATE_DELIMITER);
Class<? extends Model> modelClass = (Class<? extends Model>) Class.forName(model);
maker.setContext(JPA.find(modelClass, objectId), simpleModel);
return maker;
}
Aggregations