Search in sources :

Example 16 with Move

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

the class AccountingCloseAnnualServiceImpl method generateCloseAnnualAccount.

@Transactional(rollbackOn = { AxelorException.class, RuntimeException.class })
public List<Move> generateCloseAnnualAccount(Year year, Account account, Partner partner, LocalDate endOfYearDate, LocalDate reportedBalanceDate, String origin, String moveDescription, boolean closeYear, boolean openYear, boolean allocatePerPartner) throws AxelorException {
    List<Move> moveList = new ArrayList<>();
    Move closeYearMove = null;
    Move openYearMove = null;
    if (closeYear) {
        closeYearMove = generateCloseAnnualAccountMove(year, account, endOfYearDate, endOfYearDate, origin, moveDescription, partner, false, allocatePerPartner);
        if (closeYearMove == null) {
            return null;
        }
        moveList.add(closeYearMove);
    }
    if (openYear) {
        openYearMove = generateCloseAnnualAccountMove(year, account, reportedBalanceDate, endOfYearDate, origin, moveDescription, partner, true, allocatePerPartner);
        if (openYearMove == null) {
            return null;
        }
        moveList.add(openYearMove);
    }
    if (closeYearMove != null && openYearMove != null) {
        reconcile(closeYearMove, openYearMove);
    }
    return moveList;
}
Also used : Move(com.axelor.apps.account.db.Move) ArrayList(java.util.ArrayList) Transactional(com.google.inject.persist.Transactional)

Example 17 with Move

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

the class ChequeRejectionService method createChequeRejectionMove.

/**
 * Méthode permettant de créer une écriture de rejet de chèque (L'extourne de l'écriture de
 * paiement)
 *
 * @param chequeRejection Un rejet de cheque brouillon
 * @param company Une société
 * @return L'écriture de rejet de chèque
 * @throws AxelorException
 */
public Move createChequeRejectionMove(ChequeRejection chequeRejection, Company company) throws AxelorException {
    this.testCompanyField(company);
    Journal journal = company.getAccountConfig().getRejectJournal();
    PaymentVoucher paymentVoucher = chequeRejection.getPaymentVoucher();
    Move paymentMove = paymentVoucher.getGeneratedMove();
    Partner partner = paymentVoucher.getPartner();
    InterbankCodeLine interbankCodeLine = chequeRejection.getInterbankCodeLine();
    String description = chequeRejection.getDescription();
    LocalDate rejectionDate = chequeRejection.getRejectionDate();
    // Move
    Move move = moveService.getMoveCreateService().createMove(journal, company, null, partner, rejectionDate, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
    int ref = 1;
    for (MoveLine moveLine : paymentMove.getMoveLineList()) {
        if (moveLine.getCredit().compareTo(BigDecimal.ZERO) > 0) {
            // Debit MoveLine
            MoveLine debitMoveLine = moveLineService.createMoveLine(move, partner, moveLine.getAccount(), moveLine.getCredit(), true, rejectionDate, ref, chequeRejection.getName(), chequeRejection.getDescription());
            move.getMoveLineList().add(debitMoveLine);
            debitMoveLine.setInterbankCodeLine(interbankCodeLine);
            debitMoveLine.setDescription(description);
        } else {
            // Credit MoveLine
            MoveLine creditMoveLine = moveLineService.createMoveLine(move, partner, moveLine.getAccount(), moveLine.getDebit(), false, rejectionDate, ref, chequeRejection.getName(), chequeRejection.getDescription());
            move.getMoveLineList().add(creditMoveLine);
            creditMoveLine.setInterbankCodeLine(interbankCodeLine);
            creditMoveLine.setDescription(description);
        }
        ref++;
    }
    move.setRejectOk(true);
    moveService.getMoveValidateService().validate(move);
    return move;
}
Also used : Move(com.axelor.apps.account.db.Move) InterbankCodeLine(com.axelor.apps.account.db.InterbankCodeLine) MoveLine(com.axelor.apps.account.db.MoveLine) Journal(com.axelor.apps.account.db.Journal) Partner(com.axelor.apps.base.db.Partner) LocalDate(java.time.LocalDate) PaymentVoucher(com.axelor.apps.account.db.PaymentVoucher)

Example 18 with Move

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

the class DoubtfulCustomerService method createDoubtFulCustomerMove.

/**
 * Procédure permettant de créer les écritures de passage en client douteux pour chaque écriture
 * de facture
 *
 * @param move Une écritures de facture
 * @param doubtfulCustomerAccount Un compte client douteux
 * @param debtPassReason Un motif de passage en client douteux
 * @throws AxelorException
 */
@Transactional(rollbackOn = { Exception.class })
public void createDoubtFulCustomerMove(Move move, Account doubtfulCustomerAccount, String debtPassReason) throws AxelorException {
    log.debug("Concerned account move : {} ", move.getReference());
    Company company = move.getCompany();
    Partner partner = move.getPartner();
    Invoice invoice = move.getInvoice();
    Move newMove = moveService.getMoveCreateService().createMove(company.getAccountConfig().getAutoMiscOpeJournal(), company, invoice.getCurrency(), partner, move.getPaymentMode(), MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, move.getFunctionalOriginSelect());
    newMove.setInvoice(invoice);
    LocalDate todayDate = appBaseService.getTodayDate(company);
    MoveLine invoicePartnerMoveLine = null;
    for (MoveLine moveLine : move.getMoveLineList()) {
        if (moveLine.getAccount().getUseForPartnerBalance() && moveLine.getAmountRemaining().compareTo(BigDecimal.ZERO) > 0 && moveLine.getAccount() != doubtfulCustomerAccount && moveLine.getDebit().compareTo(BigDecimal.ZERO) > 0) {
            invoicePartnerMoveLine = moveLine;
        }
    }
    String origin = "";
    BigDecimal amountRemaining = BigDecimal.ZERO;
    MoveLine creditMoveLine = null;
    if (invoicePartnerMoveLine != null) {
        amountRemaining = invoicePartnerMoveLine.getAmountRemaining();
        // Debit move line on partner account
        creditMoveLine = moveLineService.createMoveLine(newMove, partner, invoicePartnerMoveLine.getAccount(), amountRemaining, false, todayDate, 1, move.getInvoice().getInvoiceId(), debtPassReason);
        newMove.getMoveLineList().add(creditMoveLine);
        origin = creditMoveLine.getOrigin();
    }
    // Credit move line on partner account
    MoveLine debitMoveLine = moveLineService.createMoveLine(newMove, partner, doubtfulCustomerAccount, amountRemaining, true, todayDate, 2, origin, debtPassReason);
    newMove.getMoveLineList().add(debitMoveLine);
    debitMoveLine.setPassageReason(debtPassReason);
    moveService.getMoveValidateService().validate(newMove);
    moveRepo.save(newMove);
    if (creditMoveLine != null) {
        Reconcile reconcile = reconcileService.createReconcile(invoicePartnerMoveLine, creditMoveLine, amountRemaining, false);
        if (reconcile != null) {
            reconcileService.confirmReconcile(reconcile, true);
        }
    }
    this.invoiceProcess(newMove, doubtfulCustomerAccount, debtPassReason);
}
Also used : Company(com.axelor.apps.base.db.Company) Invoice(com.axelor.apps.account.db.Invoice) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) Partner(com.axelor.apps.base.db.Partner) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal) Reconcile(com.axelor.apps.account.db.Reconcile) Transactional(com.google.inject.persist.Transactional)

