use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class ReimbursementImportService method testCompanyField.
/**
* Procédure permettant de tester la présence des champs et des séquences nécessaire aux rejets de
* remboursement.
*
* @param company Une société
* @throws AxelorException
*/
public void testCompanyField(Company company) throws AxelorException {
log.debug("Test de la société {}", company.getName());
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
accountConfigService.getReimbursementAccount(accountConfig);
accountConfigService.getRejectJournal(accountConfig);
accountConfigService.getReimbursementImportFolderPathCFONB(accountConfig);
accountConfigService.getTempReimbImportFolderPathCFONB(accountConfig);
}
use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class ReimbursementImportService method runReimbursementImport.
@Transactional(rollbackOn = { Exception.class })
public void runReimbursementImport(Company company) throws AxelorException, IOException {
String dataUploadDir = AppService.getFileUploadDir();
this.testCompanyField(company);
AccountConfig accountConfig = company.getAccountConfig();
this.createReimbursementRejectMove(rejectImportService.getCFONBFile(dataUploadDir + accountConfig.getReimbursementImportFolderPathCFONB(), dataUploadDir + accountConfig.getTempReimbImportFolderPathCFONB(), company, 0), company);
}
use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class SubrogationReleaseServiceImpl method enterReleaseInTheAccounts.
@Override
@Transactional(rollbackOn = { Exception.class })
public void enterReleaseInTheAccounts(SubrogationRelease subrogationRelease) throws AxelorException {
MoveService moveService = Beans.get(MoveService.class);
MoveRepository moveRepository = Beans.get(MoveRepository.class);
AccountConfigService accountConfigService = Beans.get(AccountConfigService.class);
AppBaseService appBaseService = Beans.get(AppBaseService.class);
Company company = subrogationRelease.getCompany();
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
Journal journal = accountConfigService.getAutoMiscOpeJournal(accountConfig);
Account factorCreditAccount = accountConfigService.getFactorCreditAccount(accountConfig);
Account factorDebitAccount = accountConfigService.getFactorDebitAccount(accountConfig);
if (subrogationRelease.getAccountingDate() == null) {
subrogationRelease.setAccountingDate(appBaseService.getTodayDate(company));
}
this.checkIfAnOtherSubrogationAlreadyExist(subrogationRelease);
for (Invoice invoice : subrogationRelease.getInvoiceSet()) {
boolean isRefund = false;
if (invoice.getOperationTypeSelect() == InvoiceRepository.OPERATION_TYPE_CLIENT_REFUND) {
isRefund = true;
}
LocalDate date = subrogationRelease.getAccountingDate();
Move move = moveService.getMoveCreateService().createMove(journal, company, company.getCurrency(), invoice.getPartner(), date, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
MoveLine creditMoveLine, debitMoveLine;
debitMoveLine = moveService.getMoveLineService().createMoveLine(move, invoice.getPartner(), factorDebitAccount, invoice.getCompanyInTaxTotalRemaining(), !isRefund, date, null, 1, subrogationRelease.getSequenceNumber(), invoice.getInvoiceId());
creditMoveLine = moveService.getMoveLineService().createMoveLine(move, invoice.getPartner(), factorCreditAccount, invoice.getCompanyInTaxTotalRemaining(), isRefund, date, null, 2, subrogationRelease.getSequenceNumber(), invoice.getInvoiceId());
move.addMoveLineListItem(debitMoveLine);
move.addMoveLineListItem(creditMoveLine);
move = moveRepository.save(move);
moveService.getMoveValidateService().validate(move);
invoice.setSubrogationRelease(subrogationRelease);
invoice.setSubrogationReleaseMove(move);
subrogationRelease.addMoveListItem(move);
}
subrogationRelease.setStatusSelect(SubrogationReleaseRepository.STATUS_ACCOUNTED);
}
use of com.axelor.apps.account.db.AccountConfig 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.AccountConfig 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;
}
Aggregations