public void updatePartnerAccountingSituation(Reconcile reconcile, boolean updateCustomerAccount) { Company company = null; List<Partner> partnerList = new ArrayList<Partner>(); MoveLine debitMoveLine = reconcile.getLineDebit(); MoveLine creditMoveLine = reconcile.getLineCredit(); Partner debitPartner = debitMoveLine.getPartner(); Partner creditPartner = creditMoveLine.getPartner(); if (debitPartner != null) { Move move = debitMoveLine.getMove(); if (move != null && move.getCompany() != null) { partnerList.add(debitPartner); company = move.getCompany(); } } if (creditPartner != null) { Move move = creditMoveLine.getMove(); if (move != null && move.getCompany() != null) { partnerList.add(creditPartner); company = move.getCompany(); } } if (partnerList != null && !partnerList.isEmpty() && company != null) { if (updateCustomerAccount) { acs.updatePartnerAccountingSituation(partnerList, company, true, true, false); } else { acs.flagPartners(partnerList, company); } } }
/** * Procédure permettant de récupérer l'écriture d'avoir d'un trop-perçu généré par un avoir * * @param moveLine un trop-perçu * @return */ public Move getRefundMove(MoveLine moveLine) { Move move = moveLine.getMove(); if (move.getJournal().equals(move.getCompany().getTechnicalJournal())) { MoveLine oppositeMoveLine = ms.getOppositeMoveLine(moveLine); if (oppositeMoveLine.getReconcileList1() != null && oppositeMoveLine.getReconcileList1().size() == 1) { return oppositeMoveLine.getReconcileList1().get(0).getLineCredit().getMove(); } } return null; }
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; }
public List<MoveLine> getInvoiceToExport( Company company, LocalDate scheduleDate, Currency currency) { List<MoveLine> moveLineInvoiceList = new ArrayList<MoveLine>(); PaymentMode paymentMode = company.getAccountConfig().getDirectDebitPaymentMode(); /** * Selection des lignes d'écritures dont : - l'état est validé - la société est celle * selectionnée sur l'objet export - le compte est lettrable - le montant restant à payer est * supérieur à 0 et débit supérieur à 0 (équivaut à une facture et non un avoir) - le mode de * règlement de la facture est en prélèvement - la date d'échéance est passée - la facture est * remplie sur l'écriture - la facture n'est pas selectionnée sur un échéancier */ List<MoveLine> moveLineList = moveLineRepo .all() .filter( "self.move.statusSelect = ?1 AND self.exportedDirectDebitOk = 'false' " + "AND self.move.company = ?2 " + "AND self.account.reconcileOk = ?3 AND self.amountRemaining > 0 " + "AND self.debit > 0 " + "AND self.dueDate <= ?5 AND self.move.invoice IS NOT NULL " + "AND self.move.invoice.paymentMode = ?4 " + "AND self.move.invoice.schedulePaymentOk = 'false' " + "AND self.move.invoice.currency = ?5", MoveRepository.STATUS_VALIDATED, company, true, paymentMode, currency) .fetch(); // Ajout des factures for (MoveLine moveLine : moveLineList) { if (!this.isDebitBlocking(moveLine.getMove().getInvoice())) { moveLineInvoiceList.add(moveLine); } } // Récupération des factures rejetées List<Invoice> invoiceRejectList = invoiceRepo .all() .filter( "self.rejectMoveLine IS NOT NULL AND self.rejectMoveLine.amountRemaining > 0 AND self.rejectMoveLine.debit > 0" + " AND self.paymentMode = ?1 AND self.company = ?2 AND self.rejectMoveLine.exportedDirectDebitOk = 'false' AND self.move.statusSelect = ?3" + " AND self.rejectMoveLine.account.reconcileOk = 'true' " + " AND self.rejectMoveLine.invoiceReject IS NOT NULL" + " AND self.currency = ?4", paymentMode, company, MoveRepository.STATUS_VALIDATED, currency) .fetch(); // Ajout des factures rejetées for (Invoice invoice : invoiceRejectList) { if (!this.isDebitBlocking(invoice)) { moveLineInvoiceList.add(invoice.getRejectMoveLine()); } } return moveLineInvoiceList; }