Search in sources :

Example 36 with InvoiceLine

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));
}
Also used : InvoiceLine(com.axelor.apps.account.db.InvoiceLine)

Example 37 with 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);
    }
}
Also used : Context(com.axelor.rpc.Context) Invoice(com.axelor.apps.account.db.Invoice) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) ArrayList(java.util.ArrayList)

Example 38 with InvoiceLine

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);
}
Also used : Context(com.axelor.rpc.Context) FixedAssetCategory(com.axelor.apps.account.db.FixedAssetCategory) InvoiceLineService(com.axelor.apps.account.service.invoice.InvoiceLineService) AppAccountService(com.axelor.apps.account.service.app.AppAccountService) HashMap(java.util.HashMap) AccountManagementServiceAccountImpl(com.axelor.apps.account.service.AccountManagementServiceAccountImpl) Mapper(com.axelor.db.mapper.Mapper) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) BigDecimal(java.math.BigDecimal) AccountTypeRepository(com.axelor.apps.account.db.repo.AccountTypeRepository) AxelorException(com.axelor.exception.AxelorException) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) TaxLine(com.axelor.apps.account.db.TaxLine) ActionResponse(com.axelor.rpc.ActionResponse) Map(java.util.Map) I18n(com.axelor.i18n.I18n) FixedAssetCategory(com.axelor.apps.account.db.FixedAssetCategory) ActionRequest(com.axelor.rpc.ActionRequest) AccountManagement(com.axelor.apps.account.db.AccountManagement) InvoiceLineManagement(com.axelor.apps.account.service.invoice.generator.line.InvoiceLineManagement) ITranslation(com.axelor.apps.account.translation.ITranslation) InvoiceLineRepository(com.axelor.apps.account.db.repo.InvoiceLineRepository) TraceBackService(com.axelor.exception.service.TraceBackService) Invoice(com.axelor.apps.account.db.Invoice) Collectors(java.util.stream.Collectors) Account(com.axelor.apps.account.db.Account) InvoiceToolService(com.axelor.apps.account.service.invoice.InvoiceToolService) List(java.util.List) InvoiceRepository(com.axelor.apps.account.db.repo.InvoiceRepository) Beans(com.axelor.inject.Beans) Product(com.axelor.apps.base.db.Product) Entry(java.util.Map.Entry) Optional(java.util.Optional) Context(com.axelor.rpc.Context) Singleton(com.google.inject.Singleton) Invoice(com.axelor.apps.account.db.Invoice) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) Product(com.axelor.apps.base.db.Product) AccountManagement(com.axelor.apps.account.db.AccountManagement)

Example 39 with InvoiceLine

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));
    }
}
Also used : Context(com.axelor.rpc.Context) InvoiceLine(com.axelor.apps.account.db.InvoiceLine)

Example 40 with 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);
    }
}
Also used : Account(com.axelor.apps.account.db.Account) AccountManagementServiceAccountImpl(com.axelor.apps.account.service.AccountManagementServiceAccountImpl) Invoice(com.axelor.apps.account.db.Invoice) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) Product(com.axelor.apps.base.db.Product) AxelorException(com.axelor.exception.AxelorException)

Aggregations

InvoiceLine (com.axelor.apps.account.db.InvoiceLine)80 ArrayList (java.util.ArrayList)36 Invoice (com.axelor.apps.account.db.Invoice)27 BigDecimal (java.math.BigDecimal)22 AxelorException (com.axelor.exception.AxelorException)20 Product (com.axelor.apps.base.db.Product)13 InvoiceLineGenerator (com.axelor.apps.account.service.invoice.generator.InvoiceLineGenerator)12 Transactional (com.google.inject.persist.Transactional)12 Context (com.axelor.rpc.Context)11 Account (com.axelor.apps.account.db.Account)8 InvoiceGenerator (com.axelor.apps.account.service.invoice.generator.InvoiceGenerator)8 TaxLine (com.axelor.apps.account.db.TaxLine)7 InvoiceLineService (com.axelor.apps.account.service.invoice.InvoiceLineService)7 RefundInvoice (com.axelor.apps.account.service.invoice.generator.invoice.RefundInvoice)6 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)6 InvoiceLineGeneratorSupplyChain (com.axelor.apps.supplychain.service.invoice.generator.InvoiceLineGeneratorSupplyChain)6 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)5 InvoiceRepository (com.axelor.apps.account.db.repo.InvoiceRepository)5 HashSet (java.util.HashSet)5 List (java.util.List)5