Example 19 with Move

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

the class DoubtfulCustomerService method updateDoubtfulCustomerMove.

/**
 * Procédure permettant de mettre à jour le motif de passage en client douteux, et créer
 * l'évènement lié.
 *
 * @param moveList Une liste d'éciture de facture
 * @param doubtfulCustomerAccount Un compte client douteux
 * @param debtPassReason Un motif de passage en client douteux
 */
public void updateDoubtfulCustomerMove(List<Move> moveList, Account doubtfulCustomerAccount, String debtPassReason) {
    for (Move move : moveList) {
        for (MoveLine moveLine : move.getMoveLineList()) {
            if (moveLine.getAccount().equals(doubtfulCustomerAccount) && moveLine.getDebit().compareTo(BigDecimal.ZERO) > 0) {
                moveLine.setPassageReason(debtPassReason);
                moveLineRepo.save(moveLine);
                break;
            }
        }
    }
}
Also used : Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine)

Example 20 with Move

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

the class BatchDoubtfulCustomer method process.

@SuppressWarnings("unchecked")
@Override
protected void process() {
    if (!end) {
        Company company = batch.getAccountingBatch().getCompany();
        AccountConfig accountConfig = company.getAccountConfig();
        Account doubtfulCustomerAccount = accountConfig.getDoubtfulCustomerAccount();
        String sixMonthDebtPassReason = accountConfig.getSixMonthDebtPassReason();
        String threeMonthDebtPassReason = accountConfig.getThreeMonthDebtPassReason();
        // FACTURES
        List<Move> moveList = doubtfulCustomerService.getMove(0, doubtfulCustomerAccount, company);
        log.debug("Nombre d'écritures de facture concernées (Créance de + 6 mois) au 411 : {} ", moveList.size());
        this.createDoubtFulCustomerMove(moveList, doubtfulCustomerAccount, sixMonthDebtPassReason);
        moveList = doubtfulCustomerService.getMove(1, doubtfulCustomerAccount, company);
        log.debug("Nombre d'écritures de facture concernées (Créance de + 3 mois) au 411 : {} ", moveList.size());
        this.createDoubtFulCustomerMove(moveList, doubtfulCustomerAccount, threeMonthDebtPassReason);
        // FACTURES REJETES
        List<MoveLine> moveLineList = (List<MoveLine>) doubtfulCustomerService.getRejectMoveLine(0, doubtfulCustomerAccount, company);
        log.debug("Nombre de lignes d'écriture de rejet concernées (Créance de + 6 mois) au 411 : {} ", moveLineList.size());
        this.createDoubtFulCustomerRejectMove(moveLineList, doubtfulCustomerAccount, sixMonthDebtPassReason);
        moveLineList = (List<MoveLine>) doubtfulCustomerService.getRejectMoveLine(1, doubtfulCustomerAccount, company);
        log.debug("Nombre de lignes d'écriture de rejet concernées (Créance de + 3 mois) au 411 : {} ", moveLineList.size());
        this.createDoubtFulCustomerRejectMove(moveLineList, doubtfulCustomerAccount, threeMonthDebtPassReason);
        updateCustomerAccountLog += batchAccountCustomer.updateAccountingSituationMarked(companyRepo.find(company.getId()));
    }
}
Also used : Account(com.axelor.apps.account.db.Account) Company(com.axelor.apps.base.db.Company) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) List(java.util.List) AccountConfig(com.axelor.apps.account.db.AccountConfig)

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