use of com.axelor.apps.bankpayment.db.BankOrderLineOrigin in project axelor-open-suite by axelor.
the class BankOrderLineManagementRepository method populate.
@Override
public Map<String, Object> populate(Map<String, Object> json, Map<String, Object> context) {
Long bankOrderLineId = (Long) json.get("id");
BankOrderLine bankOrderLine = find(bankOrderLineId);
String pieceReferenceList = "";
String pieceDateList = "";
String pieceDueDateList = "";
boolean bFirst = true;
for (BankOrderLineOrigin bankOrderLineOrigin : bankOrderLine.getBankOrderLineOriginList()) {
if (bFirst) {
pieceReferenceList += changeNullToEmptyString(bankOrderLineOrigin.getRelatedToSelectName());
pieceDateList += changeDateToString(bankOrderLineOrigin.getRelatedToSelectDate());
pieceDueDateList += changeDateToString(bankOrderLineOrigin.getRelatedToSelectDueDate());
bFirst = false;
} else {
pieceReferenceList += "," + changeNullToEmptyString(bankOrderLineOrigin.getRelatedToSelectName());
pieceDateList += "," + changeDateToString(bankOrderLineOrigin.getRelatedToSelectDate());
pieceDueDateList += "," + changeDateToString(bankOrderLineOrigin.getRelatedToSelectDueDate());
}
}
json.put("$pieceReferenceList", StringTool.cutTooLongString(pieceReferenceList));
json.put("$pieceDateList", StringTool.cutTooLongString(pieceDateList));
json.put("$pieceDueDateList", StringTool.cutTooLongString(pieceDueDateList));
return super.populate(json, context);
}
use of com.axelor.apps.bankpayment.db.BankOrderLineOrigin in project axelor-open-suite by axelor.
the class BankOrderLineOriginServiceImpl method createBankOrderLineOrigin.
protected BankOrderLineOrigin createBankOrderLineOrigin(String relatedToSelect, Long relatedToSelectId, String relatedToSelectName, LocalDate relatedToSelectDate, LocalDate relatedToSelectDueDate) {
BankOrderLineOrigin bankOrderLineOrigin = new BankOrderLineOrigin();
bankOrderLineOrigin.setRelatedToSelect(relatedToSelect);
bankOrderLineOrigin.setRelatedToSelectId(relatedToSelectId);
bankOrderLineOrigin.setRelatedToSelectName(relatedToSelectName);
bankOrderLineOrigin.setRelatedToSelectDate(relatedToSelectDate);
bankOrderLineOrigin.setRelatedToSelectDueDate(relatedToSelectDueDate);
return bankOrderLineOrigin;
}
use of com.axelor.apps.bankpayment.db.BankOrderLineOrigin in project axelor-open-suite by axelor.
the class BankOrderMergeServiceImpl method getLastReferences.
protected Pair<String, LocalDate> getLastReferences(BankOrderLine bankOrderLine) {
String lastReferenceId = "";
LocalDate lastReferenceDate = null;
for (BankOrderLineOrigin bankOrderLineOrigin : bankOrderLine.getBankOrderLineOriginList()) {
LocalDate originDate = null;
String originReferenceId = null;
switch(bankOrderLineOrigin.getRelatedToSelect()) {
case BankOrderLineOriginRepository.RELATED_TO_INVOICE:
Invoice invoice = invoiceRepository.find(bankOrderLineOrigin.getRelatedToSelectId());
if (!Strings.isNullOrEmpty(invoice.getSupplierInvoiceNb())) {
originReferenceId = invoice.getSupplierInvoiceNb();
} else {
originReferenceId = invoice.getInvoiceId();
}
if (!Strings.isNullOrEmpty(invoice.getSupplierInvoiceNb())) {
originDate = invoice.getOriginDate();
} else {
originDate = invoice.getInvoiceDate();
}
break;
case BankOrderLineOriginRepository.RELATED_TO_PAYMENT_SCHEDULE_LINE:
PaymentScheduleLine paymentScheduleLine = paymentScheduleLineRepository.find(bankOrderLineOrigin.getRelatedToSelectId());
originReferenceId = paymentScheduleLine.getName();
originDate = paymentScheduleLine.getScheduleDate();
break;
default:
break;
}
if (originDate != null && (lastReferenceDate == null || lastReferenceDate.isBefore(originDate))) {
lastReferenceDate = originDate;
lastReferenceId = originReferenceId;
}
}
return Pair.of(lastReferenceId, lastReferenceDate);
}
Aggregations