use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.
the class MoveBankPaymentRepository method copy.
@Override
public Move copy(Move entity, boolean deep) {
Move copy = super.copy(entity, deep);
List<MoveLine> moveLineList = copy.getMoveLineList();
if (moveLineList != null) {
moveLineList.forEach(moveLine -> moveLine.setBankReconciledAmount(BigDecimal.ZERO));
}
return copy;
}
use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.
the class InvoiceServiceSupplychainImpl method getMoveLinesFromSOAdvancePayments.
@Override
public List<MoveLine> getMoveLinesFromSOAdvancePayments(Invoice invoice) {
if (!Beans.get(AppSupplychainService.class).isApp("supplychain")) {
return super.getMoveLinesFromSOAdvancePayments(invoice);
}
// search sale order in the invoice
SaleOrder saleOrder = invoice.getSaleOrder();
// search sale order in invoice lines
List<SaleOrder> saleOrderList = invoice.getInvoiceLineList().stream().map(invoiceLine -> invoice.getSaleOrder()).collect(Collectors.toList());
saleOrderList.add(saleOrder);
// remove null value and duplicates
saleOrderList = saleOrderList.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
if (saleOrderList.isEmpty()) {
return new ArrayList<>();
} else {
// get move lines from sale order
return saleOrderList.stream().flatMap(saleOrder1 -> saleOrder1.getAdvancePaymentList().stream()).filter(Objects::nonNull).distinct().map(AdvancePayment::getMove).filter(Objects::nonNull).distinct().flatMap(move -> moveToolService.getToReconcileCreditMoveLines(move).stream()).collect(Collectors.toList());
}
}
use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.
the class AccountClearanceService method createAccountClearanceMove.
public Move createAccountClearanceMove(MoveLine moveLine, BigDecimal taxRate, Account taxAccount, Account profitAccount, Company company, Journal journal, AccountClearance accountClearance) throws AxelorException {
Partner partner = moveLine.getPartner();
// Move
Move move = moveService.getMoveCreateService().createMove(journal, company, null, partner, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, moveLine.getMove().getFunctionalOriginSelect());
// Debit MoveLine 411
BigDecimal amount = moveLine.getAmountRemaining();
MoveLine debitMoveLine = moveLineService.createMoveLine(move, partner, moveLine.getAccount(), amount, true, appBaseService.getTodayDateTime().toLocalDate(), 1, null, null);
move.getMoveLineList().add(debitMoveLine);
// Credit MoveLine 77. (profit account)
BigDecimal divid = taxRate.add(BigDecimal.ONE);
BigDecimal profitAmount = amount.divide(divid, AppBaseService.DEFAULT_NB_DECIMAL_DIGITS, RoundingMode.HALF_UP).setScale(AppBaseService.DEFAULT_NB_DECIMAL_DIGITS, RoundingMode.HALF_UP);
MoveLine creditMoveLine1 = moveLineService.createMoveLine(move, partner, profitAccount, profitAmount, false, appBaseService.getTodayDateTime().toLocalDate(), 2, null, null);
move.getMoveLineList().add(creditMoveLine1);
// Credit MoveLine 445 (Tax account)
BigDecimal taxAmount = amount.subtract(profitAmount);
MoveLine creditMoveLine2 = moveLineService.createMoveLine(move, partner, taxAccount, taxAmount, false, appBaseService.getTodayDateTime().toLocalDate(), 3, null, null);
move.getMoveLineList().add(creditMoveLine2);
Reconcile reconcile = reconcileService.createReconcile(debitMoveLine, moveLine, amount, false);
if (reconcile != null) {
reconcileService.confirmReconcile(reconcile, true);
}
debitMoveLine.setAccountClearance(accountClearance);
creditMoveLine1.setAccountClearance(accountClearance);
creditMoveLine2.setAccountClearance(accountClearance);
return move;
}
use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.
the class AccountingCloseAnnualServiceImpl method generateCloseAnnualMoveLine.
protected MoveLine generateCloseAnnualMoveLine(Move move, String origin, Account account, String moveDescription, LocalDate originDate, BigDecimal balance) throws AxelorException {
LocalDate moveDate = move.getDate();
MoveLine moveLine = moveLineService.createMoveLine(move, move.getPartner(), account, balance.abs(), balance.abs(), null, balance.compareTo(BigDecimal.ZERO) == 1, moveDate, moveDate, originDate, ++counter, origin, moveDescription);
move.addMoveLineListItem(moveLine);
return moveLine;
}
use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.
the class MoveManagementRepository method copy.
@Override
public Move copy(Move entity, boolean deep) {
Move copy = super.copy(entity, deep);
copy.setDate(Beans.get(AppBaseService.class).getTodayDate(copy.getCompany()));
Period period = null;
try {
period = Beans.get(PeriodService.class).getActivePeriod(copy.getDate(), entity.getCompany(), YearRepository.TYPE_FISCAL);
} catch (AxelorException e) {
throw new PersistenceException(e.getMessage(), e);
}
copy.setStatusSelect(STATUS_NEW);
copy.setTechnicalOriginSelect(MoveRepository.TECHNICAL_ORIGIN_ENTRY);
copy.setReference(null);
copy.setExportNumber(null);
copy.setExportDate(null);
copy.setAccountingReport(null);
copy.setValidationDate(null);
copy.setPeriod(period);
copy.setAccountingOk(false);
copy.setIgnoreInDebtRecoveryOk(false);
copy.setPaymentVoucher(null);
copy.setRejectOk(false);
copy.setInvoice(null);
List<MoveLine> moveLineList = copy.getMoveLineList();
if (moveLineList != null) {
moveLineList.forEach(moveLine -> resetMoveLine(moveLine, copy.getDate()));
}
return copy;
}
Aggregations