Search in sources :

Example 31 with Journal

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

the class NotificationServiceImpl method createPaymentMove.

@Transactional(rollbackOn = { Exception.class })
protected Move createPaymentMove(NotificationItem notificationItem) throws AxelorException {
    Notification notification = notificationItem.getNotification();
    Invoice invoice = notificationItem.getInvoice();
    Company company = invoice.getCompany();
    AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
    Journal journal = getJournal(accountConfig);
    SubrogationRelease subrogationRelease = getSubrogationRelease(notificationItem);
    String origin = computeOrigin(subrogationRelease, invoice);
    BigDecimal amountPaid = notificationItem.getAmountPaid();
    if (amountPaid.compareTo(BigDecimal.ZERO) == 0) {
        return null;
    }
    Move paymentMove = moveService.getMoveCreateService().createMove(journal, company, company.getCurrency(), invoice.getPartner(), notification.getPaymentDate(), null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
    MoveLine creditMoveLine, debitMoveLine;
    Account account = getAccount(accountConfig, notificationItem);
    debitMoveLine = moveService.getMoveLineService().createMoveLine(paymentMove, invoice.getPartner(), account, amountPaid, true, notification.getPaymentDate(), null, 1, origin, invoice.getInvoiceId());
    creditMoveLine = moveService.getMoveLineService().createMoveLine(paymentMove, invoice.getPartner(), invoice.getPartnerAccount(), amountPaid, false, notification.getPaymentDate(), null, 2, origin, invoice.getInvoiceId());
    paymentMove.addMoveLineListItem(debitMoveLine);
    paymentMove.addMoveLineListItem(creditMoveLine);
    paymentMove = moveRepository.save(paymentMove);
    moveService.getMoveValidateService().validate(paymentMove);
    MoveLine invoiceMoveLine = findInvoiceAccountMoveLine(invoice);
    MoveLine subrogationReleaseMoveLine = findSubrogationReleaseAccountMoveLine(invoice);
    if (invoiceMoveLine.getAmountRemaining().compareTo(BigDecimal.ZERO) == 1) {
        reconcileService.reconcile(invoiceMoveLine, creditMoveLine, true, true);
        if (subrogationReleaseMoveLine != null && notificationItem.getTypeSelect() == NotificationRepository.TYPE_PAYMENT_TO_THE_FACTORE) {
            reconcileService.reconcile(debitMoveLine, subrogationReleaseMoveLine, true, false);
        }
    }
    notificationItem.setMove(paymentMove);
    if (subrogationRelease != null) {
        subrogationReleaseService.clear(subrogationRelease);
    }
    return paymentMove;
}
Also used : Account(com.axelor.apps.account.db.Account) Company(com.axelor.apps.base.db.Company) Invoice(com.axelor.apps.account.db.Invoice) Move(com.axelor.apps.account.db.Move) SubrogationRelease(com.axelor.apps.account.db.SubrogationRelease) MoveLine(com.axelor.apps.account.db.MoveLine) Journal(com.axelor.apps.account.db.Journal) Notification(com.axelor.apps.account.db.Notification) BigDecimal(java.math.BigDecimal) AccountConfig(com.axelor.apps.account.db.AccountConfig) Transactional(com.google.inject.persist.Transactional)

Example 32 with Journal

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

the class BankReconciliationController method setJournal.

public void setJournal(ActionRequest request, ActionResponse response) {
    BankReconciliation bankReconciliation = request.getContext().asType(BankReconciliation.class);
    Journal journal = null;
    if (EntityHelper.getEntity(bankReconciliation).getBankDetails() != null) {
        journal = Beans.get(BankReconciliationService.class).getJournal(bankReconciliation);
    }
    response.setValue("journal", journal);
}
Also used : Journal(com.axelor.apps.account.db.Journal) BankReconciliation(com.axelor.apps.bankpayment.db.BankReconciliation)

Example 33 with Journal

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

the class FixedAssetLineMoveServiceImpl method generateMove.

@Transactional(rollbackOn = { Exception.class })
private void generateMove(FixedAssetLine fixedAssetLine) throws AxelorException {
    FixedAsset fixedAsset = fixedAssetLine.getFixedAsset();
    Journal journal = fixedAsset.getJournal();
    Company company = fixedAsset.getCompany();
    Partner partner = fixedAsset.getPartner();
    LocalDate date = fixedAssetLine.getDepreciationDate();
    log.debug("Creating an fixed asset line specific accounting entry {} (Company : {}, Journal : {})", fixedAsset.getReference(), company.getName(), journal.getCode());
    // Creating move
    Move move = moveCreateService.createMove(journal, company, company.getCurrency(), partner, date, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_FIXED_ASSET);
    if (move != null) {
        List<MoveLine> moveLines = new ArrayList<>();
        String origin = fixedAsset.getReference();
        Account debitLineAccount = fixedAsset.getFixedAssetCategory().getChargeAccount();
        Account creditLineAccount = fixedAsset.getFixedAssetCategory().getDepreciationAccount();
        BigDecimal amount = fixedAssetLine.getDepreciation();
        // Creating accounting debit move line
        MoveLine debitMoveLine = new MoveLine(move, partner, debitLineAccount, date, null, 1, amount, BigDecimal.ZERO, fixedAsset.getName(), origin, null, BigDecimal.ZERO, date);
        moveLines.add(debitMoveLine);
        this.addAnalyticToMoveLine(fixedAsset.getAnalyticDistributionTemplate(), debitMoveLine);
        // Creating accounting debit move line
        MoveLine creditMoveLine = new MoveLine(move, partner, creditLineAccount, date, null, 2, BigDecimal.ZERO, amount, fixedAsset.getName(), origin, null, BigDecimal.ZERO, date);
        moveLines.add(creditMoveLine);
        this.addAnalyticToMoveLine(fixedAsset.getAnalyticDistributionTemplate(), creditMoveLine);
        move.getMoveLineList().addAll(moveLines);
    }
    moveRepo.save(move);
    fixedAssetLine.setDepreciationAccountMove(move);
}
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) ArrayList(java.util.ArrayList) Journal(com.axelor.apps.account.db.Journal) FixedAsset(com.axelor.apps.account.db.FixedAsset) Partner(com.axelor.apps.base.db.Partner) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal) Transactional(com.google.inject.persist.Transactional)

