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);
}
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;
}
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;
}
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;
}
Aggregations