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);
}
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;
}
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());
}
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());
}
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;
}
Aggregations