Search in sources :

Example 11 with Move

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

the class ReimbursementExportService method createReimbursementMove.

/**
 * Methode permettant de créer l'écriture de remboursement
 *
 * @param reimbursement Un objet d'export des prélèvements
 * @throws AxelorException
 */
public void createReimbursementMove(Reimbursement reimbursement, Company company) throws AxelorException {
    reimbursement = reimbursementRepo.find(reimbursement.getId());
    Partner partner = null;
    Move newMove = null;
    boolean first = true;
    AccountConfig accountConfig = company.getAccountConfig();
    if (reimbursement.getMoveLineSet() != null && !reimbursement.getMoveLineSet().isEmpty()) {
        int seq = 1;
        for (MoveLine moveLine : reimbursement.getMoveLineSet()) {
            BigDecimal amountRemaining = moveLine.getAmountRemaining();
            if (amountRemaining.compareTo(BigDecimal.ZERO) > 0) {
                partner = moveLine.getPartner();
                // On passe les lignes d'écriture (trop perçu) à l'état 'remboursé'
                moveLine.setReimbursementStatusSelect(MoveLineRepository.REIMBURSEMENT_STATUS_REIMBURSED);
                if (first) {
                    newMove = moveService.getMoveCreateService().createMove(accountConfig.getReimbursementJournal(), company, null, partner, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
                    first = false;
                }
                // Création d'une ligne au débit
                MoveLine newDebitMoveLine = moveLineService.createMoveLine(newMove, partner, moveLine.getAccount(), amountRemaining, true, appAccountService.getTodayDate(company), seq, reimbursement.getRef(), reimbursement.getDescription());
                newMove.getMoveLineList().add(newDebitMoveLine);
                if (reimbursement.getDescription() != null && !reimbursement.getDescription().isEmpty()) {
                    newDebitMoveLine.setDescription(reimbursement.getDescription());
                }
                seq++;
                // Création de la réconciliation
                Reconcile reconcile = reconcileService.createReconcile(newDebitMoveLine, moveLine, amountRemaining, false);
                if (reconcile != null) {
                    reconcileService.confirmReconcile(reconcile, true);
                }
            }
        }
        // Création de la ligne au crédit
        MoveLine newCreditMoveLine = moveLineService.createMoveLine(newMove, partner, accountConfig.getReimbursementAccount(), reimbursement.getAmountReimbursed(), false, appAccountService.getTodayDate(company), seq, reimbursement.getRef(), reimbursement.getDescription());
        newMove.getMoveLineList().add(newCreditMoveLine);
        if (reimbursement.getDescription() != null && !reimbursement.getDescription().isEmpty()) {
            newCreditMoveLine.setDescription(reimbursement.getDescription());
        }
        moveService.getMoveValidateService().validate(newMove);
        moveRepo.save(newMove);
    }
}
Also used : Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) Partner(com.axelor.apps.base.db.Partner) BigDecimal(java.math.BigDecimal) AccountConfig(com.axelor.apps.account.db.AccountConfig) Reconcile(com.axelor.apps.account.db.Reconcile)

Example 12 with Move

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

the class ReimbursementImportService method createReimbursementRejectMove.

public void createReimbursementRejectMove(List<String[]> rejectList, Company company) throws AxelorException {
    int seq = 1;
    if (rejectList != null && !rejectList.isEmpty()) {
        LocalDate rejectDate = rejectImportService.createRejectDate(rejectList.get(0)[0]);
        Move move = this.createMoveReject(company, rejectDate);
        for (String[] reject : rejectList) {
            this.createReimbursementRejectMoveLine(reject, company, seq, move, rejectDate);
            seq++;
        }
        if (move != null) {
            // Création d'une ligne au débit
            MoveLine debitMoveLine = moveLineService.createMoveLine(move, null, company.getAccountConfig().getReimbursementAccount(), this.getTotalAmount(move), true, rejectDate, seq, null, null);
            move.getMoveLineList().add(debitMoveLine);
            this.validateMove(move);
        }
    }
}
Also used : Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) LocalDate(java.time.LocalDate)

Example 13 with Move

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

the class ReconcileServiceImpl method udpatePaymentTax.

protected void udpatePaymentTax(Reconcile reconcile) throws AxelorException {
    Move debitMove = reconcile.getDebitMoveLine().getMove();
    Move creditMove = reconcile.getCreditMoveLine().getMove();
    Invoice debitInvoice = debitMove.getInvoice();
    Invoice creditInvoice = creditMove.getInvoice();
    if (debitInvoice != null && creditInvoice == null) {
        moveLineService.generateTaxPaymentMoveLineList(reconcile.getCreditMoveLine(), debitInvoice, reconcile);
    }
    if (creditInvoice != null && debitInvoice == null) {
        moveLineService.generateTaxPaymentMoveLineList(reconcile.getDebitMoveLine(), creditInvoice, reconcile);
    }
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) Move(com.axelor.apps.account.db.Move)

Example 14 with Move

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

the class ReconcileServiceImpl method reverseTaxPaymentMoveLines.

protected void reverseTaxPaymentMoveLines(Reconcile reconcile) throws AxelorException {
    Move debitMove = reconcile.getDebitMoveLine().getMove();
    Move creditMove = reconcile.getCreditMoveLine().getMove();
    Invoice debitInvoice = debitMove.getInvoice();
    Invoice creditInvoice = creditMove.getInvoice();
    if (debitInvoice == null) {
        moveLineService.reverseTaxPaymentMoveLines(reconcile.getDebitMoveLine(), reconcile);
    }
    if (creditInvoice == null) {
        moveLineService.reverseTaxPaymentMoveLines(reconcile.getCreditMoveLine(), reconcile);
    }
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) Move(com.axelor.apps.account.db.Move)

Example 15 with Move

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

the class ReconcileServiceImpl method updateInvoicePayments.

public void updateInvoicePayments(Reconcile reconcile) throws AxelorException {
    MoveLine debitMoveLine = reconcile.getDebitMoveLine();
    MoveLine creditMoveLine = reconcile.getCreditMoveLine();
    Move debitMove = debitMoveLine.getMove();
    Move creditMove = creditMoveLine.getMove();
    Invoice debitInvoice = debitMove.getInvoice();
    Invoice creditInvoice = creditMove.getInvoice();
    BigDecimal amount = reconcile.getAmount();
    if (debitInvoice != null && debitMoveLine.getAccount().getUseForPartnerBalance() && creditMoveLine.getAccount().getUseForPartnerBalance()) {
        InvoicePayment debitInvoicePayment = invoicePaymentCreateService.createInvoicePayment(debitInvoice, amount, creditMove);
        debitInvoicePayment.setReconcile(reconcile);
    }
    if (creditInvoice != null && debitMoveLine.getAccount().getUseForPartnerBalance() && creditMoveLine.getAccount().getUseForPartnerBalance()) {
        InvoicePayment creditInvoicePayment = invoicePaymentCreateService.createInvoicePayment(creditInvoice, amount, debitMove);
        creditInvoicePayment.setReconcile(reconcile);
    }
}
Also used : InvoicePayment(com.axelor.apps.account.db.InvoicePayment) Invoice(com.axelor.apps.account.db.Invoice) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) BigDecimal(java.math.BigDecimal)

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