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;
}
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);
}
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);
}
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;
}
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;
}
Aggregations