Search in sources :

Example 56 with Account

use of com.axelor.apps.account.db.Account in project axelor-open-suite by axelor.

the class FixedAssetLineMoveServiceImpl method generateMove.

@Transactional(rollbackOn = { Exception.class })
private void generateMove(FixedAssetLine fixedAssetLine) throws AxelorException {
    FixedAsset fixedAsset = fixedAssetLine.getFixedAsset();
    Journal journal = fixedAsset.getJournal();
    Company company = fixedAsset.getCompany();
    Partner partner = fixedAsset.getPartner();
    LocalDate date = fixedAssetLine.getDepreciationDate();
    log.debug("Creating an fixed asset line specific accounting entry {} (Company : {}, Journal : {})", fixedAsset.getReference(), company.getName(), journal.getCode());
    // Creating move
    Move move = moveCreateService.createMove(journal, company, company.getCurrency(), partner, date, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_FIXED_ASSET);
    if (move != null) {
        List<MoveLine> moveLines = new ArrayList<>();
        String origin = fixedAsset.getReference();
        Account debitLineAccount = fixedAsset.getFixedAssetCategory().getChargeAccount();
        Account creditLineAccount = fixedAsset.getFixedAssetCategory().getDepreciationAccount();
        BigDecimal amount = fixedAssetLine.getDepreciation();
        // Creating accounting debit move line
        MoveLine debitMoveLine = new MoveLine(move, partner, debitLineAccount, date, null, 1, amount, BigDecimal.ZERO, fixedAsset.getName(), origin, null, BigDecimal.ZERO, date);
        moveLines.add(debitMoveLine);
        this.addAnalyticToMoveLine(fixedAsset.getAnalyticDistributionTemplate(), debitMoveLine);
        // Creating accounting debit move line
        MoveLine creditMoveLine = new MoveLine(move, partner, creditLineAccount, date, null, 2, BigDecimal.ZERO, amount, fixedAsset.getName(), origin, null, BigDecimal.ZERO, date);
        moveLines.add(creditMoveLine);
        this.addAnalyticToMoveLine(fixedAsset.getAnalyticDistributionTemplate(), creditMoveLine);
        move.getMoveLineList().addAll(moveLines);
    }
    moveRepo.save(move);
    fixedAssetLine.setDepreciationAccountMove(move);
}
Also used : Account(com.axelor.apps.account.db.Account) Company(com.axelor.apps.base.db.Company) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) ArrayList(java.util.ArrayList) Journal(com.axelor.apps.account.db.Journal) FixedAsset(com.axelor.apps.account.db.FixedAsset) Partner(com.axelor.apps.base.db.Partner) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal) Transactional(com.google.inject.persist.Transactional)

Example 57 with Account

use of com.axelor.apps.account.db.Account in project axelor-open-suite by axelor.

the class InvoiceLineServiceImpl method fillPriceAndAccount.

@Override
public Map<String, Object> fillPriceAndAccount(Invoice invoice, InvoiceLine invoiceLine, boolean isPurchase) throws AxelorException {
    Map<String, Object> productInformation = resetProductInformation(invoice);
    Product product = invoiceLine.getProduct();
    TaxLine taxLine = null;
    Company company = invoice.getCompany();
    FiscalPosition fiscalPosition = invoice.getPartner().getFiscalPosition();
    try {
        taxLine = this.getTaxLine(invoice, invoiceLine, isPurchase);
        invoiceLine.setTaxLine(taxLine);
        productInformation.put("taxLine", taxLine);
        productInformation.put("taxRate", taxLine.getValue());
        productInformation.put("taxCode", taxLine.getTax().getCode());
        TaxEquiv taxEquiv = accountManagementAccountService.getProductTaxEquiv(product, company, fiscalPosition, isPurchase);
        productInformation.put("taxEquiv", taxEquiv);
        Account account = accountManagementAccountService.getProductAccount(product, company, fiscalPosition, isPurchase, invoiceLine.getFixedAssets());
        productInformation.put("account", account);
    } catch (AxelorException e) {
        productInformation.put("error", e.getMessage());
    }
    BigDecimal price = this.getExTaxUnitPrice(invoice, invoiceLine, taxLine, isPurchase);
    BigDecimal inTaxPrice = this.getInTaxUnitPrice(invoice, invoiceLine, taxLine, isPurchase);
    productInformation.put("price", price);
    productInformation.put("inTaxPrice", inTaxPrice);
    productInformation.putAll(this.getDiscount(invoice, invoiceLine, product.getInAti() ? inTaxPrice : price));
    productInformation.put("productName", invoiceLine.getProduct().getName());
    return productInformation;
}
Also used : Account(com.axelor.apps.account.db.Account) AxelorException(com.axelor.exception.AxelorException) Company(com.axelor.apps.base.db.Company) FiscalPosition(com.axelor.apps.account.db.FiscalPosition) Product(com.axelor.apps.base.db.Product) TaxEquiv(com.axelor.apps.account.db.TaxEquiv) BigDecimal(java.math.BigDecimal) TaxLine(com.axelor.apps.account.db.TaxLine)

Example 58 with Account

use of com.axelor.apps.account.db.Account in project axelor-open-suite by axelor.

the class MoveAdjustementService method createAdjustmentCreditMove.

/**
 * Creating move of passage in gap regulation (on credit)
 *
 * @param debitMoveLine
 * @return
 * @throws AxelorException
 */
