use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class InvoiceLineController method createAnalyticDistributionWithTemplate.
public void createAnalyticDistributionWithTemplate(ActionRequest request, ActionResponse response) throws AxelorException {
InvoiceLine invoiceLine = request.getContext().asType(InvoiceLine.class);
response.setValue("analyticMoveLineList", Beans.get(InvoiceLineService.class).createAnalyticDistributionWithTemplate(invoiceLine));
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class InvoiceLineController method filterAccount.
public void filterAccount(ActionRequest request, ActionResponse response) throws AxelorException {
Context context = request.getContext();
Invoice invoice = this.getInvoice(context);
InvoiceLine invoiceLine = request.getContext().asType(InvoiceLine.class);
if (invoice != null && invoice.getCompany() != null) {
List<String> technicalTypeSelectList = new ArrayList<>();
if (InvoiceToolService.isPurchase(invoice)) {
if (invoiceLine.getFixedAssets()) {
technicalTypeSelectList.add(AccountTypeRepository.TYPE_IMMOBILISATION);
} else {
technicalTypeSelectList.add(AccountTypeRepository.TYPE_DEBT);
technicalTypeSelectList.add(AccountTypeRepository.TYPE_CHARGE);
}
} else {
technicalTypeSelectList.add(AccountTypeRepository.TYPE_INCOME);
}
String domain = "self.company.id = " + invoice.getCompany().getId() + " AND self.accountType.technicalTypeSelect IN " + technicalTypeSelectList.stream().collect(Collectors.joining("','", "('", "')"));
response.setAttr("account", "domain", domain);
}
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class InvoiceLineController method getFixedAssetCategory.
public void getFixedAssetCategory(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
InvoiceLine invoiceLine = context.asType(InvoiceLine.class);
Invoice invoice = this.getInvoice(context);
Product product = invoiceLine.getProduct();
if (invoice == null || product == null) {
return;
}
FixedAssetCategory fixedAssetCategory = null;
if (!product.getAccountManagementList().isEmpty() && (invoice.getOperationTypeSelect() == InvoiceRepository.OPERATION_TYPE_SUPPLIER_PURCHASE || invoice.getOperationTypeSelect() == InvoiceRepository.OPERATION_TYPE_SUPPLIER_REFUND)) {
Optional<AccountManagement> optionalFixedAssetCategory = product.getAccountManagementList().stream().filter(am -> invoice.getCompany().equals(am.getCompany())).findFirst();
fixedAssetCategory = optionalFixedAssetCategory.isPresent() ? optionalFixedAssetCategory.get().getFixedAssetCategory() : null;
}
response.setValue("fixedAssetCategory", fixedAssetCategory);
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class InvoiceLineController method computeAnalyticDistribution.
public void computeAnalyticDistribution(ActionRequest request, ActionResponse response) throws AxelorException {
Context context = request.getContext();
InvoiceLine invoiceLine = context.asType(InvoiceLine.class);
if (Beans.get(AppAccountService.class).getAppAccount().getManageAnalyticAccounting()) {
response.setValue("analyticMoveLineList", Beans.get(InvoiceLineService.class).computeAnalyticDistribution(invoiceLine));
}
}
use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.
the class InvoiceLineController method getAccount.
public void getAccount(ActionRequest request, ActionResponse response) {
try {
InvoiceLine invoiceLine = request.getContext().asType(InvoiceLine.class);
if (invoiceLine != null) {
Product product = invoiceLine.getProduct();
Invoice invoice = this.getInvoice(request.getContext());
if (product != null) {
Account account = Beans.get(AccountManagementServiceAccountImpl.class).getProductAccount(product, invoice.getCompany(), invoice.getPartner().getFiscalPosition(), InvoiceToolService.isPurchase(invoice), invoiceLine.getFixedAssets());
response.setValue("account", account);
}
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations