public void createPaymentMoveLine(Move paymentMove, MoveLine moveLine, int ref) throws AxelorException { BigDecimal amountExported = moveLine.getAmountRemaining(); // On assigne le montant exporté pour pouvoir l'utiliser lors de la création du fichier d'export // CFONB moveLine.setAmountExportedInDirectDebit(amountExported); // creation d'une ecriture de paiement log.debug("generateAllExportInvoice - Création de la première ligne d'écriture"); String invoiceName = ""; if (moveLine.getMove().getInvoice() != null) { invoiceName = moveLine.getMove().getInvoice().getInvoiceId(); } MoveLine moveLineGenerated = moveLineServices.createMoveLine( paymentMove, moveLine.getPartner(), moveLine.getAccount(), amountExported, false, today, ref, invoiceName); paymentMove.getMoveLineList().add(moveLineGenerated); moveLineRepo.save(moveLineGenerated); // Lettrage de la ligne 411 avec la ligne 411 de la facture log.debug("Creation du lettrage de la ligne 411 avec la ligne 411 de la facture"); reconcileService.reconcile(moveLine, moveLineGenerated); log.debug("generateAllExportInvoice - Sauvegarde de l'écriture"); moveRepo.save(paymentMove); }
/** * Procédure permettant de créer une écriture de paiement d'une facture * * @param company Une société * @param moveLine Une ligne d'écriture * @param pm Un mode de paiement * @param pse Un Export des prélèvement * @throws AxelorException */ public Move createPaymentMove(Company company, MoveLine moveLine, PaymentMode paymentMode) throws AxelorException { log.debug("Create payment move"); Move paymentMove = moveService .getMoveCreateService() .createMove( paymentModeService.getPaymentModeJournal(paymentMode, company), company, null, null, paymentMode); BigDecimal amountExported = moveLine.getAmountRemaining(); this.createPaymentMoveLine(paymentMove, moveLine, 1); log.debug("Create payment move line"); Account paymentModeAccount = paymentModeService.getCompanyAccount(paymentMode, company); String invoiceName = ""; if (moveLine.getMove().getInvoice() != null) { invoiceName = moveLine.getMove().getInvoice().getInvoiceId(); } MoveLine moveLineGenerated2 = moveLineServices.createMoveLine( paymentMove, null, paymentModeAccount, amountExported, true, today, 2, invoiceName); paymentMove.getMoveLineList().add(moveLineGenerated2); moveLineRepo.save(moveLineGenerated2); moveService.getMoveValidateService().validateMove(paymentMove); moveRepo.save(paymentMove); return paymentMove; }
@Transactional(rollbackOn = {AxelorException.class, Exception.class}) public Move validateMove(Move move) throws AxelorException { moveService.getMoveValidateService().validateMove(move); moveRepo.save(move); return move; }