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