use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class NotificationServiceImpl method createPaymentMove.
@Transactional(rollbackOn = { Exception.class })
protected Move createPaymentMove(NotificationItem notificationItem) throws AxelorException {
Notification notification = notificationItem.getNotification();
Invoice invoice = notificationItem.getInvoice();
Company company = invoice.getCompany();
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
Journal journal = getJournal(accountConfig);
SubrogationRelease subrogationRelease = getSubrogationRelease(notificationItem);
String origin = computeOrigin(subrogationRelease, invoice);
BigDecimal amountPaid = notificationItem.getAmountPaid();
if (amountPaid.compareTo(BigDecimal.ZERO) == 0) {
return null;
}
Move paymentMove = moveService.getMoveCreateService().createMove(journal, company, company.getCurrency(), invoice.getPartner(), notification.getPaymentDate(), null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
MoveLine creditMoveLine, debitMoveLine;
Account account = getAccount(accountConfig, notificationItem);
debitMoveLine = moveService.getMoveLineService().createMoveLine(paymentMove, invoice.getPartner(), account, amountPaid, true, notification.getPaymentDate(), null, 1, origin, invoice.getInvoiceId());
creditMoveLine = moveService.getMoveLineService().createMoveLine(paymentMove, invoice.getPartner(), invoice.getPartnerAccount(), amountPaid, false, notification.getPaymentDate(), null, 2, origin, invoice.getInvoiceId());
paymentMove.addMoveLineListItem(debitMoveLine);
paymentMove.addMoveLineListItem(creditMoveLine);
paymentMove = moveRepository.save(paymentMove);
moveService.getMoveValidateService().validate(paymentMove);
MoveLine invoiceMoveLine = findInvoiceAccountMoveLine(invoice);
MoveLine subrogationReleaseMoveLine = findSubrogationReleaseAccountMoveLine(invoice);
if (invoiceMoveLine.getAmountRemaining().compareTo(BigDecimal.ZERO) == 1) {
reconcileService.reconcile(invoiceMoveLine, creditMoveLine, true, true);
if (subrogationReleaseMoveLine != null && notificationItem.getTypeSelect() == NotificationRepository.TYPE_PAYMENT_TO_THE_FACTORE) {
reconcileService.reconcile(debitMoveLine, subrogationReleaseMoveLine, true, false);
}
}
notificationItem.setMove(paymentMove);
if (subrogationRelease != null) {
subrogationReleaseService.clear(subrogationRelease);
}
return paymentMove;
}
use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class BankDetailsServiceAccountImpl method createCompanyBankDetailsDomainFromFactorPartner.
private List<BankDetails> createCompanyBankDetailsDomainFromFactorPartner(Company company) throws AxelorException {
AccountConfig accountConfig = Beans.get(AccountConfigService.class).getAccountConfig(company);
List<BankDetails> bankDetailsList = accountConfig.getFactorPartner().getBankDetailsList();
return bankDetailsList.stream().filter(bankDetails -> bankDetails.getActive()).collect(Collectors.toList());
}
use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class CfonbExportService method testCompanyExportCFONBField.
/**
* Procédure permettant de vérifier la conformité des champs en rapport avec les exports CFONB
* d'une société
*
* @param company La société
* @throws AxelorException
*/
public void testCompanyExportCFONBField(Company company) throws AxelorException {
AccountConfig accountConfig = cfonbConfigService.getAccountConfig(company);
cfonbConfigService.getReimbursementExportFolderPathCFONB(accountConfig);
cfonbConfigService.getPaymentScheduleExportFolderPathCFONB(accountConfig);
this.init(cfonbConfigService.getCfonbConfig(company));
cfonbConfigService.getSenderRecordCodeExportCFONB(this.cfonbConfig);
cfonbConfigService.getSenderNumExportCFONB(this.cfonbConfig);
cfonbConfigService.getSenderNameCodeExportCFONB(this.cfonbConfig);
cfonbConfigService.getRecipientRecordCodeExportCFONB(this.cfonbConfig);
cfonbConfigService.getTotalRecordCodeExportCFONB(this.cfonbConfig);
cfonbConfigService.getTransferOperationCodeExportCFONB(this.cfonbConfig);
cfonbConfigService.getDirectDebitOperationCodeExportCFONB(this.cfonbConfig);
}
use of com.axelor.apps.account.db.AccountConfig 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.AccountConfig 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);
}
}
}
}
}
Aggregations