Search in sources :

Example 1 with BankOrderLineOrigin

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);
}
Also used : BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine) BankOrderLineOrigin(com.axelor.apps.bankpayment.db.BankOrderLineOrigin)

Example 2 with BankOrderLineOrigin

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;
}
Also used : BankOrderLineOrigin(com.axelor.apps.bankpayment.db.BankOrderLineOrigin)

Example 3 with 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);
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) PaymentScheduleLine(com.axelor.apps.account.db.PaymentScheduleLine) BankOrderLineOrigin(com.axelor.apps.bankpayment.db.BankOrderLineOrigin) LocalDate(java.time.LocalDate)

Aggregations

BankOrderLineOrigin (com.axelor.apps.bankpayment.db.BankOrderLineOrigin)3 Invoice (com.axelor.apps.account.db.Invoice)1 PaymentScheduleLine (com.axelor.apps.account.db.PaymentScheduleLine)1 BankOrderLine (com.axelor.apps.bankpayment.db.BankOrderLine)1 LocalDate (java.time.LocalDate)1