Search in sources :

Example 51 with Account

use of com.axelor.apps.account.db.Account in project axelor-open-suite by axelor.

the class AccountingSituationServiceImpl method getCustomerAccount.

@Override
public Account getCustomerAccount(Partner partner, Company company) throws AxelorException {
    Account account = null;
    AccountingSituation accountingSituation = getAccountingSituation(partner, company);
    if (accountingSituation != null) {
        account = accountingSituation.getCustomerAccount();
    }
    if (account == null) {
        AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
        account = accountConfigService.getCustomerAccount(accountConfig);
    }
    return account;
}
Also used : Account(com.axelor.apps.account.db.Account) AccountingSituation(com.axelor.apps.account.db.AccountingSituation) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 52 with Account

use of com.axelor.apps.account.db.Account in project axelor-open-suite by axelor.

the class AccountingSituationServiceImpl method getSupplierAccount.

@Override
public Account getSupplierAccount(Partner partner, Company company) throws AxelorException {
    Account account = null;
    AccountingSituation accountingSituation = getAccountingSituation(partner, company);
    if (accountingSituation != null) {
        account = accountingSituation.getSupplierAccount();
    }
    if (account == null) {
        AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
        account = accountConfigService.getSupplierAccount(accountConfig);
    }
    return account;
}
Also used : Account(com.axelor.apps.account.db.Account) AccountingSituation(com.axelor.apps.account.db.AccountingSituation) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 53 with Account

use of com.axelor.apps.account.db.Account 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;
}
Also used : Account(com.axelor.apps.account.db.Account) AccountingSituation(com.axelor.apps.account.db.AccountingSituation) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 54 with Account

use of com.axelor.apps.account.db.Account in project axelor-open-suite by axelor.

the class BankReconciliationService method compute.

@Transactional
public void compute(BankReconciliation bankReconciliation) {
    BigDecimal totalPaid = BigDecimal.ZERO;
    BigDecimal totalCashed = BigDecimal.ZERO;
    for (BankReconciliationLine bankReconciliationLine : bankReconciliation.getBankReconciliationLineList()) {
        totalPaid = totalPaid.add(bankReconciliationLine.getDebit());
        totalCashed = totalCashed.add(bankReconciliationLine.getCredit());
    }
    bankReconciliation.setTotalPaid(totalPaid);
    bankReconciliation.setTotalCashed(totalCashed);
    Account cashAccount = bankReconciliation.getCashAccount();
    if (cashAccount != null) {
        bankReconciliation.setAccountBalance(accountService.computeBalance(cashAccount, AccountService.BALANCE_TYPE_DEBIT_BALANCE));
    }
    bankReconciliation.setComputedBalance(bankReconciliation.getAccountBalance().add(totalCashed).subtract(totalPaid));
}
Also used : Account(com.axelor.apps.account.db.Account) BankReconciliationLine(com.axelor.apps.bankpayment.db.BankReconciliationLine) BigDecimal(java.math.BigDecimal) Transactional(com.google.inject.persist.Transactional)

Example 55 with Account

use of com.axelor.apps.account.db.Account in project axelor-open-suite by axelor.

the class InvoiceServiceImpl method ventilate.

/**
 * Ventilation comptable d'une facture. (Transaction)
 *
 * @param invoice Une facture.
 * @throws AxelorException
 */
@Override
@Transactional(rollbackOn = { Exception.class })
public void ventilate(Invoice invoice) throws AxelorException {
    if (invoice.getPaymentCondition() == null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.INVOICE_GENERATOR_3), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION));
    }
    if (invoice.getPaymentMode() == null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.INVOICE_GENERATOR_4), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION));
    }
    for (InvoiceLine invoiceLine : invoice.getInvoiceLineList()) {
        Account account = invoiceLine.getAccount();
        if (invoiceLine.getAccount() == null && (invoiceLine.getTypeSelect() == InvoiceLineRepository.TYPE_NORMAL)) {
            throw new AxelorException(invoice, TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.VENTILATE_STATE_6), invoiceLine.getProductName());
        }
        if (account != null && !account.getAnalyticDistributionAuthorized() && (invoiceLine.getAnalyticDistributionTemplate() != null || (invoiceLine.getAnalyticMoveLineList() != null && !invoiceLine.getAnalyticMoveLineList().isEmpty()))) {
            throw new AxelorException(invoice, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.VENTILATE_STATE_7));
        }
    }
    log.debug("Ventilation de la facture {}", invoice.getInvoiceId());
    ventilateFactory.getVentilator(invoice).process();
    invoiceRepo.save(invoice);
    if (this.checkEnablePDFGenerationOnVentilation(invoice)) {
        Beans.get(InvoicePrintService.class).printAndSave(invoice, InvoiceRepository.REPORT_TYPE_ORIGINAL_INVOICE, ReportSettings.FORMAT_PDF, null);
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) Account(com.axelor.apps.account.db.Account) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) InvoicePrintService(com.axelor.apps.account.service.invoice.print.InvoicePrintService) Transactional(com.google.inject.persist.Transactional)

Aggregations

Account (com.axelor.apps.account.db.Account)59 MoveLine (com.axelor.apps.account.db.MoveLine)27 Company (com.axelor.apps.base.db.Company)26 BigDecimal (java.math.BigDecimal)26 Partner (com.axelor.apps.base.db.Partner)25 Move (com.axelor.apps.account.db.Move)21 AxelorException (com.axelor.exception.AxelorException)20 Journal (com.axelor.apps.account.db.Journal)18 Transactional (com.google.inject.persist.Transactional)18 AccountConfig (com.axelor.apps.account.db.AccountConfig)14 LocalDate (java.time.LocalDate)12 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)10 ArrayList (java.util.ArrayList)10 TaxLine (com.axelor.apps.account.db.TaxLine)8 Invoice (com.axelor.apps.account.db.Invoice)7 Reconcile (com.axelor.apps.account.db.Reconcile)7 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)6 BankDetails (com.axelor.apps.base.db.BankDetails)6 PaymentMode (com.axelor.apps.account.db.PaymentMode)5 Product (com.axelor.apps.base.db.Product)5