use of com.axelor.apps.account.db.FixedAssetCategory in project axelor-open-suite by axelor.
the class FixedAssetTestTool method createFixedAssetCategoryFromIsProrataTemporis.
public static FixedAssetCategory createFixedAssetCategoryFromIsProrataTemporis(boolean isProrataTemporis, boolean usProrataTemporis) {
FixedAssetType fixedAssetType = new FixedAssetType();
FixedAssetCategory fixedAssetCategory = new FixedAssetCategory();
fixedAssetCategory.setFixedAssetType(fixedAssetType);
fixedAssetCategory.setIsProrataTemporis(isProrataTemporis);
fixedAssetCategory.setIsUSProrataTemporis(usProrataTemporis);
return fixedAssetCategory;
}
use of com.axelor.apps.account.db.FixedAssetCategory 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.FixedAssetCategory in project axelor-open-suite by axelor.
the class InvoiceLineGeneratorSupplyChain method createInvoiceLine.
/**
* @return
* @throws AxelorException
*/
@Override
protected InvoiceLine createInvoiceLine() throws AxelorException {
InvoiceLine invoiceLine = super.createInvoiceLine();
if (!Beans.get(AppSupplychainService.class).isApp("supplychain")) {
return invoiceLine;
}
InvoiceLineService invoiceLineService = Beans.get(InvoiceLineService.class);
this.assignOriginElements(invoiceLine);
List<AnalyticMoveLine> analyticMoveLineList = null;
if (saleOrderLine != null) {
switch(saleOrderLine.getTypeSelect()) {
case SaleOrderLineRepository.TYPE_END_OF_PACK:
invoiceLine.setIsHideUnitAmounts(saleOrderLine.getIsHideUnitAmounts());
invoiceLine.setIsShowTotal(saleOrderLine.getIsShowTotal());
break;
case SaleOrderLineRepository.TYPE_NORMAL:
if (saleOrderLine.getAnalyticDistributionTemplate() != null || !ObjectUtils.isEmpty(saleOrderLine.getAnalyticMoveLineList())) {
invoiceLine.setAnalyticDistributionTemplate(saleOrderLine.getAnalyticDistributionTemplate());
this.copyAnalyticMoveLines(saleOrderLine.getAnalyticMoveLineList(), invoiceLine);
analyticMoveLineList = invoiceLineService.computeAnalyticDistribution(invoiceLine);
} else {
analyticMoveLineList = invoiceLineService.getAndComputeAnalyticDistribution(invoiceLine, invoice);
analyticMoveLineList.stream().forEach(invoiceLine::addAnalyticMoveLineListItem);
}
break;
default:
return invoiceLine;
}
} else if (purchaseOrderLine != null) {
if (purchaseOrderLine.getAnalyticDistributionTemplate() != null || !ObjectUtils.isEmpty(purchaseOrderLine.getAnalyticMoveLineList())) {
invoiceLine.setAnalyticDistributionTemplate(purchaseOrderLine.getAnalyticDistributionTemplate());
this.copyAnalyticMoveLines(purchaseOrderLine.getAnalyticMoveLineList(), invoiceLine);
analyticMoveLineList = invoiceLineService.computeAnalyticDistribution(invoiceLine);
} else {
analyticMoveLineList = invoiceLineService.getAndComputeAnalyticDistribution(invoiceLine, invoice);
analyticMoveLineList.stream().forEach(invoiceLine::addAnalyticMoveLineListItem);
}
this.copyBudgetDistributionList(purchaseOrderLine.getBudgetDistributionList(), invoiceLine);
invoiceLine.setBudget(purchaseOrderLine.getBudget());
invoiceLine.setBudgetDistributionSumAmount(purchaseOrderLine.getBudgetDistributionSumAmount());
invoiceLine.setFixedAssets(purchaseOrderLine.getFixedAssets());
if (product != null) {
invoiceLine.setProductCode((String) productCompanyService.get(product, "code", invoice.getCompany()));
Account account = accountManagementService.getProductAccount(product, invoice.getCompany(), invoice.getPartner().getFiscalPosition(), InvoiceToolService.isPurchase(invoice), invoiceLine.getFixedAssets());
invoiceLine.setAccount(account);
}
if (product != null && purchaseOrderLine.getFixedAssets()) {
FixedAssetCategory fixedAssetCategory = accountManagementService.getProductFixedAssetCategory(product, invoice.getCompany());
invoiceLine.setFixedAssetCategory(fixedAssetCategory);
}
} else if (stockMoveLine != null) {
this.price = stockMoveLine.getUnitPriceUntaxed();
this.inTaxPrice = stockMoveLine.getUnitPriceTaxed();
this.price = unitConversionService.convert(stockMoveLine.getUnit(), this.unit, this.price, appBaseService.getNbDecimalDigitForUnitPrice(), product);
this.inTaxPrice = unitConversionService.convert(stockMoveLine.getUnit(), this.unit, this.inTaxPrice, appBaseService.getNbDecimalDigitForUnitPrice(), product);
invoiceLine.setPrice(price);
invoiceLine.setInTaxPrice(inTaxPrice);
analyticMoveLineList = invoiceLineService.getAndComputeAnalyticDistribution(invoiceLine, invoice);
analyticMoveLineList.stream().forEach(invoiceLine::addAnalyticMoveLineListItem);
}
return invoiceLine;
}
use of com.axelor.apps.account.db.FixedAssetCategory in project axelor-open-suite by axelor.
the class AccountManagementServiceAccountImpl method getProductFixedAssetCategory.
/**
* Get the product fixed asset category
*
* @param product
* @param company
* @param configObject Specify if we want get the fixed asset category from the product or its
* product family
* <li>1 : product
* <li>2 : product family
* @return
* @throws AxelorException
*/
protected FixedAssetCategory getProductFixedAssetCategory(Product product, Company company, int configObject) {
AccountManagement accountManagement = this.getAccountManagement(product, company, configObject);
FixedAssetCategory fixedAssetCategory = null;
if (accountManagement != null) {
fixedAssetCategory = accountManagement.getFixedAssetCategory();
}
if (fixedAssetCategory == null && configObject == CONFIG_OBJECT_PRODUCT) {
return getProductFixedAssetCategory(product, company, CONFIG_OBJECT_PRODUCT_FAMILY);
}
return fixedAssetCategory;
}
Aggregations