use of com.axelor.apps.bankpayment.db.BankOrderLine in project axelor-open-suite by axelor.
the class BankOrderServiceImpl method setSequenceOnBankOrderLines.
@Override
public void setSequenceOnBankOrderLines(BankOrder bankOrder) {
if (bankOrder.getBankOrderLineList() == null) {
return;
}
String bankOrderSeq = bankOrder.getBankOrderSeq();
int counter = 1;
for (BankOrderLine bankOrderLine : bankOrder.getBankOrderLineList()) {
bankOrderLine.setCounter(counter);
bankOrderLine.setSequence(bankOrderSeq + "-" + Integer.toString(counter++));
}
}
use of com.axelor.apps.bankpayment.db.BankOrderLine in project axelor-open-suite by axelor.
the class BatchCreditTransferPartnerReimbursementBankPayment method createBankOrder.
/**
* Create a bank order for the specified list of reimbursements.
*
* @param accountingBatch
* @param reimbursementList
* @return
* @throws AxelorException
* @throws DatatypeConfigurationException
* @throws IOException
* @throws JAXBException
*/
@Transactional(rollbackOn = { Exception.class })
protected BankOrder createBankOrder(AccountingBatch accountingBatch, List<Reimbursement> reimbursementList) throws AxelorException, JAXBException, IOException, DatatypeConfigurationException {
LocalDate bankOrderDate = accountingBatch.getDueDate() != null ? accountingBatch.getDueDate() : appBaseService.getTodayDate(accountingBatch.getCompany());
BankOrder bankOrder = bankOrderCreateService.createBankOrder(accountingBatch.getPaymentMode(), BankOrderRepository.PARTNER_TYPE_CUSTOMER, bankOrderDate, accountingBatch.getCompany(), accountingBatch.getBankDetails(), accountingBatch.getCompany().getCurrency(), null, null, BankOrderRepository.TECHNICAL_ORIGIN_AUTOMATIC);
for (Reimbursement reimbursement : reimbursementList) {
BankOrderLine bankOrderLine = bankOrderLineService.createBankOrderLine(accountingBatch.getPaymentMode().getBankOrderFileFormat(), null, reimbursement.getPartner(), reimbursement.getBankDetails(), reimbursement.getAmountToReimburse(), accountingBatch.getCompany().getCurrency(), bankOrderDate, reimbursement.getRef(), reimbursement.getDescription(), reimbursement);
bankOrder.addBankOrderLineListItem(bankOrderLine);
Beans.get(ReimbursementExportService.class).reimburse(reimbursement, accountingBatch.getCompany());
}
bankOrder = bankOrderRepo.save(bankOrder);
bankOrderService.confirm(bankOrder);
return bankOrder;
}
use of com.axelor.apps.bankpayment.db.BankOrderLine in project axelor-open-suite by axelor.
the class BankOrderLineController method computeCompanyCurrencyAmount.
public void computeCompanyCurrencyAmount(ActionRequest request, ActionResponse response) {
BankOrderLine bankOrderLine = request.getContext().asType(BankOrderLine.class);
BankOrder bankOrder = request.getContext().getParent().asType(BankOrder.class);
try {
response.setValue("companyCurrencyAmount", Beans.get(BankOrderLineService.class).computeCompanyCurrencyAmount(bankOrder, bankOrderLine));
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.bankpayment.db.BankOrderLine in project axelor-open-suite by axelor.
the class BankOrderLineController method fillBankDetail.
public void fillBankDetail(ActionRequest request, ActionResponse response) {
BankOrderLine bankOrderLine = request.getContext().asType(BankOrderLine.class);
BankOrder bankOrder = request.getContext().getParent().asType(BankOrder.class);
BankDetails bankDetails = Beans.get(BankOrderLineService.class).getDefaultBankDetails(bankOrderLine, bankOrder);
response.setValue("receiverBankDetails", bankDetails);
}
use of com.axelor.apps.bankpayment.db.BankOrderLine in project axelor-open-suite by axelor.
the class BankOrderMergeServiceImpl method consolidatePerPartner.
public void consolidatePerPartner(BankOrder bankOrder) {
Map<List<Object>, BankOrderLine> bankOrderLineMap = new HashMap<List<Object>, BankOrderLine>();
int counter = 1;
for (BankOrderLine bankOrderLine : bankOrder.getBankOrderLineList()) {
List<Object> keys = new ArrayList<Object>();
keys.add(bankOrderLine.getPartner());
keys.add(bankOrderLine.getBankOrderCurrency());
keys.add(bankOrderLine.getBankOrderDate());
keys.add(bankOrderLine.getBankOrderEconomicReason());
keys.add(bankOrderLine.getFeesImputationModeSelect());
keys.add(bankOrderLine.getPaymentModeSelect());
keys.add(bankOrderLine.getReceiverBankDetails());
keys.add(bankOrderLine.getReceiverCompany());
if (bankOrderLineMap.containsKey(keys)) {
BankOrderLine consolidateBankOrderLine = bankOrderLineMap.get(keys);
if (consolidateBankOrderLine.getBankOrderLineOriginList() == null) {
consolidateBankOrderLine.setBankOrderLineOriginList(new ArrayList<>());
}
if (bankOrderLine.getBankOrderLineOriginList() != null) {
bankOrderLine.getBankOrderLineOriginList().stream().forEach(consolidateBankOrderLine::addBankOrderLineOriginListItem);
}
consolidateBankOrderLine.setBankOrderAmount(consolidateBankOrderLine.getBankOrderAmount().add(bankOrderLine.getBankOrderAmount()));
consolidateBankOrderLine.setCompanyCurrencyAmount(consolidateBankOrderLine.getCompanyCurrencyAmount().add(bankOrderLine.getCompanyCurrencyAmount()));
} else {
bankOrderLine.setCounter(counter++);
bankOrderLineMap.put(keys, bankOrderLine);
}
}
bankOrder.getBankOrderLineList().clear();
for (BankOrderLine bankOrderLine : bankOrderLineMap.values()) {
Pair<String, LocalDate> lastReferences = getLastReferences(bankOrderLine);
bankOrderLine.setReceiverReference(lastReferences.getLeft());
bankOrderLine.setBankOrderDate(lastReferences.getRight());
bankOrder.addBankOrderLineListItem(bankOrderLine);
}
}
Aggregations