use of com.axelor.apps.base.db.Company 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);
}
use of com.axelor.apps.base.db.Company 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()));
}
}
use of com.axelor.apps.base.db.Company in project axelor-open-suite by axelor.
the class DebtRecoverySessionService method getDebtRecoveryMethod.
/**
* Fonction permettant de récupérer une méthode de relance en fonction de la categorie du tiers et
* d'une société
*
* @param debtRecovery Une relance
* @return
*/
public DebtRecoveryMethod getDebtRecoveryMethod(DebtRecovery debtRecovery) {
AccountingSituation accountingSituation = debtRecovery.getTradingName() == null ? debtRecovery.getAccountingSituation() : debtRecovery.getTradingNameAccountingSituation();
Company company = accountingSituation.getCompany();
Partner partner = accountingSituation.getPartner();
List<DebtRecoveryConfigLine> debtRecoveryConfigLines = company.getAccountConfig().getDebtRecoveryConfigLineList();
for (DebtRecoveryConfigLine debtRecoveryConfigLine : debtRecoveryConfigLines) {
if (debtRecoveryConfigLine.getPartnerCategory().equals(partner.getPartnerCategory())) {
log.debug("méthode de relance determinée ");
return debtRecoveryConfigLine.getDebtRecoveryMethod();
}
}
log.debug("méthode de relance non determinée ");
return null;
}
use of com.axelor.apps.base.db.Company in project axelor-open-suite by axelor.
the class FixedAssetLineMoveServiceImpl method generateDisposalMove.
@Override
@Transactional(rollbackOn = { Exception.class })
public void generateDisposalMove(FixedAssetLine fixedAssetLine) throws AxelorException {
FixedAsset fixedAsset = fixedAssetLine.getFixedAsset();
Journal journal = fixedAsset.getJournal();
Company company = fixedAsset.getCompany();
Partner partner = fixedAsset.getPartner();
LocalDate date = fixedAssetLine.getDepreciationDate();
// 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<MoveLine>();
String origin = fixedAsset.getReference();
Account chargeAccount = fixedAsset.getFixedAssetCategory().getChargeAccount();
Account depreciationAccount = fixedAsset.getFixedAssetCategory().getDepreciationAccount();
Account purchaseAccount = fixedAsset.getPurchaseAccount();
BigDecimal chargeAmount = fixedAssetLine.getResidualValue();
BigDecimal cumulativeDepreciationAmount = fixedAssetLine.getCumulativeDepreciation();
// Creating accounting debit move line for charge account
MoveLine chargeAccountDebitMoveLine = new MoveLine(move, partner, chargeAccount, date, null, 1, chargeAmount, BigDecimal.ZERO, fixedAsset.getName(), origin, null, BigDecimal.ZERO, date);
moveLines.add(chargeAccountDebitMoveLine);
this.addAnalyticToMoveLine(fixedAsset.getAnalyticDistributionTemplate(), chargeAccountDebitMoveLine);
// Creating accounting debit move line for deprecation account
MoveLine deprecationAccountDebitMoveLine = new MoveLine(move, partner, depreciationAccount, date, null, 1, cumulativeDepreciationAmount, BigDecimal.ZERO, fixedAsset.getName(), origin, null, BigDecimal.ZERO, date);
moveLines.add(deprecationAccountDebitMoveLine);
this.addAnalyticToMoveLine(fixedAsset.getAnalyticDistributionTemplate(), deprecationAccountDebitMoveLine);
// Creating accounting credit move line
MoveLine creditMoveLine = new MoveLine(move, partner, purchaseAccount, date, null, 2, BigDecimal.ZERO, fixedAsset.getGrossValue(), fixedAsset.getName(), origin, null, BigDecimal.ZERO, date);
moveLines.add(creditMoveLine);
this.addAnalyticToMoveLine(fixedAsset.getAnalyticDistributionTemplate(), creditMoveLine);
move.getMoveLineList().addAll(moveLines);
}
moveRepo.save(move);
fixedAsset.setDisposalMove(move);
}
use of com.axelor.apps.base.db.Company in project axelor-open-suite by axelor.
the class PaymentModeServiceImpl method getAccountManagementDefaults.
@Override
public List<AccountManagement> getAccountManagementDefaults() {
List<AccountManagement> accountManagementList = new ArrayList<>();
List<Company> companyList = Beans.get(CompanyRepository.class).all().fetch();
for (Company company : companyList) {
AccountManagement accountManagement = new AccountManagement();
accountManagement.setCompany(company);
accountManagement.setTypeSelect(AccountManagementRepository.TYPE_PAYMENT);
accountManagementList.add(accountManagement);
}
return accountManagementList;
}
Aggregations