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;
}
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());
}
}
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;
}
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;
}
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);
}
}
Aggregations