| Line 13... |
Line 13... |
| 13 |
+ " o.retailerId, li.sgstRate, li.cgstRate, li.igstRate," +
|
13 |
+ " o.retailerId, li.sgstRate, li.cgstRate, li.igstRate," +
|
| 14 |
" cast(case when op.createTimestamp between :startDate and :endDate and op.rejectTimestamp is null then op.amount " +
|
14 |
" cast(case when op.createTimestamp between :startDate and :endDate and op.rejectTimestamp is null then op.amount " +
|
| 15 |
" when op.createTimestamp between :startDate and :endDate and op.rejectTimestamp between :startDate and :endDate then 0" +
|
15 |
" when op.createTimestamp between :startDate and :endDate and op.rejectTimestamp between :startDate and :endDate then 0" +
|
| 16 |
" when op.rejectTimestamp between :startDate and :endDate then -op.amount" +
|
16 |
" when op.rejectTimestamp between :startDate and :endDate then -op.amount" +
|
| 17 |
" else 0 end as float), op.inventoryItemId, lii.serialNumber, op.description, o.invoiceNumber, " +
|
17 |
" else 0 end as float), op.inventoryItemId, lii.serialNumber, op.description, o.invoiceNumber, " +
|
| 18 |
" case when op.rejectTimestamp between :startDate and :endDate then op.rejectTimestamp else op.createTimestamp end) from "
|
18 |
" case when op.rejectTimestamp between :startDate and :endDate then op.rejectTimestamp else op.createTimestamp end, ii.hsnCode) from "
|
| 19 |
+ " OfferPayout op join LineItemImei lii on (op.serialNumber=lii.serialNumber) join LineItem li on li.id=lii.lineItemId "
|
19 |
+ " OfferPayout op join InventoryItem ii on ii.id=op.inventoryItemId join LineItemImei lii on (op.serialNumber=lii.serialNumber) join LineItem li on li.id=lii.lineItemId "
|
| 20 |
+ " join Order o on (o.retailerId=op.fofoId and o.billingTimestamp is not null and o.id=li.orderId) "
|
20 |
+ " join Order o on (o.retailerId=op.fofoId and o.billingTimestamp is not null and o.id=li.orderId) "
|
| 21 |
+ " where op.createTimestamp >= :cnDate and ((op.createTimestamp between :startDate and :endDate) or (op.rejectTimestamp between :startDate and :endDate))"
|
21 |
+ " where op.createTimestamp >= :cnDate and ((op.createTimestamp between :startDate and :endDate) or (op.rejectTimestamp between :startDate and :endDate))"
|
| 22 |
+ " and lii.id=(select max(lii2.id) from LineItemImei lii2 join LineItem li2 on li2.id=lii2.lineItemId join Order o2 on o2.id=li2.orderId where lii2.serialNumber=lii.serialNumber and o2.retailerId=op.fofoId) "
|
22 |
+ " and lii.id=(select max(lii2.id) from LineItemImei lii2 join LineItem li2 on li2.id=lii2.lineItemId join Order o2 on o2.id=li2.orderId where lii2.serialNumber=lii.serialNumber and o2.retailerId=op.fofoId) "
|
| 23 |
+ " AND (:fofoId IS NULL OR o.retailerId = :fofoId)"),
|
23 |
+ " AND (:fofoId IS NULL OR o.retailerId = :fofoId)"),
|
| 24 |
|
24 |
|