use of com.axelor.apps.account.db.Reconcile in project axelor-open-suite by axelor.
the class ReconcileGroupServiceImpl method mergeReconcileGroups.
@Override
@Transactional
public ReconcileGroup mergeReconcileGroups(List<ReconcileGroup> reconcileGroupList) {
Company company = reconcileGroupList.get(0).getCompany();
ReconcileGroup reconcileGroup = createReconcileGroup(company);
List<Reconcile> reconcileList = reconcileRepository.all().filter("self.reconcileGroup.id IN (:reconcileGroupIds)").bind("reconcileGroupIds", reconcileGroupList.stream().map(ReconcileGroup::getId).collect(Collectors.toList())).fetch();
reconcileList.forEach(reconcile -> addToReconcileGroup(reconcileGroup, reconcile));
for (ReconcileGroup toDeleteReconcileGroup : reconcileGroupList) {
reconcileGroupRepository.remove(toDeleteReconcileGroup);
}
return reconcileGroupRepository.save(reconcileGroup);
}
use of com.axelor.apps.account.db.Reconcile in project axelor-open-suite by axelor.
the class ReconcileServiceImpl method reconcile.
/**
* Méthode permettant de lettrer une écriture au débit avec une écriture au crédit
*
* @param debitMoveLine
* @param creditMoveLine
* @throws AxelorException
*/
public Reconcile reconcile(MoveLine debitMoveLine, MoveLine creditMoveLine, boolean canBeZeroBalanceOk, boolean updateInvoicePayments) throws AxelorException {
BigDecimal amount = debitMoveLine.getAmountRemaining().min(creditMoveLine.getAmountRemaining());
Reconcile reconcile = this.createReconcile(debitMoveLine, creditMoveLine, amount, canBeZeroBalanceOk);
if (reconcile != null) {
this.confirmReconcile(reconcile, updateInvoicePayments);
return reconcile;
}
return null;
}
use of com.axelor.apps.account.db.Reconcile in project axelor-open-suite by axelor.
the class ReconcileServiceImpl method canBeZeroBalance.
/**
* Procédure permettant de gérer les écarts de règlement, check sur la case à cocher 'Peut être
* soldé' Alors nous utilisons la règle de gestion consitant à imputer l'écart sur un compte
* transitoire si le seuil est respecté
*
* @param reconcile Une reconciliation
* @throws AxelorException
*/
@Transactional(rollbackOn = { Exception.class })
public void canBeZeroBalance(Reconcile reconcile) throws AxelorException {
MoveLine debitMoveLine = reconcile.getDebitMoveLine();
BigDecimal debitAmountRemaining = debitMoveLine.getAmountRemaining();
log.debug("Montant à payer / à lettrer au débit : {}", debitAmountRemaining);
if (debitAmountRemaining.compareTo(BigDecimal.ZERO) > 0) {
Company company = reconcile.getDebitMoveLine().getMove().getCompany();
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
if (debitAmountRemaining.plus().compareTo(accountConfig.getThresholdDistanceFromRegulation()) < 0 || reconcile.getMustBeZeroBalanceOk()) {
log.debug("Seuil respecté");
MoveLine creditAdjustMoveLine = moveAdjustementService.createAdjustmentCreditMove(debitMoveLine);
// Création de la réconciliation
Reconcile newReconcile = this.createReconcile(debitMoveLine, creditAdjustMoveLine, debitAmountRemaining, false);
if (newReconcile != null) {
this.confirmReconcile(newReconcile, true);
reconcileRepository.save(newReconcile);
}
}
}
reconcile.setCanBeZeroBalanceOk(false);
log.debug("Fin de la gestion des écarts de règlement");
}
use of com.axelor.apps.account.db.Reconcile in project axelor-open-suite by axelor.
the class ReconcileServiceImpl method balanceCredit.
/**
* Solder le trop-perçu si il respect les règles de seuil
*
* @param creditMoveLine
* @param company
* @throws AxelorException
*/
public void balanceCredit(MoveLine creditMoveLine) throws AxelorException {
if (creditMoveLine != null) {
BigDecimal creditAmountRemaining = creditMoveLine.getAmountRemaining();
log.debug("Montant à payer / à lettrer au crédit : {}", creditAmountRemaining);
if (creditAmountRemaining.compareTo(BigDecimal.ZERO) > 0) {
AccountConfig accountConfig = accountConfigService.getAccountConfig(creditMoveLine.getMove().getCompany());
if (creditAmountRemaining.plus().compareTo(accountConfig.getThresholdDistanceFromRegulation()) < 0) {
log.debug("Seuil respecté");
MoveLine debitAdjustmentMoveLine = moveAdjustementService.createAdjustmentCreditMove(creditMoveLine);
// Création de la réconciliation
Reconcile newReconcile = this.createReconcile(debitAdjustmentMoveLine, creditMoveLine, creditAmountRemaining, false);
if (newReconcile != null) {
this.confirmReconcile(newReconcile, true);
reconcileRepository.save(newReconcile);
}
}
}
}
}
use of com.axelor.apps.account.db.Reconcile in project axelor-open-suite by axelor.
the class DoubtfulCustomerService method createDoubtFulCustomerRejectMove.
/**
* Procédure permettant de créer les écritures de passage en client douteux pour chaque ligne
* d'écriture de rejet de facture
*
* @param moveLine Une ligne d'écritures de rejet de facture
* @param doubtfulCustomerAccount Un compte client douteux
* @param debtPassReason Un motif de passage en client douteux
* @throws AxelorException
*/
@Transactional(rollbackOn = { Exception.class })
public void createDoubtFulCustomerRejectMove(MoveLine moveLine, Account doubtfulCustomerAccount, String debtPassReason) throws AxelorException {
log.debug("Ecriture concernée : {} ", moveLine.getName());
Company company = moveLine.getMove().getCompany();
Partner partner = moveLine.getPartner();
LocalDate todayDate = appBaseService.getTodayDate(company);
Move newMove = moveService.getMoveCreateService().createMove(company.getAccountConfig().getAutoMiscOpeJournal(), company, null, partner, moveLine.getMove().getPaymentMode(), MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, moveLine.getMove().getFunctionalOriginSelect());
BigDecimal amountRemaining = moveLine.getAmountRemaining();
// Ecriture au crédit sur le 411
MoveLine creditMoveLine = moveLineService.createMoveLine(newMove, partner, moveLine.getAccount(), amountRemaining, false, todayDate, 1, moveLine.getName(), debtPassReason);
newMove.addMoveLineListItem(creditMoveLine);
Reconcile reconcile = reconcileService.createReconcile(moveLine, creditMoveLine, amountRemaining, false);
if (reconcile != null) {
reconcileService.confirmReconcile(reconcile, true);
}
// Ecriture au débit sur le 416 (client douteux)
MoveLine debitMoveLine = moveLineService.createMoveLine(newMove, newMove.getPartner(), doubtfulCustomerAccount, amountRemaining, true, todayDate, 2, moveLine.getName(), debtPassReason);
newMove.getMoveLineList().add(debitMoveLine);
debitMoveLine.setInvoiceReject(moveLine.getInvoiceReject());
debitMoveLine.setPassageReason(debtPassReason);
moveService.getMoveValidateService().validate(newMove);
moveRepo.save(newMove);
this.invoiceRejectProcess(debitMoveLine, doubtfulCustomerAccount, debtPassReason);
}
Aggregations