use of com.axelor.apps.bankpayment.db.BankOrderLine in project axelor-open-suite by axelor.
the class BankOrderServiceImpl method computeCompanyCurrencyTotalAmount.
@Override
public BigDecimal computeCompanyCurrencyTotalAmount(BankOrder bankOrder) throws AxelorException {
BigDecimal companyCurrencyTotalAmount = BigDecimal.ZERO;
List<BankOrderLine> bankOrderLines = bankOrder.getBankOrderLineList();
if (bankOrderLines != null) {
for (BankOrderLine bankOrderLine : bankOrderLines) {
BigDecimal amount = bankOrderLine.getCompanyCurrencyAmount();
if (amount != null) {
companyCurrencyTotalAmount = companyCurrencyTotalAmount.add(amount);
}
}
}
return companyCurrencyTotalAmount;
}
use of com.axelor.apps.bankpayment.db.BankOrderLine 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;
}
use of com.axelor.apps.bankpayment.db.BankOrderLine in project axelor-open-suite by axelor.
the class BankOrderLineController method setBankDetailsDomain.
// settings the domain for the bank details view.
public void setBankDetailsDomain(ActionRequest request, ActionResponse response) {
BankOrderLine bankOrderLine = request.getContext().asType(BankOrderLine.class);
BankOrder bankOrder = request.getContext().getParent().asType(BankOrder.class);
String domain = Beans.get(BankOrderLineService.class).createDomainForBankDetails(bankOrderLine, bankOrder);
// if nothing was found for the domain, we set it at a default value.
if (domain.equals("")) {
response.setAttr("receiverBankDetails", "domain", "self.id IN (0)");
} else {
response.setAttr("receiverBankDetails", "domain", domain);
}
}
Aggregations