use of com.axelor.apps.bankpayment.db.BankOrderLine in project axelor-open-suite by axelor.
the class BankOrderFileAFB160Service method generateFile.
/**
* Method to create an XML file for SEPA transfer pain.001.001.02
*
* @throws AxelorException
* @throws DatatypeConfigurationException
* @throws JAXBException
* @throws IOException
*/
@Override
public File generateFile() throws JAXBException, IOException, AxelorException, DatatypeConfigurationException {
List<String> records = Lists.newArrayList();
records.add(this.createSenderRecord());
for (BankOrderLine bankOrderLine : bankOrderLineList) {
records.add(this.createDetailRecord(bankOrderLine));
if (this.useOptionalFurtherInformationRecord(bankOrderLine)) {
records.add(this.createOptionalFurtherInformationRecord(bankOrderLine));
}
}
records.add(this.createTotalRecord());
fileToCreate = records;
return super.generateFile();
}
use of com.axelor.apps.bankpayment.db.BankOrderLine in project axelor-open-suite by axelor.
the class BankOrderFileAFB320XCTService method generateFile.
/**
* Method to create an XML file for SEPA transfer pain.001.001.02
*
* @throws AxelorException
* @throws DatatypeConfigurationException
* @throws JAXBException
* @throws IOException
*/
@Override
public File generateFile() throws JAXBException, IOException, AxelorException, DatatypeConfigurationException {
List<String> records = Lists.newArrayList();
records.add(this.createSenderRecord());
for (BankOrderLine bankOrderLine : bankOrderLineList) {
records.add(this.createDetailRecord(bankOrderLine));
if (bankOrderLine.getPaymentModeSelect() == BankOrderLineRepository.PAYMENT_MODE_TRANSFER_OR_OTHER) {
records.add(this.createDependentReceiverBankRecord(bankOrderLine));
}
if (this.useOptionnalFurtherInformationRecord(bankOrderLine)) {
records.add(this.createOptionnalFurtherInformationRecord(bankOrderLine));
}
}
records.add(this.createTotalRecord());
fileToCreate = records;
return super.generateFile();
}
use of com.axelor.apps.bankpayment.db.BankOrderLine in project axelor-open-suite by axelor.
the class BankOrderCreateService method createBankOrder.
/**
* Method to create a bank order for an invoice Payment
*
* @param invoicePayment An invoice payment
* @throws AxelorException
*/
public BankOrder createBankOrder(InvoicePayment invoicePayment) throws AxelorException {
Invoice invoice = invoicePayment.getInvoice();
Company company = invoice.getCompany();
PaymentMode paymentMode = invoicePayment.getPaymentMode();
Partner partner = invoice.getPartner();
BigDecimal amount = invoicePayment.getAmount();
Currency currency = invoicePayment.getCurrency();
LocalDate paymentDate = invoicePayment.getPaymentDate();
BankDetails companyBankDetails = invoicePayment.getCompanyBankDetails() != null ? invoicePayment.getCompanyBankDetails() : this.getSenderBankDetails(invoice);
String reference = InvoiceToolService.isPurchase(invoice) ? invoice.getSupplierInvoiceNb() : invoice.getInvoiceId();
BankOrder bankOrder = this.createBankOrder(paymentMode, this.getBankOrderPartnerType(invoice), paymentDate, company, companyBankDetails, currency, reference, null, BankOrderRepository.TECHNICAL_ORIGIN_AUTOMATIC);
BankDetails receiverBankDetails = invoiceService.getBankDetails(invoice);
BankOrderLine bankOrderLine = bankOrderLineService.createBankOrderLine(paymentMode.getBankOrderFileFormat(), null, partner, receiverBankDetails, amount, currency, paymentDate, reference, null, invoice);
bankOrder.addBankOrderLineListItem(bankOrderLine);
bankOrder = bankOrderRepo.save(bankOrder);
return bankOrder;
}
use of com.axelor.apps.bankpayment.db.BankOrderLine in project axelor-open-suite by axelor.
the class BankOrderCreateService method createBankOrder.
/**
* Créer un ordre bancaire avec tous les paramètres
*
* @param
* @return
* @throws AxelorException
*/
public BankOrder createBankOrder(PaymentMode paymentMode, Integer partnerType, LocalDate bankOrderDate, Company senderCompany, BankDetails senderBankDetails, Currency currency, String senderReference, String senderLabel, int technicalOriginSelect) throws AxelorException {
BankOrderFileFormat bankOrderFileFormat = paymentMode.getBankOrderFileFormat();
BankOrder bankOrder = new BankOrder();
bankOrder.setOrderTypeSelect(paymentMode.getOrderTypeSelect());
bankOrder.setPaymentMode(paymentMode);
bankOrder.setPartnerTypeSelect(partnerType);
if (!bankOrderFileFormat.getIsMultiDate()) {
bankOrder.setBankOrderDate(bankOrderDate);
}
bankOrder.setStatusSelect(BankOrderRepository.STATUS_DRAFT);
bankOrder.setRejectStatusSelect(BankOrderRepository.REJECT_STATUS_NOT_REJECTED);
bankOrder.setSenderCompany(senderCompany);
bankOrder.setSenderBankDetails(senderBankDetails);
EbicsUser signatoryEbicsUser = bankOrderService.getDefaultEbicsUserFromBankDetails(senderBankDetails);
User signatoryUser = null;
if (signatoryEbicsUser != null) {
signatoryUser = signatoryEbicsUser.getAssociatedUser();
bankOrder.setSignatoryEbicsUser(signatoryEbicsUser);
}
if (signatoryUser != null) {
bankOrder.setSignatoryUser(signatoryUser);
}
if (!bankOrderFileFormat.getIsMultiCurrency()) {
bankOrder.setBankOrderCurrency(currency);
}
bankOrder.setCompanyCurrency(senderCompany.getCurrency());
bankOrder.setSenderReference(senderReference);
bankOrder.setSenderLabel(senderLabel);
bankOrder.setBankOrderLineList(new ArrayList<BankOrderLine>());
bankOrder.setBankOrderFileFormat(bankOrderFileFormat);
bankOrder.setTechnicalOriginSelect(technicalOriginSelect);
return bankOrder;
}
use of com.axelor.apps.bankpayment.db.BankOrderLine in project axelor-open-suite by axelor.
the class BankOrderLineService method createBankOrderLine.
/**
* Generic method to create a BankOrderLine
*
* @param receiverCompany
* @param partner
* @param bankDetails
* @param amount
* @param receiverReference
* @param receiverLabel
* @return
* @throws AxelorException
*/
public BankOrderLine createBankOrderLine(BankOrderFileFormat bankOrderFileFormat, Company receiverCompany, Partner partner, BankDetails bankDetails, BigDecimal amount, Currency currency, LocalDate bankOrderDate, String receiverReference, String receiverLabel, Model origin) throws AxelorException {
BankOrderLine bankOrderLine = new BankOrderLine();
bankOrderLine.setReceiverCompany(receiverCompany);
bankOrderLine.setPartner(partner);
bankOrderLine.setReceiverBankDetails(bankDetails);
bankOrderLine.setBankOrderAmount(amount);
if (bankOrderFileFormat.getIsMultiCurrency()) {
bankOrderLine.setBankOrderCurrency(currency);
}
if (bankOrderFileFormat.getIsMultiDate()) {
bankOrderLine.setBankOrderDate(bankOrderDate);
}
bankOrderLine.setReceiverReference(receiverReference);
bankOrderLine.setReceiverLabel(receiverLabel);
if (origin != null) {
bankOrderLine.addBankOrderLineOriginListItem(bankOrderLineOriginService.createBankOrderLineOrigin(origin));
}
if (bankOrderFileFormat.getOrderFileFormatSelect().equals(BankOrderFileFormatRepository.FILE_FORMAT_PAIN_XXX_CFONB320_XCT)) {
bankOrderLine.setBankOrderEconomicReason(bankOrderFileFormat.getBankOrderEconomicReason());
bankOrderLine.setReceiverCountry(bankOrderFileFormat.getReceiverCountry());
if (bankDetails != null) {
Bank bank = bankDetails.getBank();
if (bank != null && bank.getCountry() != null) {
bankOrderLine.setReceiverCountry(bank.getCountry());
}
} else {
throw new AxelorException(bankOrderLine, TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.BANK_ORDER_LINE_BANK_DETAILS_MISSING));
}
bankOrderLine.setPaymentModeSelect(bankOrderFileFormat.getPaymentModeSelect());
bankOrderLine.setFeesImputationModeSelect(bankOrderFileFormat.getFeesImputationModeSelect());
bankOrderLine.setReceiverAddressStr(getReceiverAddress(partner));
}
return bankOrderLine;
}
Aggregations