| 22653 |
ashik.ali |
1 |
package com.spice.profitmandi.dao.entity.fofo;
|
|
|
2 |
|
| 31903 |
amit.gupta |
3 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 31008 |
amit.gupta |
4 |
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
|
|
|
5 |
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
|
|
|
6 |
|
|
|
7 |
import javax.persistence.*;
|
| 30050 |
manish |
8 |
import java.io.Serializable;
|
|
|
9 |
import java.time.LocalDateTime;
|
| 31903 |
amit.gupta |
10 |
import java.util.Objects;
|
| 30050 |
manish |
11 |
|
| 22653 |
ashik.ali |
12 |
@Entity
|
| 31860 |
tejbeer |
13 |
@Table(name = "fofo.scheme_in_out")
|
| 29578 |
tejbeer |
14 |
|
|
|
15 |
@NamedQueries({
|
| 32071 |
amit.gupta |
16 |
@NamedQuery(name = "SchemeInOut.selectPendingActivationGroupByBrandYearMonth", query = "select new com.spice.profitmandi.dao.model.ActivationYearMonthModel(i.brand, "
|
|
|
17 |
+ " DATE_FORMAT(sio.createTimestamp, '%m-%Y'),sum(cast(sio.amount As integer )) ) from Scheme sc join SchemeInOut sio on"
|
|
|
18 |
+ " sc.id = sio.schemeId join InventoryItem ii on ii.id = sio.inventoryItemId"
|
|
|
19 |
+ " join Item i on i.id = ii.itemId where sc.type = 'ACTIVATION' and sio.status ='PENDING' and sio.createTimestamp >= :startDate and ii.fofoId = :fofoId "
|
|
|
20 |
+ " group by i.brand, DATE_FORMAT(sio.createTimestamp, '%m-%Y')"),
|
| 29578 |
tejbeer |
21 |
|
| 32071 |
amit.gupta |
22 |
@NamedQuery(name = "SchemeInOut.selectByYearMonthActivationGroupByBrand", query = "select new com.spice.profitmandi.dao.model.ActivationBrandModel(i.brand, "
|
|
|
23 |
+ " sum(cast(sio.amount As integer )) ) from Scheme sc join SchemeInOut sio on"
|
|
|
24 |
+ " sc.id = sio.schemeId join InventoryItem ii on ii.id = sio.inventoryItemId"
|
|
|
25 |
+ " join Item i on i.id = ii.itemId where sc.type = 'ACTIVATION' and sio.status ='PENDING' and sio.createTimestamp <= :endDate and ii.fofoId = :fofoId "
|
|
|
26 |
+ " group by i.brand"),
|
| 29578 |
tejbeer |
27 |
|
| 32071 |
amit.gupta |
28 |
@NamedQuery(name = "SchemeInOut.selectBrandPendingActivationItemDetails", query = "select new com.spice.profitmandi.dao.model.ActivationItemDetailModel(i.brand, "
|
|
|
29 |
+ " i.modelName,i.modelNumber,cast(sio.amount As integer ),ii.serialNumber, ii.id) from Scheme sc join SchemeInOut sio on"
|
|
|
30 |
+ " sc.id = sio.schemeId join InventoryItem ii on ii.id = sio.inventoryItemId"
|
|
|
31 |
+ " join Item i on i.id = ii.itemId where sc.type = 'ACTIVATION' and sio.status ='PENDING' and "
|
|
|
32 |
+ " ii.fofoId = :fofoId and i.brand = :brand and DATE_FORMAT(sio.createTimestamp, '%m-%Y') = :yearMonthValue"),
|
| 29578 |
tejbeer |
33 |
|
| 32071 |
amit.gupta |
34 |
@NamedQuery(name = "SchemeInOut.selectBrandPendingActivationItemDetailByYearMonth", query = "select new com.spice.profitmandi.dao.model.ActivationItemDetailModel(i.brand, "
|
|
|
35 |
+ " i.modelName,i.modelNumber,cast(sio.amount As integer ),ii.serialNumber, ii.id) from Scheme sc join SchemeInOut sio on"
|
|
|
36 |
+ " sc.id = sio.schemeId join InventoryItem ii on ii.id = sio.inventoryItemId"
|
|
|
37 |
+ " join Item i on i.id = ii.itemId where sc.type = 'ACTIVATION' and sio.status ='PENDING' and "
|
|
|
38 |
+ " ii.fofoId = :fofoId and i.brand = :brand and sio.createTimestamp <= :endDate"),
|
| 29578 |
tejbeer |
39 |
|
| 31008 |
amit.gupta |
40 |
|
| 32071 |
amit.gupta |
41 |
@NamedQuery(name = "SchemeInOut.selectAllPurchaseInventoryByFofoId", query = "select new com.spice.profitmandi.dao.model.AllPurchaseInventoryModel(sum(cast(sio.amount As int ))) from InventoryItem ii join SchemeInOut sio on"
|
| 34434 |
amit.gupta |
42 |
+ " sio.inventoryItemId=ii.id join Scheme sc on sc.id=sio.schemeId where sc.type in :types and ii.fofoId = :fofoId and ii.createTimestamp >= :startDate and "
|
| 32071 |
amit.gupta |
43 |
+ " ii.createTimestamp <= :endDate and ii.fofoId = :fofoId group by ii.fofoId"),
|
| 31008 |
amit.gupta |
44 |
|
| 32071 |
amit.gupta |
45 |
@NamedQuery(name = "SchemeInOut.selectAllCreditedSaleInventoryByFofoId", query = "select new com.spice.profitmandi.dao.model.AllPurchaseInventoryModel(sum(cast(sio.amount As int ))) from "
|
| 34434 |
amit.gupta |
46 |
+ " ScanRecord sr join InventoryItem ii on ii.id=sr.inventoryItemId join FofoOrder fo on fo.id=sr.orderId join SchemeInOut sio on (sio.inventoryItemId=sr.inventoryItemId) join Scheme sc on sc.id=sio.schemeId where sc.type in :types and fo.cancelledTimestamp is null and "
|
| 32071 |
amit.gupta |
47 |
+ " sio.status='CREDITED' and sr.type='SALE' and sr.createTimestamp >= :startDate and sr.createTimestamp <= :endDate and sr.fofoId = :fofoId group by sr.fofoId"),
|
| 31008 |
amit.gupta |
48 |
|
| 32071 |
amit.gupta |
49 |
@NamedQuery(name = "SchemeInOut.selectFrontIncomeByFofoId", query = "select new com.spice.profitmandi.dao.model.AllPurchaseInventoryModel(sum(cast(foi.sellingPrice As int )-cast(foi.dp As int ))) "
|
|
|
50 |
+ " from InventoryItem ii join ScanRecord sr on sr.inventoryItemId=ii.id join FofoOrder fo on fo.id=sr.orderId join FofoOrderItem foi on (foi.orderId=fo.id and foi.itemId=ii.itemId) where "
|
|
|
51 |
+ " fo.cancelledTimestamp is null and sr.type='SALE' and sr.createTimestamp >=:startDate and sr.createTimestamp <= :endDate and sr.fofoId = :fofoId group by sr.fofoId"),
|
| 31008 |
amit.gupta |
52 |
|
| 32071 |
amit.gupta |
53 |
@NamedQuery(name = "SchemeInOut.selectAllPendingSaleInventoryByFofoId", query = "select new com.spice.profitmandi.dao.model.AllPurchaseInventoryModel(sum(cast(sio.amount As int ))) from "
|
|
|
54 |
+ " ScanRecord sr join FofoOrder fo on fo.id=sr.orderId join SchemeInOut sio on sio.inventoryItemId=sr.inventoryItemId where fo.cancelledTimestamp is null and "
|
|
|
55 |
+ " sio.status='PENDING' and sr.type='SALE' and sr.createTimestamp >= :startDate and sr.createTimestamp < :endDate and sr.fofoId = :fofoId group by sr.fofoId"),
|
| 31008 |
amit.gupta |
56 |
|
| 32071 |
amit.gupta |
57 |
@NamedQuery(name = "SchemeInOut.selectLastMonthCreditedIncomeByFofoId", query = "select new com.spice.profitmandi.dao.model.LastMonthCreditedIncomeModel(foi.brand,sum(cast(foi.quantity As int)), sum(cast(sio.amount As int))) from ScanRecord sr "
|
| 34410 |
amit.gupta |
58 |
+ " join InventoryItem ii on ii.id=sr.inventoryItemId join FofoOrder fo on fo.id=sr.orderId join SchemeInOut sio on sio.inventoryItemId=sr.inventoryItemId join FofoOrderItem foi on (foi.orderId=fo.id and foi.itemId=ii.itemId) join Scheme sc on sc.id=sio.schemeId where sc.type in :types and fo.cancelledTimestamp is null and "
|
| 32071 |
amit.gupta |
59 |
+ "sio.status='CREDITED' and sr.type='SALE' and sr.createTimestamp >= :startDate and sr.createTimestamp < :endDate and sr.fofoId = :fofoId group by foi.brand"),
|
| 31008 |
amit.gupta |
60 |
|
| 32071 |
amit.gupta |
61 |
@NamedQuery(name = "SchemeInOut.selectFrontIncomeByBrand", query = "select new com.spice.profitmandi.dao.model.LastMonthCreditedIncomeModel(foi.brand,sum(cast(foi.quantity As int)), sum(cast(foi.sellingPrice As int )-cast(foi.dp As int ))) "
|
|
|
62 |
+ " from InventoryItem ii join ScanRecord sr on sr.inventoryItemId=ii.id join FofoOrder fo on fo.id=sr.orderId join FofoOrderItem foi on (foi.orderId=fo.id and foi.itemId = ii.itemId) where "
|
|
|
63 |
+ " fo.cancelledTimestamp is null and sr.type='SALE' and sr.createTimestamp >=:startDate and sr.createTimestamp <= :endDate and sr.fofoId = :fofoId group by foi.brand"),
|
| 31008 |
amit.gupta |
64 |
|
| 32071 |
amit.gupta |
65 |
@NamedQuery(name = "SchemeInOut.selectLastMonthPendingIncomeByFofoId", query = "select new com.spice.profitmandi.dao.model.LastMonthCreditedIncomeModel(foi.brand,sum(cast(foi.quantity As int)),sum(cast(sio.amount As int ))) from "
|
|
|
66 |
+ " ScanRecord sr join FofoOrder fo on fo.id=sr.orderId join SchemeInOut sio on sio.inventoryItemId=sr.inventoryItemId join FofoOrderItem foi on foi.orderId=fo.id where fo.cancelledTimestamp is null and "
|
|
|
67 |
+ " sio.status='PENDING' and sr.type='SALE' and sr.createTimestamp >= :startDate and sr.createTimestamp < :endDate and sr.fofoId = :fofoId group by foi.brand"),
|
| 31008 |
amit.gupta |
68 |
|
| 32071 |
amit.gupta |
69 |
@NamedQuery(name = "SchemeInOut.selectLastMonthPurchaseInMarginByFofoId", query = "select new com.spice.profitmandi.dao.model.LastMonthCreditedIncomeModel(i.brand, count(distinct ii.id ),sum(cast(sio.amount As int ))) from InventoryItem ii join SchemeInOut sio on"
|
| 34407 |
amit.gupta |
70 |
+ " sio.inventoryItemId=ii.id join Scheme sc on sc.id=sio.schemeId join Item i on i.id=ii.itemId where sio.status='CREDITED' and sc.type in :types and ii.fofoId = :fofoId and ii.createTimestamp >= :startDate and "
|
| 32071 |
amit.gupta |
71 |
+ " ii.createTimestamp <= :endDate group by i.brand"),
|
| 31008 |
amit.gupta |
72 |
|
|
|
73 |
|
| 32071 |
amit.gupta |
74 |
@NamedQuery(name = "SchemeInOut.selectLastMonthBrandWiseIncome", query = "select new com.spice.profitmandi.dao.model.LastMonthBrandWiseIncomeModel(" +
|
| 33375 |
amit.gupta |
75 |
" i.brand,sum(case when sio.status = 'CREDITED' then cast(sr.quantity As int) else 0 end)," +
|
| 32071 |
amit.gupta |
76 |
" sum(case when sio.status = 'CREDITED' then cast(sio.amount As float) else 0 end)," +
|
|
|
77 |
" sum(case when sio.status = 'PENDING' then cast(sio.amount As float) else 0 end)," +
|
|
|
78 |
"i.catalogItemId,i.modelName,i.modelNumber) from ScanRecord sr join InventoryItem ii on ii.id=sr.inventoryItemId "
|
| 34410 |
amit.gupta |
79 |
+ " join FofoOrder fo on fo.id=sr.orderId join SchemeInOut sio on sio.inventoryItemId=sr.inventoryItemId join FofoOrderItem foi on (foi.orderId=fo.id and ii.itemId=foi.itemId) join FofoLineItem fli on (fli.fofoOrderItemId=foi.id and fli.serialNumber=ii.serialNumber) join Item i on i.id=foi.itemId join Scheme sc on sc.id=sio.schemeId where sc.type in :types and fo.cancelledTimestamp is null and "
|
| 32237 |
amit.gupta |
80 |
+ " (sio.status='CREDITED' or sio.status='PENDING') and sr.type='SALE' and sr.createTimestamp >= :startDate and sr.createTimestamp < :endDate and sr.fofoId = :fofoId and foi.brand = :brand group by i.catalogItemId,i.modelName,i.modelNumber,i.brand"),
|
| 29578 |
tejbeer |
81 |
|
| 33375 |
amit.gupta |
82 |
@NamedQuery(name = "SchemeInOut.selectFrontIncomeBrandWise", query = "select new com.spice.profitmandi.dao.model.LastMonthFrontEndBrandWiseIncome(i.brand,sum(cast(sr.quantity As int)),sum(cast(foi.sellingPrice -foi.dp As float)),0.0,i.catalogItemId,i.modelName,i.modelNumber) "
|
| 32071 |
amit.gupta |
83 |
+ " from InventoryItem ii join ScanRecord sr on sr.inventoryItemId=ii.id join FofoOrder fo on fo.id=sr.orderId join FofoOrderItem foi on (foi.orderId=fo.id and foi.itemId=ii.itemId) join Item i on foi.itemId=i.id where "
|
| 32237 |
amit.gupta |
84 |
+ " fo.cancelledTimestamp is null and sr.type='SALE' and sr.createTimestamp >=:startDate and sr.createTimestamp < :endDate and sr.fofoId = :fofoId and foi.brand = :brand group by i.catalogItemId,i.modelName,i.modelNumber,i.brand"),
|
| 30050 |
manish |
85 |
|
| 32071 |
amit.gupta |
86 |
@NamedQuery(name = "SchemeInOut.selectLastMonthPurchaseBrandWiseIncome", query = "select new com.spice.profitmandi.dao.model.LastMonthBrandWiseIncomeModel( " +
|
|
|
87 |
"i.brand ,count(distinct ii.id),sum(cast(sio.amount As float)) ,0.0,i.catalogItemId,i.modelName,i.modelNumber) from"
|
|
|
88 |
+ " InventoryItem ii join SchemeInOut sio on sio.inventoryItemId=ii.id join Scheme sc on sc.id=sio.schemeId " +
|
|
|
89 |
" join Item i on i.id=ii.itemId where sio.status='CREDITED' and "
|
| 34410 |
amit.gupta |
90 |
+ " sc.type in :types and ii.fofoId = :fofoId and i.brand= :brand and ii.createTimestamp >= :startDate and " +
|
| 32071 |
amit.gupta |
91 |
" ii.createTimestamp <= :endDate group by i.catalogItemId,i.modelName,i.modelNumber,i.brand"),
|
| 30050 |
manish |
92 |
|
| 31008 |
amit.gupta |
93 |
|
| 32071 |
amit.gupta |
94 |
@NamedQuery(name = "SchemeInOut.selectLastMonthCreditedImei", query = "select new com.spice.profitmandi.dao.model.LastMonthImeiModel(fli.serialNumber,(case when sio.status='CREDITED' then sio.amount else 0 end),(case when sio.status='PENDING' then sio.amount else 0 end),sc.description,sr.createTimestamp,sio.status)" +
|
|
|
95 |
" from ScanRecord sr join InventoryItem ii on ii.id=sr.inventoryItemId "
|
| 33375 |
amit.gupta |
96 |
+ " join FofoOrder fo on fo.id=sr.orderId join SchemeInOut sio on sio.inventoryItemId=sr.inventoryItemId join FofoOrderItem foi on (foi.orderId=fo.id and foi.itemId=ii.itemId) join FofoLineItem fli on (fli.fofoOrderItemId=foi.id and fli.serialNumber=ii.serialNumber) "
|
| 34410 |
amit.gupta |
97 |
+ " join Item i on i.id=foi.itemId join Scheme sc on sc.id=sio.schemeId where sc.type in :types and fo.cancelledTimestamp is null and (sio.status='CREDITED' or sio.status='PENDING' ) and sr.type='SALE' and sr.createTimestamp >= :startDate and sr.createTimestamp <= :endDate and "
|
| 32071 |
amit.gupta |
98 |
+ " i.catalogItemId= :catalogItemId and sr.fofoId = :fofoId"),
|
| 30050 |
manish |
99 |
|
| 32071 |
amit.gupta |
100 |
@NamedQuery(name = "SchemeInOut.selectLastMonthPurchaseInImei", query = "select new com.spice.profitmandi.dao.model.LastMonthImeiModel(ii.serialNumber,sio.amount,cast(0.0 As float),sc.description,ii.createTimestamp,sio.status) from InventoryItem ii "
|
| 34410 |
amit.gupta |
101 |
+ " join SchemeInOut sio on sio.inventoryItemId=ii.id join Scheme sc on sc.id=sio.schemeId join Item i on i.id=ii.itemId where sio.status='CREDITED' and sc.type in :types and ii.fofoId = :fofoId and "
|
| 32071 |
amit.gupta |
102 |
+ " i.catalogItemId= :catalogItemId and ii.createTimestamp >= :startDate and ii.createTimestamp <= :endDate"),
|
| 31008 |
amit.gupta |
103 |
|
|
|
104 |
|
| 32071 |
amit.gupta |
105 |
@NamedQuery(name = "SchemeInOut.selectLastMonthFrontEndImei", query = "select new com.spice.profitmandi.dao.model.LastMonthFrontEndImeiModel( ii.serialNumber,foi.sellingPrice, foi.dp) from InventoryItem ii "
|
|
|
106 |
+ " join ScanRecord sr on sr.inventoryItemId=ii.id join FofoOrder fo on fo.id=sr.orderId join FofoOrderItem foi on (foi.orderId=fo.id and foi.itemId=ii.itemId) join Item i on foi.itemId=i.id where "
|
|
|
107 |
+ " fo.cancelledTimestamp is null and sr.type='SALE' and i.catalogItemId= :catalogItemId and sr.createTimestamp >=:startDate and sr.createTimestamp <= :endDate and sr.fofoId = :fofoId "
|
|
|
108 |
+ " group by ii.id"),
|
| 31008 |
amit.gupta |
109 |
|
| 32071 |
amit.gupta |
110 |
@NamedQuery(name = "SchemeInOut.selectLastMonthCreditedByImei", query = "select new com.spice.profitmandi.dao.model.LastMonthImeiModel(fli.serialNumber,(case when sio.status='CREDITED' then sio.amount else 0 end),(case when sio.status='PENDING' then sio.amount else 0 end),sc.description,sr.createTimestamp,sio.status)from ScanRecord sr "
|
| 33375 |
amit.gupta |
111 |
+ " join InventoryItem ii on ii.id=sr.inventoryItemId join FofoOrder fo on fo.id=sr.orderId join SchemeInOut sio on sio.inventoryItemId=sr.inventoryItemId join FofoOrderItem foi on foi.orderId=fo.id join FofoLineItem fli on (fli.fofoOrderItemId=foi.id and fli.serialNumber=ii.serialNumber )"
|
| 34410 |
amit.gupta |
112 |
+ " join Item i on i.id=foi.itemId join Scheme sc on sc.id=sio.schemeId where sc.type in :types and fo.cancelledTimestamp is null and (sio.status='CREDITED' or sio.status='PENDING') and sr.type='SALE' and "
|
| 32071 |
amit.gupta |
113 |
+ " fli.serialNumber in :imeis and sr.fofoId = :fofoId"),
|
| 30050 |
manish |
114 |
|
| 32071 |
amit.gupta |
115 |
@NamedQuery(name = "SchemeInOut.selectLastMonthPurchaseInByImei", query = "select new com.spice.profitmandi.dao.model.LastMonthImeiModel(ii.serialNumber,sio.amount, cast(0.0 As float) ,sc.description,ii.createTimestamp,sio.status) from InventoryItem ii "
|
| 34410 |
amit.gupta |
116 |
+ " join SchemeInOut sio on sio.inventoryItemId=ii.id join Scheme sc on sc.id=sio.schemeId join Item i on i.id=ii.itemId where sio.status='CREDITED' and sc.type in :types and ii.fofoId = :fofoId and "
|
| 32071 |
amit.gupta |
117 |
+ " ii.serialNumber in :imeis"),
|
| 31008 |
amit.gupta |
118 |
|
| 35378 |
amit |
119 |
@NamedQuery(name = "SchemeInOut.selectLastMonthFrontEndByImei", query = "select new com.spice.profitmandi.dao.model.LastMonthFrontEndImeiModel( ii.serialNumber,foi.sellingPrice, ii.unitPrice-ii.priceDropAmount, fo.createTimestamp) from InventoryItem ii "
|
| 32071 |
amit.gupta |
120 |
+ " join ScanRecord sr on sr.inventoryItemId=ii.id join FofoOrder fo on fo.id=sr.orderId join FofoOrderItem foi on (foi.orderId=fo.id and ii.itemId=foi.itemId) where "
|
|
|
121 |
+ " fo.cancelledTimestamp is null and sr.type='SALE' and ii.serialNumber in (:imeis) and sr.fofoId = :fofoId group by ii.id"),
|
| 31008 |
amit.gupta |
122 |
|
|
|
123 |
|
| 32071 |
amit.gupta |
124 |
@NamedQuery(name = "SchemeInOut.selectLastMonthCategoryUpgradeMarginByBrand", query = "select new com.spice.profitmandi.dao.model.LastMonthCategoryUpgradeMargin(foi.brand, sum(case when sio.status='REJECTED' then -sio.amount else sio.amount end) ) " +
|
|
|
125 |
" from ScanRecord sr join InventoryItem ii on ii.id=sr.inventoryItemId "
|
|
|
126 |
+ " join FofoOrder fo on fo.id=sr.orderId join SchemeInOut sio on sio.inventoryItemId=sr.inventoryItemId join FofoOrderItem foi on (foi.orderId=fo.id and foi.itemId=ii.itemId) join Scheme sc on sc.id=sio.schemeId where sc.type = 'CATEGORY' and fo.cancelledTimestamp is null "
|
|
|
127 |
+ " and sr.type='SALE' and sr.createTimestamp >= :startDate and sr.createTimestamp <= :endDate and sr.fofoId = :fofoId group by foi.brand"),
|
| 31008 |
amit.gupta |
128 |
|
| 32071 |
amit.gupta |
129 |
@NamedQuery(name = "SchemeInOut.selectLastMonthCategoryUpgradeMarginByBrandModel", query = "select new com.spice.profitmandi.dao.model.LastMonthCategoryUpgradeMargin(i.modelNumber,sum(case when sio.status='REJECTED' then -sio.amount else sio.amount end)) " +
|
|
|
130 |
" from ScanRecord sr join InventoryItem ii on ii.id=sr.inventoryItemId "
|
| 33375 |
amit.gupta |
131 |
+ " join FofoOrder fo on fo.id=sr.orderId join SchemeInOut sio on sio.inventoryItemId=sr.inventoryItemId join FofoOrderItem foi on (foi.orderId=fo.id and foi.itemId=ii.itemId) join FofoLineItem fli on (fli.fofoOrderItemId=foi.id and fli.serialNumber=ii.serialNumber) join Item i on i.id=foi.itemId join Scheme sc on sc.id=sio.schemeId where sc.type = 'CATEGORY' and fo.cancelledTimestamp is null and "
|
| 32071 |
amit.gupta |
132 |
+ " sr.type='SALE' and sr.createTimestamp >= :startDate and sr.createTimestamp <= :endDate and sr.fofoId = :fofoId and foi.brand = :brand group by i.catalogItemId,i.modelName,i.modelNumber,i.brand"),
|
| 30050 |
manish |
133 |
|
| 32071 |
amit.gupta |
134 |
@NamedQuery(name = "SchemeInOut.selectLastMonthCategoryUpgradeMarginByImei", query = "select new com.spice.profitmandi.dao.model.LastMonthCategoryUpgradeMargin(fli.serialNumber,sum(case when sio.status='REJECTED' then -sio.amount else sio.amount end) ) from " +
|
|
|
135 |
" ScanRecord sr join InventoryItem ii on ii.id=sr.inventoryItemId "
|
| 33375 |
amit.gupta |
136 |
+ " join FofoOrder fo on fo.id=sr.orderId join SchemeInOut sio on sio.inventoryItemId=sr.inventoryItemId join FofoOrderItem foi on (foi.orderId=fo.id and foi.itemId=ii.itemId) join FofoLineItem fli on (fli.fofoOrderItemId=foi.id and ii.serialNumber=fli.serialNumber) "
|
| 32071 |
amit.gupta |
137 |
+ " join Item i on i.id=foi.itemId join Scheme sc on sc.id=sio.schemeId where sc.type = 'CATEGORY' and fo.cancelledTimestamp is null and sr.type='SALE' and sr.createTimestamp >= :startDate and sr.createTimestamp <= :endDate and "
|
|
|
138 |
+ " i.catalogItemId= :catalogItemId and sr.fofoId = :fofoId group by fli.serialNumber"),
|
| 30050 |
manish |
139 |
|
| 31008 |
amit.gupta |
140 |
|
| 32071 |
amit.gupta |
141 |
@NamedQuery(name = "SchemeInOut.selectPaidMargins", query = "select new com.spice.profitmandi.service.transaction.InventoryMarginModel("
|
|
|
142 |
+ " ii.fofoId, ii.sgstRate, ii.cgstRate, ii.igstRate," +
|
|
|
143 |
" cast(case when sio.creditTimestamp between :startDate and :endDate and sio.rolledBackTimestamp is null or sio.rolledBackTimestamp not between :startDate and :endDate then sio.amount " +
|
|
|
144 |
" when sio.creditTimestamp between :startDate and :endDate and sio.rolledBackTimestamp between :startDate and :endDate then 0" +
|
|
|
145 |
" when sio.creditTimestamp is not null and sio.rolledBackTimestamp between :startDate and :endDate then -sio.amount" +
|
| 33459 |
amit.gupta |
146 |
" else 0 end as float), ii.id, ii.serialNumber, s.name, p.purchaseReference, " +
|
| 32071 |
amit.gupta |
147 |
" case when sio.rolledBackTimestamp between :startDate and :endDate then sio.rolledBackTimestamp else sio.creditTimestamp end) from "
|
|
|
148 |
+ " SchemeInOut sio join Scheme s on s.id=sio.schemeId join InventoryItem ii on sio.inventoryItemId=ii.id join com.spice.profitmandi.dao.entity.fofo.Purchase p on p.id=ii.purchaseId"
|
| 34256 |
ranu |
149 |
+ " where sio.createTimestamp >= :cnDate and (:fofoId IS NULL OR ii.fofoId = :fofoId) and ((sio.creditTimestamp between :startDate and :endDate) or (sio.creditTimestamp is not null and sio.rolledBackTimestamp between :startDate and :endDate))")
|
| 29578 |
tejbeer |
150 |
})
|
| 27377 |
amit.gupta |
151 |
public class SchemeInOut implements Serializable {
|
|
|
152 |
|
| 32071 |
amit.gupta |
153 |
private static final long serialVersionUID = 1L;
|
|
|
154 |
@Id
|
|
|
155 |
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
|
156 |
private int id;
|
|
|
157 |
@Column(name = "scheme_id")
|
|
|
158 |
private int schemeId;
|
|
|
159 |
@Column(name = "inventory_item_id")
|
|
|
160 |
private int inventoryItemId;
|
|
|
161 |
@Column(name = "amount")
|
|
|
162 |
private float amount;
|
|
|
163 |
@Column(name = "status")
|
|
|
164 |
@Enumerated(EnumType.STRING)
|
|
|
165 |
private SchemePayoutStatus status;
|
|
|
166 |
@Column(name = "create_timestamp")
|
|
|
167 |
private LocalDateTime createTimestamp = LocalDateTime.now();
|
|
|
168 |
@Column(name = "rolled_back_timestamp")
|
|
|
169 |
private LocalDateTime rolledBackTimestamp;
|
|
|
170 |
@Column(name = "credit_timestamp")
|
|
|
171 |
private LocalDateTime creditTimestamp;
|
|
|
172 |
@Column(name = "description")
|
|
|
173 |
private String statusDescription;
|
|
|
174 |
@Transient
|
|
|
175 |
private int reference;
|
|
|
176 |
@Transient
|
|
|
177 |
private String serialNumber;
|
|
|
178 |
@Transient
|
|
|
179 |
private String storeCode;
|
|
|
180 |
@Transient
|
|
|
181 |
private SchemeType schemeType;
|
|
|
182 |
@Transient
|
|
|
183 |
private Scheme scheme;
|
| 22653 |
ashik.ali |
184 |
|
| 32071 |
amit.gupta |
185 |
public SchemeInOut(int schemeId, int inventoryItemId) {
|
|
|
186 |
this.schemeId = schemeId;
|
|
|
187 |
this.inventoryItemId = inventoryItemId;
|
|
|
188 |
}
|
| 27377 |
amit.gupta |
189 |
|
| 32071 |
amit.gupta |
190 |
public SchemeInOut() {
|
|
|
191 |
}
|
| 24592 |
amit.gupta |
192 |
|
| 32071 |
amit.gupta |
193 |
public int getId() {
|
|
|
194 |
return id;
|
|
|
195 |
}
|
| 24592 |
amit.gupta |
196 |
|
| 32071 |
amit.gupta |
197 |
public void setId(int id) {
|
|
|
198 |
this.id = id;
|
|
|
199 |
}
|
| 22653 |
ashik.ali |
200 |
|
| 32071 |
amit.gupta |
201 |
public SchemePayoutStatus getStatus() {
|
|
|
202 |
return status;
|
|
|
203 |
}
|
| 24592 |
amit.gupta |
204 |
|
| 32071 |
amit.gupta |
205 |
public void setStatus(SchemePayoutStatus status) {
|
|
|
206 |
this.status = status;
|
|
|
207 |
}
|
| 24592 |
amit.gupta |
208 |
|
| 32071 |
amit.gupta |
209 |
public LocalDateTime getCreditTimestamp() {
|
|
|
210 |
return creditTimestamp;
|
|
|
211 |
}
|
| 27377 |
amit.gupta |
212 |
|
| 32071 |
amit.gupta |
213 |
public void setCreditTimestamp(LocalDateTime creditTimestamp) {
|
|
|
214 |
this.creditTimestamp = creditTimestamp;
|
|
|
215 |
}
|
| 24592 |
amit.gupta |
216 |
|
| 32071 |
amit.gupta |
217 |
public String getStatusDescription() {
|
|
|
218 |
return statusDescription;
|
|
|
219 |
}
|
| 27377 |
amit.gupta |
220 |
|
| 32071 |
amit.gupta |
221 |
public void setStatusDescription(String statusDescription) {
|
|
|
222 |
this.statusDescription = statusDescription;
|
|
|
223 |
}
|
| 27377 |
amit.gupta |
224 |
|
| 32071 |
amit.gupta |
225 |
public int getReference() {
|
|
|
226 |
return reference;
|
|
|
227 |
}
|
| 27377 |
amit.gupta |
228 |
|
| 32071 |
amit.gupta |
229 |
public void setReference(int reference) {
|
|
|
230 |
this.reference = reference;
|
|
|
231 |
}
|
| 27377 |
amit.gupta |
232 |
|
| 32071 |
amit.gupta |
233 |
public Scheme getScheme() {
|
|
|
234 |
return scheme;
|
|
|
235 |
}
|
| 27377 |
amit.gupta |
236 |
|
| 32071 |
amit.gupta |
237 |
public void setScheme(Scheme scheme) {
|
|
|
238 |
this.scheme = scheme;
|
|
|
239 |
}
|
| 27377 |
amit.gupta |
240 |
|
| 32071 |
amit.gupta |
241 |
@Override
|
|
|
242 |
public String toString() {
|
|
|
243 |
return "SchemeInOut{" +
|
|
|
244 |
"id=" + id +
|
|
|
245 |
", schemeId=" + schemeId +
|
|
|
246 |
", inventoryItemId=" + inventoryItemId +
|
|
|
247 |
", amount=" + amount +
|
|
|
248 |
", status=" + status +
|
|
|
249 |
", createTimestamp=" + createTimestamp +
|
|
|
250 |
", rolledBackTimestamp=" + rolledBackTimestamp +
|
|
|
251 |
", creditTimestamp=" + creditTimestamp +
|
|
|
252 |
", statusDescription='" + statusDescription + '\'' +
|
|
|
253 |
", reference=" + reference +
|
|
|
254 |
", serialNumber='" + serialNumber + '\'' +
|
|
|
255 |
", storeCode='" + storeCode + '\'' +
|
|
|
256 |
", schemeType=" + schemeType +
|
|
|
257 |
", scheme=" + scheme +
|
|
|
258 |
'}';
|
|
|
259 |
}
|
| 27377 |
amit.gupta |
260 |
|
| 32071 |
amit.gupta |
261 |
@Override
|
|
|
262 |
public boolean equals(Object o) {
|
|
|
263 |
if (this == o) return true;
|
|
|
264 |
if (o == null || getClass() != o.getClass()) return false;
|
|
|
265 |
SchemeInOut that = (SchemeInOut) o;
|
|
|
266 |
return id == that.id && schemeId == that.schemeId && inventoryItemId == that.inventoryItemId && Float.compare(that.amount, amount) == 0 && reference == that.reference && status == that.status && Objects.equals(createTimestamp, that.createTimestamp) && Objects.equals(rolledBackTimestamp, that.rolledBackTimestamp) && Objects.equals(creditTimestamp, that.creditTimestamp) && Objects.equals(statusDescription, that.statusDescription) && Objects.equals(serialNumber, that.serialNumber) && Objects.equals(storeCode, that.storeCode) && schemeType == that.schemeType && Objects.equals(scheme, that.scheme);
|
|
|
267 |
}
|
| 27377 |
amit.gupta |
268 |
|
| 32071 |
amit.gupta |
269 |
@Override
|
|
|
270 |
public int hashCode() {
|
|
|
271 |
return Objects.hash(id, schemeId, inventoryItemId, amount, status, createTimestamp, rolledBackTimestamp, creditTimestamp, statusDescription, reference, serialNumber, storeCode, schemeType, scheme);
|
|
|
272 |
}
|
| 27377 |
amit.gupta |
273 |
|
| 32071 |
amit.gupta |
274 |
public String getStoreCode() {
|
|
|
275 |
return storeCode;
|
|
|
276 |
}
|
| 27377 |
amit.gupta |
277 |
|
| 32071 |
amit.gupta |
278 |
public void setStoreCode(String storeCode) {
|
|
|
279 |
this.storeCode = storeCode;
|
|
|
280 |
}
|
| 27377 |
amit.gupta |
281 |
|
| 32071 |
amit.gupta |
282 |
public SchemeType getSchemeType() {
|
|
|
283 |
return schemeType;
|
|
|
284 |
}
|
| 27377 |
amit.gupta |
285 |
|
| 32071 |
amit.gupta |
286 |
public void setSchemeType(SchemeType schemeType) {
|
|
|
287 |
this.schemeType = schemeType;
|
|
|
288 |
}
|
| 24671 |
amit.gupta |
289 |
|
| 32071 |
amit.gupta |
290 |
public String getSerialNumber() {
|
|
|
291 |
return serialNumber;
|
|
|
292 |
}
|
| 24671 |
amit.gupta |
293 |
|
| 32071 |
amit.gupta |
294 |
public void setSerialNumber(String serialNumber) {
|
|
|
295 |
this.serialNumber = serialNumber;
|
|
|
296 |
}
|
| 27377 |
amit.gupta |
297 |
|
| 32071 |
amit.gupta |
298 |
public int getSchemeId() {
|
|
|
299 |
return schemeId;
|
|
|
300 |
}
|
| 27377 |
amit.gupta |
301 |
|
| 32071 |
amit.gupta |
302 |
public void setSchemeId(int schemeId) {
|
|
|
303 |
this.schemeId = schemeId;
|
|
|
304 |
}
|
| 23509 |
amit.gupta |
305 |
|
| 32071 |
amit.gupta |
306 |
public int getInventoryItemId() {
|
|
|
307 |
return inventoryItemId;
|
|
|
308 |
}
|
| 31903 |
amit.gupta |
309 |
|
| 32071 |
amit.gupta |
310 |
public void setInventoryItemId(int inventoryItemId) {
|
|
|
311 |
this.inventoryItemId = inventoryItemId;
|
|
|
312 |
}
|
| 31903 |
amit.gupta |
313 |
|
| 32071 |
amit.gupta |
314 |
public float getAmount() {
|
|
|
315 |
return amount;
|
|
|
316 |
}
|
| 31903 |
amit.gupta |
317 |
|
| 32071 |
amit.gupta |
318 |
public void setAmount(float amount) {
|
|
|
319 |
this.amount = amount;
|
|
|
320 |
}
|
| 31903 |
amit.gupta |
321 |
|
| 32071 |
amit.gupta |
322 |
public LocalDateTime getCreateTimestamp() {
|
|
|
323 |
return createTimestamp;
|
|
|
324 |
}
|
| 31903 |
amit.gupta |
325 |
|
| 32071 |
amit.gupta |
326 |
public void setCreateTimestamp(LocalDateTime createTimestamp) {
|
|
|
327 |
this.createTimestamp = createTimestamp;
|
|
|
328 |
}
|
| 31903 |
amit.gupta |
329 |
|
| 32071 |
amit.gupta |
330 |
public LocalDateTime getRolledBackTimestamp() {
|
|
|
331 |
return rolledBackTimestamp;
|
|
|
332 |
}
|
| 24592 |
amit.gupta |
333 |
|
| 32071 |
amit.gupta |
334 |
public void setRolledBackTimestamp(LocalDateTime rolledBackTimestamp) {
|
|
|
335 |
this.rolledBackTimestamp = rolledBackTimestamp;
|
|
|
336 |
}
|
| 24592 |
amit.gupta |
337 |
|
| 22653 |
ashik.ali |
338 |
}
|