use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class AccountingSituationServiceImpl method getEmployeeAccount.
@Override
public Account getEmployeeAccount(Partner partner, Company company) throws AxelorException {
Account account = null;
AccountingSituation accountingSituation = getAccountingSituation(partner, company);
if (accountingSituation != null) {
account = accountingSituation.getEmployeeAccount();
}
if (account == null) {
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
account = accountConfigService.getEmployeeAccount(accountConfig);
}
return account;
}
use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class BatchReimbursementImport method process.
@Override
protected void process() {
if (!end) {
Company company = batch.getAccountingBatch().getCompany();
company = companyRepo.find(company.getId());
AccountConfig accountConfig = company.getAccountConfig();
Map<List<String[]>, String> data = null;
try {
String dataImportDir = AppService.getFileUploadDir();
String reimbursementImportFolderPathCFONB = accountConfig.getReimbursementImportFolderPathCFONB() == null ? null : dataImportDir + accountConfig.getReimbursementImportFolderPathCFONB();
rejectImportService.createFilePath(reimbursementImportFolderPathCFONB);
data = rejectImportService.getCFONBFileByLot(reimbursementImportFolderPathCFONB, accountConfig.getTempReimbImportFolderPathCFONB() == null ? null : dataImportDir + accountConfig.getTempReimbImportFolderPathCFONB(), company, 0);
} catch (AxelorException e) {
TraceBackService.trace(new AxelorException(e, e.getCategory(), I18n.get(IExceptionMessage.BATCH_REIMBURSEMENT_6), batch.getId()), ExceptionOriginRepository.REIMBURSEMENT, batch.getId());
incrementAnomaly();
stop();
} catch (Exception e) {
TraceBackService.trace(new Exception(String.format(I18n.get(IExceptionMessage.BATCH_REIMBURSEMENT_6), batch.getId()), e), ExceptionOriginRepository.REIMBURSEMENT, batch.getId());
incrementAnomaly();
log.error("Bug(Anomalie) généré(e) pour le batch d'import des remboursements {}", batch.getId());
stop();
}
int seq = 1;
int i = 0;
for (Entry<List<String[]>, String> entry : data.entrySet()) {
LocalDate rejectDate = rejectImportService.createRejectDate(entry.getValue());
Move move = this.createMove(company, rejectDate);
for (String[] reject : entry.getKey()) {
try {
Reimbursement reimbursement = reimbursementImportService.createReimbursementRejectMoveLine(reject, companyRepo.find(company.getId()), seq, moveRepo.find(move.getId()), rejectDate);
if (reimbursement != null) {
log.debug("Remboursement n° {} traité", reimbursement.getRef());
seq++;
i++;
updateReimbursement(reimbursement);
}
} catch (AxelorException e) {
TraceBackService.trace(new AxelorException(e, e.getCategory(), I18n.get(IExceptionMessage.BATCH_REIMBURSEMENT_7), reject[1]), ExceptionOriginRepository.REIMBURSEMENT, batch.getId());
incrementAnomaly();
} catch (Exception e) {
TraceBackService.trace(new Exception(String.format(I18n.get(IExceptionMessage.BATCH_REIMBURSEMENT_7), reject[1]), e), ExceptionOriginRepository.REIMBURSEMENT, batch.getId());
incrementAnomaly();
log.error("Bug(Anomalie) généré(e) pour le rejet de remboursement {}", reject[1]);
} finally {
if (i % 10 == 0) {
JPA.clear();
}
}
}
this.validateMove(move, rejectDate, seq);
}
updateCustomerAccountLog += batchAccountCustomer.updateAccountingSituationMarked(company);
}
}
use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class InvoiceServiceImpl method getJournal.
public Journal getJournal(Invoice invoice) throws AxelorException {
Company company = invoice.getCompany();
if (company == null)
return null;
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
// Taken from legacy JournalService but negative cases seem rather strange
switch(invoice.getOperationTypeSelect()) {
case InvoiceRepository.OPERATION_TYPE_SUPPLIER_PURCHASE:
return invoice.getInTaxTotal().signum() < 0 ? accountConfigService.getSupplierCreditNoteJournal(accountConfig) : accountConfigService.getSupplierPurchaseJournal(accountConfig);
case InvoiceRepository.OPERATION_TYPE_SUPPLIER_REFUND:
return invoice.getInTaxTotal().signum() < 0 ? accountConfigService.getSupplierPurchaseJournal(accountConfig) : accountConfigService.getSupplierCreditNoteJournal(accountConfig);
case InvoiceRepository.OPERATION_TYPE_CLIENT_SALE:
return invoice.getInTaxTotal().signum() < 0 ? accountConfigService.getCustomerCreditNoteJournal(accountConfig) : accountConfigService.getCustomerSalesJournal(accountConfig);
case InvoiceRepository.OPERATION_TYPE_CLIENT_REFUND:
return invoice.getInTaxTotal().signum() < 0 ? accountConfigService.getCustomerSalesJournal(accountConfig) : accountConfigService.getCustomerCreditNoteJournal(accountConfig);
default:
throw new AxelorException(invoice, TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.JOURNAL_1), invoice.getInvoiceId());
}
}
use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class MoveAdjustementService method createAdjustmentCreditMove.
/**
* Creating move of passage in gap regulation (on credit)
*
* @param debitMoveLine
* @return
* @throws AxelorException
*/
public MoveLine createAdjustmentCreditMove(MoveLine debitMoveLine) throws AxelorException {
Partner partner = debitMoveLine.getPartner();
Account account = debitMoveLine.getAccount();
Move debitMove = debitMoveLine.getMove();
Company company = debitMove.getCompany();
BigDecimal debitAmountRemaining = debitMoveLine.getAmountRemaining();
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
Journal miscOperationJournal = accountConfigService.getAutoMiscOpeJournal(accountConfig);
Move adjustmentMove = moveCreateService.createMove(miscOperationJournal, company, null, partner, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, debitMove.getFunctionalOriginSelect());
// Création de la ligne au crédit
MoveLine creditAdjustmentMoveLine = moveLineService.createMoveLine(adjustmentMove, partner, account, debitAmountRemaining, false, appAccountService.getTodayDate(company), 1, null, null);
// Création de la ligne au débit
MoveLine debitAdjustmentMoveLine = moveLineService.createMoveLine(adjustmentMove, partner, accountConfigService.getCashPositionVariationAccount(accountConfig), debitAmountRemaining, true, appAccountService.getTodayDate(company), 2, null, null);
adjustmentMove.addMoveLineListItem(creditAdjustmentMoveLine);
adjustmentMove.addMoveLineListItem(debitAdjustmentMoveLine);
moveValidateService.validate(adjustmentMove);
moveRepository.save(adjustmentMove);
return creditAdjustmentMoveLine;
}
use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class MoveAdjustementService method createMoveToPassOnTheOtherAccount.
/**
* Méthode permettant de créer une écriture du passage du compte de l'écriture au debit vers le
* compte de l'écriture au credit.
*
* @param debitMoveLineToReconcile Ecriture au débit
* @param creditMoveLineToReconcile Ecriture au crédit
* @param amount Montant
* @return L'écriture de passage du compte de l'écriture au debit vers le compte de l'écriture au
* credit.
* @throws AxelorException
*/
public Move createMoveToPassOnTheOtherAccount(MoveLine debitMoveLineToReconcile, MoveLine creditMoveLineToReconcile, BigDecimal amount) throws AxelorException {
Partner partnerDebit = debitMoveLineToReconcile.getPartner();
Partner partnerCredit = creditMoveLineToReconcile.getPartner();
Company company = debitMoveLineToReconcile.getMove().getCompany();
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
Journal journal = accountConfigService.getAutoMiscOpeJournal(accountConfig);
// Move
Move move = moveCreateService.createMove(journal, company, null, partnerDebit, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, debitMoveLineToReconcile.getMove().getFunctionalOriginSelect());
MoveLine debitMoveLine = moveLineService.createMoveLine(move, partnerCredit, creditMoveLineToReconcile.getAccount(), amount, true, appAccountService.getTodayDate(company), 1, null, null);
MoveLine creditMoveLine = moveLineService.createMoveLine(move, partnerDebit, debitMoveLineToReconcile.getAccount(), amount, false, appAccountService.getTodayDate(company), 2, null, null);
move.addMoveLineListItem(debitMoveLine);
move.addMoveLineListItem(creditMoveLine);
moveValidateService.validate(move);
return move;
}
Aggregations