use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class MoveCreateService method createMove.
/**
* Creating a new generic accounting move
*
* @param journal
* @param company
* @param currency
* @param partner
* @param date
* @param paymentMode
* @param technicalOriginSelect
* @param ignoreInDebtRecoveryOk
* @param ignoreInAccountingOk
* @return
* @throws AxelorException
*/
public Move createMove(Journal journal, Company company, Currency currency, Partner partner, LocalDate date, PaymentMode paymentMode, int technicalOriginSelect, int functionalOriginSelect, boolean ignoreInDebtRecoveryOk, boolean ignoreInAccountingOk, boolean autoYearClosureMove) throws AxelorException {
log.debug("Creating a new generic accounting move (journal : {}, company : {}", new Object[] { journal.getName(), company.getName() });
Move move = new Move();
move.setJournal(journal);
move.setCompany(company);
move.setIgnoreInDebtRecoveryOk(ignoreInDebtRecoveryOk);
move.setIgnoreInAccountingOk(ignoreInAccountingOk);
move.setAutoYearClosureMove(autoYearClosureMove);
if (autoYearClosureMove) {
move.setPeriod(periodService.getPeriod(date, company, YearRepository.TYPE_FISCAL));
if (move.getPeriod() == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.PERIOD_1), company.getName(), date.toString());
}
} else {
move.setPeriod(periodService.getActivePeriod(date, company, YearRepository.TYPE_FISCAL));
}
move.setDate(date);
move.setMoveLineList(new ArrayList<MoveLine>());
Currency companyCurrency = companyConfigService.getCompanyCurrency(company);
if (companyCurrency != null) {
move.setCompanyCurrency(companyCurrency);
move.setCompanyCurrencyCode(companyCurrency.getCode());
}
if (currency == null) {
currency = move.getCompanyCurrency();
}
if (currency != null) {
move.setCurrency(currency);
move.setCurrencyCode(currency.getCode());
}
move.setPartner(partner);
move.setPaymentMode(paymentMode);
move.setTechnicalOriginSelect(technicalOriginSelect);
move.setFunctionalOriginSelect(functionalOriginSelect);
moveRepository.save(move);
move.setReference(Beans.get(SequenceService.class).getDraftSequenceNumber(move));
return move;
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class MoveCreateService method createMoveWithPaymentVoucher.
/**
* Créer une écriture comptable de toute pièce spécifique à une saisie paiement.
*
* @param journal
* @param period
* @param company
* @param invoice
* @param partner
* @param isReject <code>true = écriture de rejet avec séquence spécifique</code>
* @param agency L'agence dans laquelle s'effectue le paiement
* @return
* @throws AxelorException
*/
public Move createMoveWithPaymentVoucher(Journal journal, Company company, PaymentVoucher paymentVoucher, Partner partner, LocalDate date, PaymentMode paymentMode, int technicalOriginSelect, int functionalOriginSelect) throws AxelorException {
Move move = this.createMove(journal, company, paymentVoucher.getCurrency(), partner, date, paymentMode, technicalOriginSelect, functionalOriginSelect);
move.setPaymentVoucher(paymentVoucher);
return move;
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class AccountingReportController method showMoveExported.
public void showMoveExported(ActionRequest request, ActionResponse response) {
AccountingReport accountingReport = request.getContext().asType(AccountingReport.class);
ActionViewBuilder actionViewBuilder = ActionView.define(I18n.get(IExceptionMessage.ACCOUNTING_REPORT_6));
actionViewBuilder.model(Move.class.getName());
actionViewBuilder.add("grid", "move-grid");
actionViewBuilder.param("search-filters", "move-filters");
actionViewBuilder.domain("self.accountingReport.id = :_accountingReportId");
actionViewBuilder.context("_accountingReportId", accountingReport.getId());
response.setView(actionViewBuilder.map());
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class InvoicePaymentCreateServiceImpl method determineIfReconcileFromInvoice.
/**
* We try to get to the status of the invoice from the reconcile to see if this move was created
* from a payment for an advance payment invoice.
*
* @param move
* @return the found advance invoice if the move is from a payment that comes from this invoice.
* null in other cases
*/
protected Invoice determineIfReconcileFromInvoice(Move move) {
List<MoveLine> moveLineList = move.getMoveLineList();
if (moveLineList == null || moveLineList.size() != 2) {
return null;
}
InvoicePaymentRepository invoicePaymentRepo = Beans.get(InvoicePaymentRepository.class);
for (MoveLine moveLine : moveLineList) {
// search for the reconcile between the debit line
if (moveLine.getDebit().compareTo(BigDecimal.ZERO) > 0) {
Reconcile reconcile = Beans.get(ReconcileRepository.class).all().filter("self.debitMoveLine = ?", moveLine).fetchOne();
if (reconcile == null) {
return null;
}
// associated payment
if (reconcile.getCreditMoveLine() == null || reconcile.getCreditMoveLine().getMove() == null) {
continue;
}
Move candidatePaymentMove = reconcile.getCreditMoveLine().getMove();
InvoicePayment invoicePayment = invoicePaymentRepo.all().filter("self.move = :_move").bind("_move", candidatePaymentMove).fetchOne();
// payment, then return true.
if (invoicePayment != null && invoicePayment.getInvoice() != null && invoicePayment.getInvoice().getOperationSubTypeSelect() == InvoiceRepository.OPERATION_SUB_TYPE_ADVANCE) {
return invoicePayment.getInvoice();
}
}
}
return null;
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class InvoicePaymentToolServiceImpl method getCreditMoveLinesFromPayments.
@Override
public List<MoveLine> getCreditMoveLinesFromPayments(List<InvoicePayment> payments) {
List<MoveLine> moveLines = new ArrayList<>();
for (InvoicePayment payment : payments) {
Move move = payment.getMove();
if (move == null || move.getMoveLineList() == null || move.getMoveLineList().isEmpty()) {
continue;
}
moveLines.addAll(moveToolService.getToReconcileCreditMoveLines(move));
}
return moveLines;
}
Aggregations