use of com.axelor.apps.account.service.app.AppAccountService in project axelor-open-suite by axelor.
the class PurchaseOrderController method generateBudgetDistribution.
public void generateBudgetDistribution(ActionRequest request, ActionResponse response) {
PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
AppAccountService appAccountService = Beans.get(AppAccountService.class);
if (appAccountService.isApp("budget") && !appAccountService.getAppBudget().getManageMultiBudget()) {
purchaseOrder = Beans.get(PurchaseOrderRepository.class).find(purchaseOrder.getId());
Beans.get(PurchaseOrderSupplychainService.class).generateBudgetDistribution(purchaseOrder);
response.setValues(purchaseOrder);
}
}
use of com.axelor.apps.account.service.app.AppAccountService in project axelor-open-suite by axelor.
the class PaymentVoucherConfirmService method confirmPaymentVoucher.
/**
* Confirms the payment voucher if the selected lines PiToPay 2nd O2M belongs to different
* companies -> error I - Payment with an amount If we pay a classical moveLine (invoice, reject
* ..) -> just create a payment If we pay a schedule 2 payments are created 1st reconciled with
* the invoice and the second reconciled with the schedule II - Payment with an excess Payment If
* we pay a moveLine having the same account, we just reconcile If we pay a with different account
* -> 1- switch money to the good account 2- reconcile then
*
* @param paymentVoucher
*/
@Transactional(rollbackOn = { Exception.class })
public void confirmPaymentVoucher(PaymentVoucher paymentVoucher) throws AxelorException {
log.debug("In confirmPaymentVoucherService ....");
paymentVoucherSequenceService.setReference(paymentVoucher);
PaymentMode paymentMode = paymentVoucher.getPaymentMode();
Company company = paymentVoucher.getCompany();
BankDetails companyBankDetails = paymentVoucher.getCompanyBankDetails();
Journal journal = paymentModeService.getPaymentModeJournal(paymentMode, company, companyBankDetails);
Account paymentModeAccount = paymentModeService.getPaymentModeAccount(paymentMode, company, companyBankDetails);
paymentVoucherControlService.checkPaymentVoucherField(paymentVoucher, company, paymentModeAccount, journal);
if (paymentVoucher.getRemainingAmount().compareTo(BigDecimal.ZERO) > 0 && !journal.getExcessPaymentOk()) {
throw new AxelorException(paymentVoucher, TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.PAYMENT_AMOUNT_EXCEEDING), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION));
}
// TODO VEIRIFER QUE LES ELEMENTS A PAYER NE CONCERNE QU'UNE SEULE DEVISE
// TODO RECUPERER DEVISE DE LA PREMIERE DETTE
// Currency currencyToPay = null;
AppAccountService appAccountService = Beans.get(AppAccountService.class);
if (appAccountService.getAppAccount().getPaymentVouchersOnInvoice() && paymentVoucher.getPaymentMode().getValidatePaymentByDepositSlipPublication()) {
waitForDepositSlip(paymentVoucher);
} else {
createMoveAndConfirm(paymentVoucher);
}
paymentVoucherSequenceService.setReceiptNo(paymentVoucher, company, journal);
paymentVoucherRepository.save(paymentVoucher);
}
use of com.axelor.apps.account.service.app.AppAccountService in project axelor-open-suite by axelor.
the class ContractLineServiceImpl method createAnalyticDistributionWithTemplate.
@Override
public ContractLine createAnalyticDistributionWithTemplate(ContractLine contractLine, Contract contract) {
AppAccountService appAccountService = Beans.get(AppAccountService.class);
List<AnalyticMoveLine> analyticMoveLineList = Beans.get(AnalyticMoveLineService.class).generateLines(contractLine.getAnalyticDistributionTemplate(), contractLine.getExTaxTotal(), AnalyticMoveLineRepository.STATUS_FORECAST_CONTRACT, appAccountService.getTodayDate(contract.getCompany()));
contractLine.setAnalyticMoveLineList(analyticMoveLineList);
return contractLine;
}
use of com.axelor.apps.account.service.app.AppAccountService in project axelor-open-suite by axelor.
the class BankDetailsServiceAccountImpl method createCompanyBankDetailsDomain.
/**
* In this implementation, we use the O2M in payment mode.
*
* @param company
* @param paymentMode
* @return
* @throws AxelorException
*/
@Override
public String createCompanyBankDetailsDomain(Partner partner, Company company, PaymentMode paymentMode, Integer operationTypeSelect) throws AxelorException {
AppAccountService appAccountService = Beans.get(AppAccountService.class);
if (!appAccountService.isApp("account") || !appAccountService.getAppBase().getManageMultiBanks()) {
return super.createCompanyBankDetailsDomain(partner, company, paymentMode, operationTypeSelect);
} else {
if (partner != null) {
partner = Beans.get(PartnerRepository.class).find(partner.getId());
}
List<BankDetails> authorizedBankDetails = new ArrayList<>();
if (partner != null && partner.getFactorizedCustomer() && operationTypeSelect != null && (operationTypeSelect.intValue() == InvoiceRepository.OPERATION_TYPE_CLIENT_SALE || operationTypeSelect.intValue() == InvoiceRepository.OPERATION_TYPE_CLIENT_REFUND)) {
authorizedBankDetails = createCompanyBankDetailsDomainFromFactorPartner(company);
} else {
if (paymentMode == null) {
return "self.id IN (0)";
}
List<AccountManagement> accountManagementList = paymentMode.getAccountManagementList();
authorizedBankDetails = new ArrayList<>();
for (AccountManagement accountManagement : accountManagementList) {
if (accountManagement.getCompany() != null && accountManagement.getCompany().equals(company)) {
authorizedBankDetails.add(accountManagement.getBankDetails());
}
}
}
if (authorizedBankDetails.isEmpty()) {
return "self.id IN (0)";
} else {
return "self.id IN (" + StringTool.getIdListString(authorizedBankDetails) + ") AND self.active = true";
}
}
}
use of com.axelor.apps.account.service.app.AppAccountService in project axelor-open-suite by axelor.
the class BankDetailsServiceAccountImpl method getDefaultCompanyBankDetails.
/**
* Find a default bank details.
*
* @param company
* @param paymentMode
* @param partner
* @return the default bank details in accounting situation if it is active and allowed by the
* payment mode, or an authorized bank details if he is the only one authorized.
* @throws AxelorException
*/
@Override
public BankDetails getDefaultCompanyBankDetails(Company company, PaymentMode paymentMode, Partner partner, Integer operationTypeSelect) throws AxelorException {
AppAccountService appAccountService = Beans.get(AppAccountService.class);
if (!appAccountService.isApp("account") || !appAccountService.getAppBase().getManageMultiBanks()) {
return super.getDefaultCompanyBankDetails(company, paymentMode, partner, operationTypeSelect);
} else {
if (partner != null && partner.getFactorizedCustomer() && operationTypeSelect != null && (operationTypeSelect.intValue() == InvoiceRepository.OPERATION_TYPE_CLIENT_SALE || operationTypeSelect.intValue() == InvoiceRepository.OPERATION_TYPE_CLIENT_REFUND)) {
return getDefaultCompanyBankDetailsFromFactorPartner(company);
} else {
if (paymentMode == null) {
return null;
}
BankDetails candidateBankDetails = getDefaultCompanyBankDetailsFromPartner(company, paymentMode, partner);
List<BankDetails> authorizedBankDetails = Beans.get(PaymentModeService.class).getCompatibleBankDetailsList(paymentMode, company);
if (candidateBankDetails != null && authorizedBankDetails.contains(candidateBankDetails) && candidateBankDetails.getActive()) {
return candidateBankDetails;
} else // we did not find a bank details in accounting situation
{
if (authorizedBankDetails.size() == 1) {
return authorizedBankDetails.get(0);
}
}
}
return null;
}
}
Aggregations