use of com.axelor.apps.base.db.BankDetails 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 facture
*
* @param company Une société
* @param moveLine L' écriture d'export des prélèvement d'une facture
* @return Un enregistrement 'destinataire'
* @throws AxelorException
*/
private String createRecipientCFONB(Company company, Invoice invoice) throws AxelorException {
Partner partner = invoice.getPartner();
BankDetails bankDetails = partnerService.getDefaultBankDetails(partner);
if (bankDetails == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.PAYMENT_SCHEDULE_2), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION), partner.getName());
}
BigDecimal amount = invoice.getDirectDebitAmount();
// Référence
String ref = invoice.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.BankDetails in project axelor-open-suite by axelor.
the class CfonbExportService method createRecipientCFONB.
/**
* Fonction permettant de créer un enregistrement 'destinataire' pour un virement de remboursement
*
* @param company Une société
* @param reimbursement Un remboursement
* @return Un enregistrement 'destinataire'
* @throws AxelorException
*/
private String createRecipientCFONB(Reimbursement reimbursement) throws AxelorException {
BankDetails bankDetails = reimbursement.getBankDetails();
if (bankDetails == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, "%s :\n " + I18n.get(IExceptionMessage.CFONB_EXPORT_1) + " %s", I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION), reimbursement.getRef());
}
BigDecimal amount = reimbursement.getAmountReimbursed();
// Référence
String ref = reimbursement.getRef();
String partner = // Nom/Raison sociale du bénéficiaire
this.getPayeurPartnerName(reimbursement.getPartner());
// Code opération
String operationCode = this.cfonbConfig.getTransferOperationCodeExportCFONB();
return this.createRecipientCFONB(amount, ref, partner, bankDetails, operationCode);
}
use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.
the class PaymentScheduleServiceImpl method getBankDetails.
@Override
public BankDetails getBankDetails(PaymentSchedule paymentSchedule) throws AxelorException {
BankDetails bankDetails = paymentSchedule.getBankDetails();
if (bankDetails != null) {
return bankDetails;
}
Partner partner = paymentSchedule.getPartner();
Preconditions.checkNotNull(partner);
bankDetails = partnerService.getDefaultBankDetails(partner);
if (bankDetails != null) {
return bankDetails;
}
throw new AxelorException(partner, TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.PARTNER_BANK_DETAILS_MISSING), partner.getName());
}
use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.
the class AccountingSituationInitServiceImpl method createAccountingSituation.
@Override
@Transactional(rollbackOn = { Exception.class })
public AccountingSituation createAccountingSituation(Partner partner, Company company) throws AxelorException {
AccountingSituation accountingSituation = new AccountingSituation();
accountingSituation.setCompany(company);
partner.addCompanySetItem(company);
PaymentMode inPaymentMode = partner.getInPaymentMode();
PaymentMode outPaymentMode = partner.getOutPaymentMode();
BankDetails defaultBankDetails = company.getDefaultBankDetails();
if (inPaymentMode != null) {
List<BankDetails> authorizedInBankDetails = paymentModeService.getCompatibleBankDetailsList(inPaymentMode, company);
if (authorizedInBankDetails.contains(defaultBankDetails)) {
accountingSituation.setCompanyInBankDetails(defaultBankDetails);
}
}
if (outPaymentMode != null) {
List<BankDetails> authorizedOutBankDetails = paymentModeService.getCompatibleBankDetailsList(outPaymentMode, company);
if (authorizedOutBankDetails.contains(defaultBankDetails)) {
accountingSituation.setCompanyOutBankDetails(defaultBankDetails);
}
}
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
accountingSituation.setInvoiceAutomaticMail(accountConfig.getInvoiceAutomaticMail());
accountingSituation.setInvoiceMessageTemplate(accountConfig.getInvoiceMessageTemplate());
partner.addAccountingSituationListItem(accountingSituation);
return accountingSituationRepository.save(accountingSituation);
}
use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.
the class BatchBankPaymentServiceImpl method createBankOrderFromMonthlyPaymentScheduleLines.
@Override
@Transactional(rollbackOn = { Exception.class })
public BankOrder createBankOrderFromMonthlyPaymentScheduleLines(Batch batch) throws AxelorException, JAXBException, IOException, DatatypeConfigurationException {
AccountingBatch accountingBatch = batch.getAccountingBatch();
LocalDate bankOrderDate = accountingBatch.getDueDate();
Company senderCompany = accountingBatch.getCompany();
BankDetails senderBankDetails = accountingBatch.getBankDetails();
if (senderBankDetails == null) {
senderBankDetails = accountingBatch.getCompany().getDefaultBankDetails();
}
PaymentMode paymentMode = accountingBatch.getPaymentMode();
Currency currency = senderCompany.getCurrency();
int partnerType = BankOrderRepository.PARTNER_TYPE_CUSTOMER;
String senderReference = "";
String senderLabel = "";
if (bankOrderDate == null) {
bankOrderDate = appBaseService.getTodayDate(senderCompany);
}
BankOrder bankOrder = bankOrderCreateService.createBankOrder(paymentMode, partnerType, bankOrderDate, senderCompany, senderBankDetails, currency, senderReference, senderLabel, BankOrderRepository.TECHNICAL_ORIGIN_AUTOMATIC);
bankOrder = JPA.save(bankOrder);
List<PaymentScheduleLine> paymentScheduleLineList;
int offset = 0;
try {
while (!(paymentScheduleLineList = fetchPaymentScheduleLineDoneList(batch, offset)).isEmpty()) {
bankOrder = bankOrderRepo.find(bankOrder.getId());
for (PaymentScheduleLine paymentScheduleLine : paymentScheduleLineList) {
PaymentSchedule paymentSchedule = paymentScheduleLine.getPaymentSchedule();
Partner partner = paymentSchedule.getPartner();
BankDetails bankDetails = paymentScheduleService.getBankDetails(paymentSchedule);
BigDecimal amount = paymentScheduleLine.getInTaxAmount();
String receiverReference = paymentScheduleLine.getName();
String receiverLabel = paymentScheduleLine.getDebitNumber();
BankOrderLine bankOrderLine = bankOrderLineService.createBankOrderLine(paymentMode.getBankOrderFileFormat(), null, partner, bankDetails, amount, currency, bankOrderDate, receiverReference, receiverLabel, paymentScheduleLine);
bankOrder.addBankOrderLineListItem(bankOrderLine);
}
bankOrder = JPA.save(bankOrder);
offset += paymentScheduleLineList.size();
JPA.clear();
}
} catch (Exception e) {
bankOrder = bankOrderRepo.find(bankOrder.getId());
bankOrderRepo.remove(bankOrder);
throw e;
}
bankOrder = bankOrderRepo.find(bankOrder.getId());
bankOrder = bankOrderRepo.save(bankOrder);
bankOrderService.confirm(bankOrder);
batch = batchRepo.find(batch.getId());
batch.setBankOrder(bankOrder);
return bankOrder;
}
Aggregations