use of com.axelor.apps.account.db.Reconcile in project axelor-open-suite by axelor.
the class ReconcileManagementRepository method copy.
@Override
public Reconcile copy(Reconcile reconcile, boolean deep) {
Reconcile copy = super.copy(reconcile, deep);
copy.setCanBeZeroBalanceOk(false);
copy.setMustBeZeroBalanceOk(false);
copy.setReconcileSeq(null);
copy.setStatusSelect(ReconcileRepository.STATUS_DRAFT);
return copy;
}
use of com.axelor.apps.account.db.Reconcile in project axelor-open-suite by axelor.
the class PaymentScheduleLineBankPaymentServiceImpl method cancelInvoicePayments.
@Transactional(rollbackOn = { Exception.class })
protected void cancelInvoicePayments(PaymentScheduleLine paymentScheduleLine) throws AxelorException {
MoveLineService moveLineService = moveService.getMoveLineService();
PaymentSchedule paymentSchedule = paymentScheduleLine.getPaymentSchedule();
MoveLine creditMoveLine = paymentScheduleLine.getAdvanceMoveLine();
Set<Invoice> invoiceSet = MoreObjects.firstNonNull(paymentSchedule.getInvoiceSet(), Collections.emptySet());
for (Invoice invoice : invoiceSet) {
MoveLine debitMoveLine = moveLineService.getDebitCustomerMoveLine(invoice);
Reconcile reconcile = reconcileRepo.findByMoveLines(debitMoveLine, creditMoveLine);
if (reconcile == null) {
continue;
}
for (InvoicePayment invoicePayment : invoicePaymentRepo.findByReconcile(reconcile).fetch()) {
invoicePaymentCancelService.cancel(invoicePayment);
}
}
}
use of com.axelor.apps.account.db.Reconcile in project axelor-open-suite by axelor.
the class IrrecoverableService method createIrrecoverableMove.
/**
* Fonction permettant de créer l'écriture de passage en irrécouvrable d'une échéance
*
* @param moveLine Une écriture d'échéance
* @return
* @throws AxelorException
*/
public Move createIrrecoverableMove(MoveLine moveLine, String irrecoverableName) throws AxelorException {
Company company = moveLine.getMove().getCompany();
Partner payerPartner = moveLine.getPartner();
BigDecimal amount = moveLine.getAmountRemaining();
AccountConfig accountConfig = company.getAccountConfig();
// Move
Move move = moveService.getMoveCreateService().createMove(accountConfig.getIrrecoverableJournal(), company, null, payerPartner, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, moveLine.getMove().getFunctionalOriginSelect());
int seq = 1;
// Credit MoveLine Customer account (411, 416, ...)
MoveLine creditMoveLine = moveLineService.createMoveLine(move, payerPartner, moveLine.getAccount(), amount, false, appAccountService.getTodayDate(company), seq, irrecoverableName, moveLine.getDescription());
move.getMoveLineList().add(creditMoveLine);
Reconcile reconcile = reconcileService.createReconcile(moveLine, creditMoveLine, amount, false);
if (reconcile != null) {
reconcileService.confirmReconcile(reconcile, true);
}
Tax tax = accountConfig.getIrrecoverableStandardRateTax();
BigDecimal taxRate = taxService.getTaxRate(tax, appAccountService.getTodayDate(company));
// Debit MoveLine 654. (irrecoverable account)
BigDecimal divid = taxRate.add(BigDecimal.ONE);
BigDecimal irrecoverableAmount = amount.divide(divid, 6, RoundingMode.HALF_UP).setScale(AppBaseService.DEFAULT_NB_DECIMAL_DIGITS, RoundingMode.HALF_UP);
MoveLine creditMoveLine1 = moveLineService.createMoveLine(move, payerPartner, accountConfig.getIrrecoverableAccount(), irrecoverableAmount, true, appAccountService.getTodayDate(company), 2, irrecoverableName, moveLine.getDescription());
move.getMoveLineList().add(creditMoveLine1);
// Debit MoveLine 445 (Tax account)
Account taxAccount = taxAccountService.getAccount(tax, company, false, false);
BigDecimal taxAmount = amount.subtract(irrecoverableAmount);
MoveLine creditMoveLine2 = moveLineService.createMoveLine(move, payerPartner, taxAccount, taxAmount, true, appAccountService.getTodayDate(company), 3, irrecoverableName, moveLine.getDescription());
move.getMoveLineList().add(creditMoveLine2);
return move;
}
use of com.axelor.apps.account.db.Reconcile in project axelor-open-suite by axelor.
the class IrrecoverableService method createIrrecoverableMove.
/**
* Fonction permettant de créer l'écriture de passage en irrécouvrable d'une facture
*
* @param invoice Une facture
* @param prorataRate Le taux de restant à payer sur la facture
* @param isInvoiceReject La facture est-elle rejetée?
* @return
* @throws AxelorException
*/
public Move createIrrecoverableMove(Invoice invoice, BigDecimal prorataRate, boolean isInvoiceReject, String irrecoverableName) throws AxelorException {
Company company = invoice.getCompany();
Partner payerPartner = invoice.getPartner();
AccountConfig accountConfig = company.getAccountConfig();
// Move
Move move = moveService.getMoveCreateService().createMove(accountConfig.getIrrecoverableJournal(), company, null, payerPartner, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_SALE);
int seq = 1;
BigDecimal amount = BigDecimal.ZERO;
MoveLine debitMoveLine = null;
BigDecimal creditAmount = null;
BigDecimal debitAmount = null;
if (isInvoiceReject) {
creditAmount = invoice.getRejectMoveLine().getAmountRemaining();
debitAmount = creditAmount;
} else {
creditAmount = invoice.getCompanyInTaxTotalRemaining();
debitAmount = creditAmount;
}
// Debits MoveLines Tva
for (InvoiceLineTax invoiceLineTax : invoice.getInvoiceLineTaxList()) {
amount = (invoiceLineTax.getTaxTotal().multiply(prorataRate)).setScale(2, RoundingMode.HALF_UP);
// do not generate move line with amount equal to zero
if (amount.signum() == 0) {
continue;
}
debitMoveLine = moveLineService.createMoveLine(move, payerPartner, taxAccountService.getAccount(invoiceLineTax.getTaxLine().getTax(), company, false, false), amount, true, appAccountService.getTodayDate(company), seq, irrecoverableName, invoice.getInvoiceId());
move.getMoveLineList().add(debitMoveLine);
seq++;
debitAmount = debitAmount.subtract(amount);
}
// Debit MoveLine 654 (irrecoverable account)
debitMoveLine = moveLineService.createMoveLine(move, payerPartner, accountConfig.getIrrecoverableAccount(), debitAmount, true, appAccountService.getTodayDate(company), seq, irrecoverableName, invoice.getInvoiceId());
move.getMoveLineList().add(debitMoveLine);
seq++;
// Getting customer MoveLine from Facture
MoveLine customerMoveLine = moveService.getMoveToolService().getCustomerMoveLineByQuery(invoice);
if (customerMoveLine == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.IRRECOVERABLE_3), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION), invoice.getInvoiceId());
}
customerMoveLine.setIrrecoverableStatusSelect(MoveLineRepository.IRRECOVERABLE_STATUS_PASSED_IN_IRRECOUVRABLE);
// Credit MoveLine Customer account (411, 416, ...)
MoveLine creditMoveLine = moveLineService.createMoveLine(move, payerPartner, customerMoveLine.getAccount(), creditAmount, false, appAccountService.getTodayDate(company), seq, irrecoverableName, invoice.getInvoiceId());
move.getMoveLineList().add(creditMoveLine);
Reconcile reconcile = reconcileService.createReconcile(customerMoveLine, creditMoveLine, creditAmount, false);
if (reconcile != null) {
reconcileService.confirmReconcile(reconcile, true);
}
return move;
}
use of com.axelor.apps.account.db.Reconcile in project axelor-open-suite by axelor.
the class ReconcileGroupServiceImpl method remove.
@Override
public void remove(Reconcile reconcile) throws AxelorException {
ReconcileGroup reconcileGroup = reconcile.getReconcileGroup();
// update move lines
List<MoveLine> moveLineToRemoveList = moveLineRepository.findByReconcileGroup(reconcileGroup).fetch();
moveLineToRemoveList.forEach(moveLine -> moveLine.setReconcileGroup(null));
List<Reconcile> reconcileList = this.getReconcileList(reconcileGroup);
reconcileList.stream().map(Reconcile::getDebitMoveLine).forEach(moveLine -> moveLine.setReconcileGroup(reconcileGroup));
reconcileList.stream().map(Reconcile::getCreditMoveLine).forEach(moveLine -> moveLine.setReconcileGroup(reconcileGroup));
// update status
updateStatus(reconcileGroup);
}
Aggregations