public MoveLine createAdjustmentCreditMove(MoveLine debitMoveLine) throws AxelorException {
    Partner partner = debitMoveLine.getPartner();
    Account account = debitMoveLine.getAccount();
    Move debitMove = debitMoveLine.getMove();
    Company company = debitMove.getCompany();
    BigDecimal debitAmountRemaining = debitMoveLine.getAmountRemaining();
    AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
    Journal miscOperationJournal = accountConfigService.getAutoMiscOpeJournal(accountConfig);
    Move adjustmentMove = moveCreateService.createMove(miscOperationJournal, company, null, partner, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, debitMove.getFunctionalOriginSelect());
    // Création de la ligne au crédit
    MoveLine creditAdjustmentMoveLine = moveLineService.createMoveLine(adjustmentMove, partner, account, debitAmountRemaining, false, appAccountService.getTodayDate(company), 1, null, null);
    // Création de la ligne au débit
    MoveLine debitAdjustmentMoveLine = moveLineService.createMoveLine(adjustmentMove, partner, accountConfigService.getCashPositionVariationAccount(accountConfig), debitAmountRemaining, true, appAccountService.getTodayDate(company), 2, null, null);
    adjustmentMove.addMoveLineListItem(creditAdjustmentMoveLine);
    adjustmentMove.addMoveLineListItem(debitAdjustmentMoveLine);
    moveValidateService.validate(adjustmentMove);
    moveRepository.save(adjustmentMove);
    return creditAdjustmentMoveLine;
}
Also used : Account(com.axelor.apps.account.db.Account) Company(com.axelor.apps.base.db.Company) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) Journal(com.axelor.apps.account.db.Journal) Partner(com.axelor.apps.base.db.Partner) BigDecimal(java.math.BigDecimal) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 59 with Account

use of com.axelor.apps.account.db.Account in project axelor-open-suite by axelor.

the class InvoiceLineGenerator method createInvoiceLine.

/**
 * @return
 * @throws AxelorException
 */
protected InvoiceLine createInvoiceLine() throws AxelorException {
    InvoiceLine invoiceLine = new InvoiceLine();
    boolean isPurchase = InvoiceToolService.isPurchase(invoice);
    Partner partner = invoice.getPartner();
    Company company = invoice.getCompany();
    invoiceLine.setInvoice(invoice);
    invoiceLine.setProduct(product);
    invoiceLine.setProductName(productName);
    if (product != null) {
        invoiceLine.setProductCode((String) productCompanyService.get(product, "code", company));
        Account account = accountManagementService.getProductAccount(product, company, partner.getFiscalPosition(), isPurchase, invoiceLine.getFixedAssets());
        invoiceLine.setAccount(account);
    }
    invoiceLine.setDescription(description);
    invoiceLine.setPrice(price);
    invoiceLine.setInTaxPrice(inTaxPrice);
    invoiceLine.setPriceDiscounted(priceDiscounted);
    invoiceLine.setQty(qty);
    invoiceLine.setUnit(unit);
    invoiceLine.setTypeSelect(typeSelect);
    if (taxLine == null) {
        this.determineTaxLine();
    }
    if (product != null) {
        TaxEquiv taxEquiv = Beans.get(AccountManagementService.class).getProductTaxEquiv(product, company, partner.getFiscalPosition(), isPurchase);
        invoiceLine.setTaxEquiv(taxEquiv);
    }
    invoiceLine.setTaxLine(taxLine);
    if (taxLine != null) {
        invoiceLine.setTaxRate(taxLine.getValue());
        invoiceLine.setTaxCode(taxLine.getTax().getCode());
    }
    if ((exTaxTotal == null || inTaxTotal == null)) {
        this.computeTotal();
    }
    invoiceLine.setExTaxTotal(exTaxTotal);
    invoiceLine.setInTaxTotal(inTaxTotal);
    this.computeCompanyTotal(invoiceLine);
    invoiceLine.setSequence(sequence);
    invoiceLine.setDiscountTypeSelect(discountTypeSelect);
    invoiceLine.setDiscountAmount(discountAmount);
    return invoiceLine;
}
Also used : Account(com.axelor.apps.account.db.Account) Company(com.axelor.apps.base.db.Company) AccountManagementService(com.axelor.apps.base.service.tax.AccountManagementService) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) Partner(com.axelor.apps.base.db.Partner) TaxEquiv(com.axelor.apps.account.db.TaxEquiv)

Aggregations

Account (com.axelor.apps.account.db.Account)59 MoveLine (com.axelor.apps.account.db.MoveLine)27 Company (com.axelor.apps.base.db.Company)26 BigDecimal (java.math.BigDecimal)26 Partner (com.axelor.apps.base.db.Partner)25 Move (com.axelor.apps.account.db.Move)21 AxelorException (com.axelor.exception.AxelorException)20 Journal (com.axelor.apps.account.db.Journal)18 Transactional (com.google.inject.persist.Transactional)18 AccountConfig (com.axelor.apps.account.db.AccountConfig)14 LocalDate (java.time.LocalDate)12 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)10 ArrayList (java.util.ArrayList)10 TaxLine (com.axelor.apps.account.db.TaxLine)8 Invoice (com.axelor.apps.account.db.Invoice)7 Reconcile (com.axelor.apps.account.db.Reconcile)7 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)6 BankDetails (com.axelor.apps.base.db.BankDetails)6 PaymentMode (com.axelor.apps.account.db.PaymentMode)5 Product (com.axelor.apps.base.db.Product)5