Search in sources :

Example 21 with AccountConfig

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;
}
Also used : Company(com.axelor.apps.base.db.Company) Move(com.axelor.apps.account.db.Move) BigDecimal(java.math.BigDecimal) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 22 with AccountConfig

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;
}
Also used : Company(com.axelor.apps.base.db.Company) AccountConfigService(com.axelor.apps.account.service.config.AccountConfigService) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 23 with AccountConfig

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;
}
Also used : InvoicingProject(com.axelor.apps.businessproject.db.InvoicingProject) Project(com.axelor.apps.project.db.Project) AxelorException(com.axelor.exception.AxelorException) Company(com.axelor.apps.base.db.Company) Invoice(com.axelor.apps.account.db.Invoice) InvoiceGenerator(com.axelor.apps.account.service.invoice.generator.InvoiceGenerator) AccountConfigService(com.axelor.apps.account.service.config.AccountConfigService) InvoiceRepository(com.axelor.apps.account.db.repo.InvoiceRepository) Partner(com.axelor.apps.base.db.Partner) AccountConfig(com.axelor.apps.account.db.AccountConfig) Transactional(com.google.inject.persist.Transactional)

Example 24 with AccountConfig

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());
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 25 with AccountConfig

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;
}
Also used : Reimbursement(com.axelor.apps.account.db.Reimbursement) BigDecimal(java.math.BigDecimal) AccountConfig(com.axelor.apps.account.db.AccountConfig) Transactional(com.google.inject.persist.Transactional)

Aggregations

AccountConfig (com.axelor.apps.account.db.AccountConfig)46 Company (com.axelor.apps.base.db.Company)27 Move (com.axelor.apps.account.db.Move)18 MoveLine (com.axelor.apps.account.db.MoveLine)17 BigDecimal (java.math.BigDecimal)17 Account (com.axelor.apps.account.db.Account)14 Partner (com.axelor.apps.base.db.Partner)14 Transactional (com.google.inject.persist.Transactional)14 Journal (com.axelor.apps.account.db.Journal)9 AccountConfigService (com.axelor.apps.account.service.config.AccountConfigService)9 AxelorException (com.axelor.exception.AxelorException)9 AccountingSituation (com.axelor.apps.account.db.AccountingSituation)7 Reconcile (com.axelor.apps.account.db.Reconcile)7 BankDetails (com.axelor.apps.base.db.BankDetails)6 LocalDate (java.time.LocalDate)6 ArrayList (java.util.ArrayList)6 Invoice (com.axelor.apps.account.db.Invoice)5 PaymentMode (com.axelor.apps.account.db.PaymentMode)5 List (java.util.List)4 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)3