use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class InvoiceServiceImpl method getBankDetails.
@Override
public BankDetails getBankDetails(Invoice invoice) throws AxelorException {
BankDetails bankDetails;
if (invoice.getSchedulePaymentOk() && invoice.getPaymentSchedule() != null) {
bankDetails = invoice.getPaymentSchedule().getBankDetails();
if (bankDetails != null) {
return bankDetails;
}
}
bankDetails = invoice.getBankDetails();
if (bankDetails != null) {
return bankDetails;
}
Partner partner = invoice.getPartner();
Preconditions.checkNotNull(partner);
bankDetails = Beans.get(BankDetailsRepository.class).findDefaultByPartner(partner);
if (bankDetails != null) {
return bankDetails;
}
throw new AxelorException(invoice, TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.PARTNER_BANK_DETAILS_MISSING), partner.getName());
}
use of com.axelor.apps.base.db.Partner 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.Partner 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.Partner in project axelor-open-suite by axelor.
the class CfonbExportService method createRecipientCFONB.
/**
* Fonction permettant de créer un enregistrement 'destinataire' pour un export de prélèvement
* d'une échéance
*
* @param company Une société
* @param paymentScheduleLine Une échéance
* @return Un enregistrement 'destinataire'
* @throws AxelorException
*/
private String createRecipientCFONB(PaymentScheduleLine paymentScheduleLine, boolean mensu) throws AxelorException {
PaymentSchedule paymentSchedule = paymentScheduleLine.getPaymentSchedule();
Partner partner = paymentSchedule.getPartner();
BankDetails bankDetails = Beans.get(PaymentScheduleService.class).getBankDetails(paymentSchedule);
BigDecimal amount = paymentScheduleLine.getDirectDebitAmount();
// Référence
String ref = paymentScheduleLine.getDebitNumber();
// Nom/Raison sociale du débiteur
String partnerName = this.getPayeurPartnerName(partner);
String operationCode = // Code opération
this.cfonbConfig.getDirectDebitOperationCodeExportCFONB();
return this.createRecipientCFONB(amount, ref, partnerName, bankDetails, operationCode);
}
use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class BatchCloseAnnualAccounts method process.
protected void process() {
if (!end) {
AccountingBatch accountingBatch = batch.getAccountingBatch();
boolean allocatePerPartner = accountingBatch.getAllocatePerPartner();
boolean closeYear = accountingBatch.getCloseYear();
boolean openYear = accountingBatch.getOpenYear();
Year year = accountingBatch.getYear();
LocalDate endOfYearDate = year.getToDate();
LocalDate reportedBalanceDate = year.getReportedBalanceDate();
String origin = accountingBatch.getCode();
String moveDescription = accountingBatch.getMoveDescription();
List<Long> accountIdList = accountingCloseAnnualService.getAllAccountOfYear(accountingBatch.getAccountSet(), year);
List<Pair<Long, Long>> accountAndPartnerPairList = accountingCloseAnnualService.assignPartner(accountIdList, year, allocatePerPartner);
Account account = null;
Partner partner = null;
for (Pair<Long, Long> accountAndPartnerPair : accountAndPartnerPairList) {
try {
account = accountRepository.find(accountAndPartnerPair.getLeft());
if (accountAndPartnerPair.getRight() != null) {
partner = partnerRepository.find(accountAndPartnerPair.getRight());
} else {
partner = null;
}
List<Move> generateMoves = accountingCloseAnnualService.generateCloseAnnualAccount(yearRepository.find(year.getId()), account, partner, endOfYearDate, reportedBalanceDate, origin, moveDescription, closeYear, openYear, allocatePerPartner);
if (generateMoves != null && !generateMoves.isEmpty()) {
updateAccount(account);
for (Move move : generateMoves) {
updateAccountMove(move, false);
}
}
} catch (AxelorException e) {
TraceBackService.trace(new AxelorException(e, e.getCategory(), I18n.get("Account") + " %s", account.getCode()), null, batch.getId());
incrementAnomaly();
break;
} catch (Exception e) {
TraceBackService.trace(new Exception(String.format(I18n.get("Account") + " %s", account.getCode()), e), null, batch.getId());
incrementAnomaly();
LOG.error("Anomaly generated for the account {}", account.getCode());
break;
} finally {
JPA.clear();
}
}
}
}
Aggregations