Search in sources :

Example 1 with PaymentVoucher

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

the class ChequeRejectionService method createChequeRejectionMove.

/**
 * Méthode permettant de créer une écriture de rejet de chèque (L'extourne de l'écriture de
 * paiement)
 *
 * @param chequeRejection Un rejet de cheque brouillon
 * @param company Une société
 * @return L'écriture de rejet de chèque
 * @throws AxelorException
 */
public Move createChequeRejectionMove(ChequeRejection chequeRejection, Company company) throws AxelorException {
    this.testCompanyField(company);
    Journal journal = company.getAccountConfig().getRejectJournal();
    PaymentVoucher paymentVoucher = chequeRejection.getPaymentVoucher();
    Move paymentMove = paymentVoucher.getGeneratedMove();
    Partner partner = paymentVoucher.getPartner();
    InterbankCodeLine interbankCodeLine = chequeRejection.getInterbankCodeLine();
    String description = chequeRejection.getDescription();
    LocalDate rejectionDate = chequeRejection.getRejectionDate();
    // Move
    Move move = moveService.getMoveCreateService().createMove(journal, company, null, partner, rejectionDate, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
    int ref = 1;
    for (MoveLine moveLine : paymentMove.getMoveLineList()) {
        if (moveLine.getCredit().compareTo(BigDecimal.ZERO) > 0) {
            // Debit MoveLine
            MoveLine debitMoveLine = moveLineService.createMoveLine(move, partner, moveLine.getAccount(), moveLine.getCredit(), true, rejectionDate, ref, chequeRejection.getName(), chequeRejection.getDescription());
            move.getMoveLineList().add(debitMoveLine);
            debitMoveLine.setInterbankCodeLine(interbankCodeLine);
            debitMoveLine.setDescription(description);
        } else {
            // Credit MoveLine
            MoveLine creditMoveLine = moveLineService.createMoveLine(move, partner, moveLine.getAccount(), moveLine.getDebit(), false, rejectionDate, ref, chequeRejection.getName(), chequeRejection.getDescription());
            move.getMoveLineList().add(creditMoveLine);
            creditMoveLine.setInterbankCodeLine(interbankCodeLine);
            creditMoveLine.setDescription(description);
        }
        ref++;
    }
    move.setRejectOk(true);
    moveService.getMoveValidateService().validate(move);
    return move;
}
Also used : Move(com.axelor.apps.account.db.Move) InterbankCodeLine(com.axelor.apps.account.db.InterbankCodeLine) MoveLine(com.axelor.apps.account.db.MoveLine) Journal(com.axelor.apps.account.db.Journal) Partner(com.axelor.apps.base.db.Partner) LocalDate(java.time.LocalDate) PaymentVoucher(com.axelor.apps.account.db.PaymentVoucher)

Example 2 with PaymentVoucher

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

the class DepositSlipServiceImpl method compute.

private void compute(DepositSlip depositSlip) {
    if (depositSlip.getPaymentVoucherList() != null) {
        List<PaymentVoucher> paymentVoucherList = depositSlip.getPaymentVoucherList();
        BigDecimal totalAmount = paymentVoucherList.stream().map(PaymentVoucher::getPaidAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
        depositSlip.setTotalAmount(totalAmount);
        depositSlip.setChequeCount(paymentVoucherList.size());
    }
}
Also used : PaymentVoucher(com.axelor.apps.account.db.PaymentVoucher) BigDecimal(java.math.BigDecimal)

Example 3 with PaymentVoucher

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

the class PaymentVoucherManagementRepository method copy.

@Override
public PaymentVoucher copy(PaymentVoucher entity, boolean deep) {
    PaymentVoucher copy = super.copy(entity, deep);
    copy.setStatusSelect(STATUS_DRAFT);
    copy.setRef(null);
    copy.setPaymentDate(Beans.get(AppBaseService.class).getTodayDate(copy.getCompany()));
    copy.clearPayVoucherDueElementList();
    copy.clearPayVoucherElementToPayList();
    copy.setGeneratedMove(null);
    copy.setBankCardTransactionNumber(null);
    copy.clearBatchSet();
    copy.setImportId(null);
    copy.setReceiptNo(null);
    copy.setRemainingAmount(null);
    copy.setRemainingAllocatedAmount(null);
    copy.setToSaveEmailOk(false);
    copy.setDefaultEmailOk(false);
    copy.setEmail(null);
    return copy;
}
Also used : PaymentVoucher(com.axelor.apps.account.db.PaymentVoucher)

Example 4 with PaymentVoucher

use of com.axelor.apps.account.db.PaymentVoucher 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 5 with PaymentVoucher

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

the class PaymentVoucherController method loadMoveLines.

// Loading move lines of the selected partner (1st O2M)
public void loadMoveLines(ActionRequest request, ActionResponse response) {
    PaymentVoucher paymentVoucher = request.getContext().asType(PaymentVoucher.class);
    try {
        List<PayVoucherDueElement> pvDueElementList = Beans.get(PaymentVoucherLoadService.class).searchDueElements(paymentVoucher);
        response.setValue("payVoucherDueElementList", pvDueElementList);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : PayVoucherDueElement(com.axelor.apps.account.db.PayVoucherDueElement) PaymentVoucherLoadService(com.axelor.apps.account.service.payment.paymentvoucher.PaymentVoucherLoadService) PaymentVoucher(com.axelor.apps.account.db.PaymentVoucher) AxelorException(com.axelor.exception.AxelorException)

Aggregations

PaymentVoucher (com.axelor.apps.account.db.PaymentVoucher)16 AxelorException (com.axelor.exception.AxelorException)8 PaymentVoucherLoadService (com.axelor.apps.account.service.payment.paymentvoucher.PaymentVoucherLoadService)5 MoveLine (com.axelor.apps.account.db.MoveLine)3 PaymentMode (com.axelor.apps.account.db.PaymentMode)3 BankDetails (com.axelor.apps.base.db.BankDetails)3 BigDecimal (java.math.BigDecimal)3 LocalDate (java.time.LocalDate)3 Invoice (com.axelor.apps.account.db.Invoice)2 Journal (com.axelor.apps.account.db.Journal)2 PayVoucherDueElement (com.axelor.apps.account.db.PayVoucherDueElement)2 Company (com.axelor.apps.base.db.Company)2 Partner (com.axelor.apps.base.db.Partner)2 InterbankCodeLine (com.axelor.apps.account.db.InterbankCodeLine)1 InvoicePayment (com.axelor.apps.account.db.InvoicePayment)1 Move (com.axelor.apps.account.db.Move)1 PayVoucherElementToPay (com.axelor.apps.account.db.PayVoucherElementToPay)1 PaymentVoucherRepository (com.axelor.apps.account.db.repo.PaymentVoucherRepository)1 PaymentModeService (com.axelor.apps.account.service.payment.PaymentModeService)1 PaymentVoucherConfirmService (com.axelor.apps.account.service.payment.paymentvoucher.PaymentVoucherConfirmService)1