use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class AccountingCloseAnnualServiceImpl method generateCloseAnnualAccountMove.
protected Move generateCloseAnnualAccountMove(Year year, Account account, LocalDate moveDate, LocalDate originDate, String origin, String moveDescription, Partner partner, boolean isReverse, boolean allocatePerPartner) throws AxelorException {
Company company = account.getCompany();
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
BigDecimal balance = computeBalance(year, account, partner, allocatePerPartner);
if (balance.compareTo(BigDecimal.ZERO) == 0) {
return null;
}
Integer functionalOriginSelect = null;
if (isReverse) {
balance = balance.negate();
functionalOriginSelect = MoveRepository.FUNCTIONAL_ORIGIN_OPENING;
} else {
functionalOriginSelect = MoveRepository.FUNCTIONAL_ORIGIN_CLOSURE;
}
Move move = moveCreateService.createMove(accountConfigService.getReportedBalanceJournal(accountConfig), company, company.getCurrency(), partner, moveDate, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, functionalOriginSelect, false, false, !isReverse);
counter = 0;
this.generateCloseAnnualMoveLine(move, origin, account, moveDescription, originDate, balance.negate());
this.generateCloseAnnualMoveLine(move, origin, getYearClosureOrOpeningAccount(accountConfig, isReverse), moveDescription, originDate, balance);
if (move.getMoveLineList() != null && !move.getMoveLineList().isEmpty()) {
moveValidateService.validate(move);
} else {
moveRepository.remove(move);
return null;
}
return move;
}
use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class AccountingReportServiceImpl method getJournalType.
public JournalType getJournalType(AccountingReport accountingReport) throws AxelorException {
if (accountingReport.getReportType() == null) {
return null;
}
Company company = accountingReport.getCompany();
AccountConfigService accountConfigService = Beans.get(AccountConfigService.class);
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
switch(accountingReport.getReportType().getTypeSelect()) {
case AccountingReportRepository.EXPORT_SALES:
return accountConfigService.getSaleJournalType(accountConfig);
case AccountingReportRepository.EXPORT_REFUNDS:
return accountConfigService.getCreditNoteJournalType(accountConfig);
case AccountingReportRepository.EXPORT_TREASURY:
return accountConfigService.getCashJournalType(accountConfig);
case AccountingReportRepository.EXPORT_PURCHASES:
return accountConfigService.getPurchaseJournalType(accountConfig);
default:
break;
}
return null;
}
use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class InvoicingProjectService method generateInvoice.
@Transactional(rollbackOn = { Exception.class })
public Invoice generateInvoice(InvoicingProject invoicingProject) throws AxelorException {
Project project = invoicingProject.getProject();
Partner customer = project.getClientPartner();
Partner customerContact = project.getContactPartner();
if (invoicingProject.getSaleOrderLineSet().isEmpty() && invoicingProject.getPurchaseOrderLineSet().isEmpty() && invoicingProject.getLogTimesSet().isEmpty() && invoicingProject.getExpenseLineSet().isEmpty() && invoicingProject.getProjectSet().isEmpty() && invoicingProject.getProjectTaskSet().isEmpty()) {
throw new AxelorException(invoicingProject, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.INVOICING_PROJECT_EMPTY));
}
if (invoicingProject.getProject() == null) {
throw new AxelorException(invoicingProject, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.INVOICING_PROJECT_PROJECT));
}
if (invoicingProject.getProject().getClientPartner() == null) {
throw new AxelorException(invoicingProject, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.INVOICING_PROJECT_PROJECT_PARTNER));
}
if (customerContact == null && customer.getContactPartnerSet().size() == 1) {
customerContact = customer.getContactPartnerSet().iterator().next();
}
Company company = this.getRootCompany(project);
if (company == null) {
throw new AxelorException(invoicingProject, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.INVOICING_PROJECT_PROJECT_COMPANY));
}
InvoiceGenerator invoiceGenerator = new InvoiceGenerator(InvoiceRepository.OPERATION_TYPE_CLIENT_SALE, company, customer.getPaymentCondition(), customer.getInPaymentMode(), partnerService.getInvoicingAddress(customer), customer, customerContact, customer.getCurrency(), Beans.get(PartnerPriceListService.class).getDefaultPriceList(customer, PriceListRepository.TYPE_SALE), null, null, null, null, null, null) {
@Override
public Invoice generate() throws AxelorException {
Invoice invoice = super.createInvoiceHeader();
invoice.setProject(project);
invoice.setPriceList(project.getPriceList());
return invoice;
}
};
Invoice invoice = invoiceGenerator.generate();
AccountConfigService accountConfigService = Beans.get(AccountConfigService.class);
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
invoice.setDisplayTimesheetOnPrinting(accountConfig.getDisplayTimesheetOnPrinting());
invoice.setDisplayExpenseOnPrinting(accountConfig.getDisplayExpenseOnPrinting());
invoiceGenerator.populate(invoice, this.populate(invoice, invoicingProject));
Beans.get(InvoiceRepository.class).save(invoice);
invoicingProject.setInvoice(invoice);
invoicingProject.setStatusSelect(InvoicingProjectRepository.STATUS_GENERATED);
invoicingProjectRepo.save(invoicingProject);
return invoice;
}
use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class ReimbursementExportService method testCompanyField.
/**
* Procédure permettant de tester la présence des champs et des séquences nécessaire aux
* remboursements.
*
* @param company Une société
* @throws AxelorException
*/
public void testCompanyField(Company company) throws AxelorException {
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
accountConfigService.getReimbursementAccount(accountConfig);
accountConfigService.getReimbursementJournal(accountConfig);
accountConfigService.getReimbursementExportFolderPath(accountConfig);
if (!sequenceService.hasSequence(SequenceRepository.REIMBOURSEMENT, company)) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.REIMBURSEMENT_1), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION), company.getName());
}
}
use of com.axelor.apps.account.db.AccountConfig in project axelor-open-suite by axelor.
the class ReimbursementExportService method runCreateReimbursement.
@Transactional(rollbackOn = { Exception.class })
public Reimbursement runCreateReimbursement(List<MoveLine> moveLineList, Company company, Partner partner) throws AxelorException {
log.debug("In runReimbursementProcess");
BigDecimal total = this.getTotalAmountRemaining(moveLineList);
AccountConfig accountConfig = company.getAccountConfig();
// Seuil bas respecté et remboursement manuel autorisé
if (total.compareTo(accountConfig.getLowerThresholdReimbursement()) > 0) {
Reimbursement reimbursement = createReimbursement(partner, company);
fillMoveLineSet(reimbursement, moveLineList, total);
if (total.compareTo(accountConfig.getUpperThresholdReimbursement()) > 0 || reimbursement.getBankDetails() == null) {
// Seuil haut dépassé
reimbursement.setStatusSelect(ReimbursementRepository.STATUS_TO_VALIDATE);
} else {
reimbursement.setStatusSelect(ReimbursementRepository.STATUS_VALIDATED);
}
reimbursement = reimbursementRepo.save(reimbursement);
return reimbursement;
}
log.debug("End runReimbursementProcess");
return null;
}
Aggregations