Search in sources :

Example 31 with MoveLine

use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.

the class ImportMoveLine method importMoveLine.

@Transactional(rollbackOn = Exception.class)
public Object importMoveLine(Object bean, Map<String, Object> values) throws AxelorException {
    assert bean instanceof MoveLine;
    MoveLine moveLine = (MoveLine) bean;
    String accountId = (String) values.get("account_importId");
    Account account = getAccount(accountId);
    if (account != null) {
        moveLine.setAccountCode(account.getCode());
        moveLine.setAccountName(account.getName());
    } else {
        moveLine.setAccountCode((String) values.get("accountCode"));
        moveLine.setAccountName((String) values.get("accountName"));
    }
    String taxLineId = (String) values.get("taxLine_importId");
    TaxLine taxLine = getTaxLine(taxLineId);
    if (taxLine != null) {
        moveLine.setTaxCode(taxLine.getTax().getCode());
        moveLine.setTaxRate(taxLine.getValue());
    } else {
        moveLine.setTaxCode((String) values.get("taxCode"));
        moveLine.setTaxRate(new BigDecimal((String) values.get("taxRate")));
    }
    String partnerId = (String) values.get("partner_importId");
    Partner partner = getPartner(partnerId);
    if (partner != null) {
        moveLine.setPartnerSeq(partner.getPartnerSeq());
        moveLine.setPartnerFullName(partner.getFullName());
    } else {
        moveLine.setPartnerSeq((String) values.get("partnerSeq"));
        moveLine.setPartnerFullName((String) values.get("partnerFullName"));
    }
    moveLineRepository.save(moveLine);
    return moveLine;
}
Also used : Account(com.axelor.apps.account.db.Account) MoveLine(com.axelor.apps.account.db.MoveLine) Partner(com.axelor.apps.base.db.Partner) BigDecimal(java.math.BigDecimal) TaxLine(com.axelor.apps.account.db.TaxLine) Transactional(com.google.inject.persist.Transactional)

Example 32 with MoveLine

use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.

the class ImportPaymentVoucher method importPaymentVoucher.

@SuppressWarnings("rawtypes")
public Object importPaymentVoucher(Object bean, Map values) {
    assert bean instanceof PaymentVoucher;
    try {
        PaymentVoucher paymentVoucher = (PaymentVoucher) bean;
        Invoice invoiceToPay = getInvoice((String) values.get("orderImport"));
        MoveLine moveLineToPay = this.getMoveLineToPay(paymentVoucher, invoiceToPay);
        if (moveLineToPay != null) {
            PayVoucherDueElement payVoucherDueElement = paymentVoucherLoadService.createPayVoucherDueElement(moveLineToPay);
            paymentVoucher.addPayVoucherElementToPayListItem(paymentVoucherLoadService.createPayVoucherElementToPay(paymentVoucher, payVoucherDueElement, 1));
        }
        if (paymentVoucher.getStatusSelect() == PaymentVoucherRepository.STATUS_CONFIRMED) {
            paymentVoucherConfirmService.confirmPaymentVoucher(paymentVoucher);
        }
        return paymentVoucher;
    } catch (Exception e) {
        TraceBackService.trace(e);
    }
    return bean;
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) MoveLine(com.axelor.apps.account.db.MoveLine) PayVoucherDueElement(com.axelor.apps.account.db.PayVoucherDueElement) PaymentVoucher(com.axelor.apps.account.db.PaymentVoucher) AxelorException(com.axelor.exception.AxelorException)

Example 33 with MoveLine

use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.

the class MoveController method checkRemoveLines.

public void checkRemoveLines(ActionRequest request, ActionResponse response) {
    try {
        Move moveView = request.getContext().asType(Move.class);
        if (moveView.getId() == null) {
            return;
        }
        Move moveBD = Beans.get(MoveRepository.class).find(moveView.getId());
        List<String> moveLineReconciledAndRemovedNameList = new ArrayList<>();
        for (MoveLine moveLineBD : moveBD.getMoveLineList()) {
            if (!moveView.getMoveLineList().contains(moveLineBD)) {
                if (moveLineBD.getReconcileGroup() != null) {
                    moveLineReconciledAndRemovedNameList.add(moveLineBD.getName());
                }
            }
        }
        if (moveLineReconciledAndRemovedNameList != null && !moveLineReconciledAndRemovedNameList.isEmpty()) {
            response.setError(String.format(I18n.get(IExceptionMessage.MOVE_LINE_RECONCILE_LINE_CANNOT_BE_REMOVED), moveLineReconciledAndRemovedNameList.toString()));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : MoveRepository(com.axelor.apps.account.db.repo.MoveRepository) Move(com.axelor.apps.account.db.Move) ArrayList(java.util.ArrayList) MoveLine(com.axelor.apps.account.db.MoveLine) AxelorException(com.axelor.exception.AxelorException)

Example 34 with MoveLine

use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.

the class MoveLineController method computeTaxAmount.

public void computeTaxAmount(ActionRequest request, ActionResponse response) {
    try {
        MoveLine moveLine = request.getContext().asType(MoveLine.class);
        moveLine = Beans.get(MoveLineService.class).computeTaxAmount(moveLine);
        response.setValues(moveLine);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : MoveLine(com.axelor.apps.account.db.MoveLine) AxelorException(com.axelor.exception.AxelorException)

Example 35 with MoveLine

use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.

the class MoveLineController method usherProcess.

public void usherProcess(ActionRequest request, ActionResponse response) {
    MoveLine moveLine = request.getContext().asType(MoveLine.class);
    moveLine = Beans.get(MoveLineRepository.class).find(moveLine.getId());
    try {
        Beans.get(MoveLineService.class).usherProcess(moveLine);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : MoveLineService(com.axelor.apps.account.service.move.MoveLineService) MoveLine(com.axelor.apps.account.db.MoveLine) AxelorException(com.axelor.exception.AxelorException)

Aggregations

MoveLine (com.axelor.apps.account.db.MoveLine)135 BigDecimal (java.math.BigDecimal)60 Move (com.axelor.apps.account.db.Move)51 Transactional (com.google.inject.persist.Transactional)42 AxelorException (com.axelor.exception.AxelorException)40 Company (com.axelor.apps.base.db.Company)38 ArrayList (java.util.ArrayList)38 Partner (com.axelor.apps.base.db.Partner)33 Account (com.axelor.apps.account.db.Account)28 LocalDate (java.time.LocalDate)27 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)25 Journal (com.axelor.apps.account.db.Journal)22 Reconcile (com.axelor.apps.account.db.Reconcile)22 AccountConfig (com.axelor.apps.account.db.AccountConfig)17 Invoice (com.axelor.apps.account.db.Invoice)15 List (java.util.List)13 TaxPaymentMoveLine (com.axelor.apps.account.db.TaxPaymentMoveLine)8 Tax (com.axelor.apps.account.db.Tax)7 TaxLine (com.axelor.apps.account.db.TaxLine)7 MoveLineRepository (com.axelor.apps.account.db.repo.MoveLineRepository)7