Search in sources :

Example 1 with Tax

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

the class AccountClearanceService method validateAccountClearance.

@Transactional(rollbackOn = { Exception.class })
public void validateAccountClearance(AccountClearance accountClearance) throws AxelorException {
    Company company = accountClearance.getCompany();
    AccountConfig accountConfig = company.getAccountConfig();
    Tax tax = accountConfig.getStandardRateTax();
    BigDecimal taxRate = taxService.getTaxRate(tax, appBaseService.getTodayDateTime().toLocalDate());
    Account taxAccount = taxAccountService.getAccount(tax, company, false, false);
    Account profitAccount = accountConfig.getProfitAccount();
    Journal journal = accountConfig.getAccountClearanceJournal();
    Set<MoveLine> moveLineList = accountClearance.getMoveLineSet();
    for (MoveLine moveLine : moveLineList) {
        Move move = this.createAccountClearanceMove(moveLine, taxRate, taxAccount, profitAccount, company, journal, accountClearance);
        moveService.getMoveValidateService().validate(move);
    }
    accountClearance.setStatusSelect(AccountClearanceRepository.STATUS_VALIDATED);
    accountClearance.setDateTime(appBaseService.getTodayDateTime());
    accountClearance.setName(sequenceService.getSequenceNumber(SequenceRepository.ACCOUNT_CLEARANCE, company));
    accountClearanceRepo.save(accountClearance);
}
Also used : Account(com.axelor.apps.account.db.Account) Company(com.axelor.apps.base.db.Company) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) Tax(com.axelor.apps.account.db.Tax) Journal(com.axelor.apps.account.db.Journal) BigDecimal(java.math.BigDecimal) AccountConfig(com.axelor.apps.account.db.AccountConfig) Transactional(com.google.inject.persist.Transactional)

Example 2 with Tax

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

the class IrrecoverableService method createIrrecoverablePaymentScheduleLineLine.

/**
 * Fonction permettant de créer une ligne Echéance rejetée
 *
 * @param icl Une ligne Client
 * @param invoice Une échéance rejetée
 * @param seq Un numéro de séquence
 * @return
 * @throws AxelorException
 */
public IrrecoverablePaymentScheduleLineLine createIrrecoverablePaymentScheduleLineLine(IrrecoverableCustomerLine icl, PaymentScheduleLine paymentScheduleLine, int seq) throws AxelorException {
    IrrecoverablePaymentScheduleLineLine ipsll = new IrrecoverablePaymentScheduleLineLine();
    ipsll.setPaymentScheduleLine(paymentScheduleLine);
    ipsll.setIrrecoverableCustomerLine(icl);
    Company company = paymentScheduleLine.getPaymentSchedule().getCompany();
    Tax tax = accountConfigService.getIrrecoverableStandardRateTax(accountConfigService.getAccountConfig(company));
    ipsll.setIrrecoverableReportLineList(this.createIrrecoverableReportLineList(ipsll, paymentScheduleLine, tax));
    log.debug("Ligne échéance rejetée : {}", ipsll);
    return ipsll;
}
Also used : Company(com.axelor.apps.base.db.Company) IrrecoverablePaymentScheduleLineLine(com.axelor.apps.account.db.IrrecoverablePaymentScheduleLineLine) InvoiceLineTax(com.axelor.apps.account.db.InvoiceLineTax) Tax(com.axelor.apps.account.db.Tax)

Example 3 with Tax

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

the class AccountManagementServiceImpl method getProductTax.

/**
 * Get the product tax according to the fiscal position
 *
 * @param product
 * @param company
 * @param fiscalPosition
 * @param isPurchase specify if we want get the tax for purchase or sale
 * @return the tax defined for the product, according to the fiscal position
 * @throws AxelorException
 */
protected Tax getProductTax(Product product, Company company, FiscalPosition fiscalPosition, boolean isPurchase) throws AxelorException {
    Tax generalTax = this.getProductTax(product, company, isPurchase);
    Tax tax = fiscalPositionService.getTax(fiscalPosition, generalTax);
    if (tax != null) {
        return tax;
    }
    throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.ACCOUNT_MANAGEMENT_3), product.getCode(), company.getName());
}
Also used : AxelorException(com.axelor.exception.AxelorException) Tax(com.axelor.apps.account.db.Tax)

Example 4 with Tax

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

the class AccountManagementServiceImpl method getProductTax.

/**
 * Get product tax before using tax equiv from fiscal position.
 *
 * @param product
 * @param company
 * @param isPurchase specify if we want get the tax for purchase or sale
 * @return the tax defined for the product
 * @throws AxelorException
 */
protected Tax getProductTax(Product product, Company company, boolean isPurchase) throws AxelorException {
    LOG.debug("Get the tax for the product {} (company : {}, purchase : {}", product.getCode(), company.getName(), isPurchase);
    Tax tax = this.getProductTax(product, company, isPurchase, CONFIG_OBJECT_PRODUCT);
    if (tax != null) {
        return tax;
    }
    throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.ACCOUNT_MANAGEMENT_3), product.getCode(), company.getName());
}
Also used : AxelorException(com.axelor.exception.AxelorException) Tax(com.axelor.apps.account.db.Tax)

Example 5 with Tax

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

the class AccountManagementServiceImpl method getProductTax.

/**
 * Get the product tax
 *
 * @param product
 * @param company
 * @param isPurchase
 * @param configObject Specify if we want get the tax from the product or its product family
 *     <li>1 : product
 *     <li>2 : product family
 * @return
 * @throws AxelorException
 */
protected Tax getProductTax(Product product, Company company, boolean isPurchase, int configObject) {
    AccountManagement accountManagement = this.getAccountManagement(product, company, configObject);
    Tax tax = null;
    if (accountManagement != null) {
        if (isPurchase) {
            tax = accountManagement.getPurchaseTax();
        } else {
            tax = accountManagement.getSaleTax();
        }
    }
    if (tax == null && configObject == CONFIG_OBJECT_PRODUCT) {
        return getProductTax(product, company, isPurchase, CONFIG_OBJECT_PRODUCT_FAMILY);
    }
    return tax;
}
Also used : Tax(com.axelor.apps.account.db.Tax) AccountManagement(com.axelor.apps.account.db.AccountManagement)

Aggregations

Tax (com.axelor.apps.account.db.Tax)11 MoveLine (com.axelor.apps.account.db.MoveLine)6 BigDecimal (java.math.BigDecimal)6 Account (com.axelor.apps.account.db.Account)4 Move (com.axelor.apps.account.db.Move)4 TaxLine (com.axelor.apps.account.db.TaxLine)4 InvoiceLineTax (com.axelor.apps.account.db.InvoiceLineTax)3 Company (com.axelor.apps.base.db.Company)3 AxelorException (com.axelor.exception.AxelorException)3 Transactional (com.google.inject.persist.Transactional)3 ArrayList (java.util.ArrayList)3 AccountConfig (com.axelor.apps.account.db.AccountConfig)2 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)2 MoveTemplateLine (com.axelor.apps.account.db.MoveTemplateLine)2 Partner (com.axelor.apps.base.db.Partner)2 AccountManagement (com.axelor.apps.account.db.AccountManagement)1 AnalyticAccount (com.axelor.apps.account.db.AnalyticAccount)1 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)1 IrrecoverablePaymentScheduleLineLine (com.axelor.apps.account.db.IrrecoverablePaymentScheduleLineLine)1 Journal (com.axelor.apps.account.db.Journal)1