Example 34 with Journal

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

the class MoveAdjustementService method createAdjustmentCreditMove.

/**
 * Creating move of passage in gap regulation (on credit)
 *
 * @param debitMoveLine
 * @return
 * @throws AxelorException
 */
public MoveLine createAdjustmentCreditMove(MoveLine debitMoveLine) throws AxelorException {
    Partner partner = debitMoveLine.getPartner();
    Account account = debitMoveLine.getAccount();
    Move debitMove = debitMoveLine.getMove();
    Company company = debitMove.getCompany();
    BigDecimal debitAmountRemaining = debitMoveLine.getAmountRemaining();
    AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
    Journal miscOperationJournal = accountConfigService.getAutoMiscOpeJournal(accountConfig);
    Move adjustmentMove = moveCreateService.createMove(miscOperationJournal, company, null, partner, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, debitMove.getFunctionalOriginSelect());
    // Création de la ligne au crédit
    MoveLine creditAdjustmentMoveLine = moveLineService.createMoveLine(adjustmentMove, partner, account, debitAmountRemaining, false, appAccountService.getTodayDate(company), 1, null, null);
    // Création de la ligne au débit
    MoveLine debitAdjustmentMoveLine = moveLineService.createMoveLine(adjustmentMove, partner, accountConfigService.getCashPositionVariationAccount(accountConfig), debitAmountRemaining, true, appAccountService.getTodayDate(company), 2, null, null);
    adjustmentMove.addMoveLineListItem(creditAdjustmentMoveLine);
    adjustmentMove.addMoveLineListItem(debitAdjustmentMoveLine);
    moveValidateService.validate(adjustmentMove);
    moveRepository.save(adjustmentMove);
    return creditAdjustmentMoveLine;
}
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) Journal(com.axelor.apps.account.db.Journal) Partner(com.axelor.apps.base.db.Partner) BigDecimal(java.math.BigDecimal) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 35 with Journal

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

the class MoveAdjustementService method createMoveToPassOnTheOtherAccount.

/**
 * Méthode permettant de créer une écriture du passage du compte de l'écriture au debit vers le
 * compte de l'écriture au credit.
 *
 * @param debitMoveLineToReconcile Ecriture au débit
 * @param creditMoveLineToReconcile Ecriture au crédit
 * @param amount Montant
 * @return L'écriture de passage du compte de l'écriture au debit vers le compte de l'écriture au
 *     credit.
 * @throws AxelorException
 */
public Move createMoveToPassOnTheOtherAccount(MoveLine debitMoveLineToReconcile, MoveLine creditMoveLineToReconcile, BigDecimal amount) throws AxelorException {
    Partner partnerDebit = debitMoveLineToReconcile.getPartner();
    Partner partnerCredit = creditMoveLineToReconcile.getPartner();
    Company company = debitMoveLineToReconcile.getMove().getCompany();
    AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
    Journal journal = accountConfigService.getAutoMiscOpeJournal(accountConfig);
    // Move
    Move move = moveCreateService.createMove(journal, company, null, partnerDebit, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, debitMoveLineToReconcile.getMove().getFunctionalOriginSelect());
    MoveLine debitMoveLine = moveLineService.createMoveLine(move, partnerCredit, creditMoveLineToReconcile.getAccount(), amount, true, appAccountService.getTodayDate(company), 1, null, null);
    MoveLine creditMoveLine = moveLineService.createMoveLine(move, partnerDebit, debitMoveLineToReconcile.getAccount(), amount, false, appAccountService.getTodayDate(company), 2, null, null);
    move.addMoveLineListItem(debitMoveLine);
    move.addMoveLineListItem(creditMoveLine);
    moveValidateService.validate(move);
    return move;
}
Also used : Company(com.axelor.apps.base.db.Company) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) Journal(com.axelor.apps.account.db.Journal) Partner(com.axelor.apps.base.db.Partner) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Aggregations

Journal (com.axelor.apps.account.db.Journal)35 Company (com.axelor.apps.base.db.Company)26 Move (com.axelor.apps.account.db.Move)24 MoveLine (com.axelor.apps.account.db.MoveLine)21 Account (com.axelor.apps.account.db.Account)18 Transactional (com.google.inject.persist.Transactional)18 BigDecimal (java.math.BigDecimal)18 Partner (com.axelor.apps.base.db.Partner)17 LocalDate (java.time.LocalDate)16 ArrayList (java.util.ArrayList)10 AccountConfig (com.axelor.apps.account.db.AccountConfig)9 BankDetails (com.axelor.apps.base.db.BankDetails)9 PaymentMode (com.axelor.apps.account.db.PaymentMode)7 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)6 AxelorException (com.axelor.exception.AxelorException)6 Query (javax.persistence.Query)5 Invoice (com.axelor.apps.account.db.Invoice)4 JournalType (com.axelor.apps.account.db.JournalType)4 Reconcile (com.axelor.apps.account.db.Reconcile)4 FixedAsset (com.axelor.apps.account.db.FixedAsset)2