Search in sources :

Example 41 with Move

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;
}
Also used : AxelorException(com.axelor.exception.AxelorException) Move(com.axelor.apps.account.db.Move) Currency(com.axelor.apps.base.db.Currency) MoveLine(com.axelor.apps.account.db.MoveLine)

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

Example 43 with 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());
}
Also used : AccountingReport(com.axelor.apps.account.db.AccountingReport) Move(com.axelor.apps.account.db.Move) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)

Example 44 with Move

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;
}
Also used : InvoicePayment(com.axelor.apps.account.db.InvoicePayment) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) ReconcileRepository(com.axelor.apps.account.db.repo.ReconcileRepository) InvoicePaymentRepository(com.axelor.apps.account.db.repo.InvoicePaymentRepository) Reconcile(com.axelor.apps.account.db.Reconcile)

Example 45 with Move

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;
}
Also used : InvoicePayment(com.axelor.apps.account.db.InvoicePayment) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) ArrayList(java.util.ArrayList)

Aggregations

Move (com.axelor.apps.account.db.Move)101 MoveLine (com.axelor.apps.account.db.MoveLine)51 Transactional (com.google.inject.persist.Transactional)37 Company (com.axelor.apps.base.db.Company)36 AxelorException (com.axelor.exception.AxelorException)34 BigDecimal (java.math.BigDecimal)33 Partner (com.axelor.apps.base.db.Partner)31 LocalDate (java.time.LocalDate)28 Journal (com.axelor.apps.account.db.Journal)25 Account (com.axelor.apps.account.db.Account)22 ArrayList (java.util.ArrayList)22 AccountConfig (com.axelor.apps.account.db.AccountConfig)18 Reconcile (com.axelor.apps.account.db.Reconcile)14 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)11 Invoice (com.axelor.apps.account.db.Invoice)11 List (java.util.List)7 BankDetails (com.axelor.apps.base.db.BankDetails)6 InvoicePayment (com.axelor.apps.account.db.InvoicePayment)5 MoveRepository (com.axelor.apps.account.db.repo.MoveRepository)5 MoveService (com.axelor.apps.account.service.move.MoveService)5