Subversion Repositories SmartDukaan

Rev

Rev 32237 | Rev 33376 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 32237 Rev 33375
Line 70... Line 70...
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' and ii.fofoId = :fofoId and ii.createTimestamp >= :startDate and "
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' and ii.fofoId = :fofoId and ii.createTimestamp >= :startDate and "
71
                + "  ii.createTimestamp <= :endDate group by i.brand"),
71
                + "  ii.createTimestamp <= :endDate group by i.brand"),
72
 
72
 
73
 
73
 
74
        @NamedQuery(name = "SchemeInOut.selectLastMonthBrandWiseIncome", query = "select new com.spice.profitmandi.dao.model.LastMonthBrandWiseIncomeModel(" +
74
        @NamedQuery(name = "SchemeInOut.selectLastMonthBrandWiseIncome", query = "select new com.spice.profitmandi.dao.model.LastMonthBrandWiseIncomeModel(" +
75
                " i.brand,sum(case when sio.status = 'CREDITED' then cast(foi.quantity As int) else 0 end)," +
75
                " i.brand,sum(case when sio.status = 'CREDITED' then cast(sr.quantity As int) else 0 end)," +
76
                " sum(case when sio.status = 'CREDITED' then cast(sio.amount As float) else  0 end)," +
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)," +
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 "
78
                "i.catalogItemId,i.modelName,i.modelNumber) from ScanRecord sr join InventoryItem ii on ii.id=sr.inventoryItemId "
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  join  Item i on i.id=foi.itemId join Scheme sc on sc.id=sio.schemeId   where   sc.type != 'IN' and fo.cancelledTimestamp is null and "
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  join  Item i on i.id=foi.itemId join Scheme sc on sc.id=sio.schemeId   where   sc.type != 'IN' and fo.cancelledTimestamp is null and "
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"),
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"),
81
 
81
 
82
        @NamedQuery(name = "SchemeInOut.selectFrontIncomeBrandWise", query = "select new com.spice.profitmandi.dao.model.LastMonthFrontEndBrandWiseIncome(i.brand,sum(cast(foi.quantity As int)),sum(cast(foi.sellingPrice -foi.dp As float)),0.0,i.catalogItemId,i.modelName,i.modelNumber) "
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) "
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 "
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 "
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"),
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"),
85
 
85
 
86
        @NamedQuery(name = "SchemeInOut.selectLastMonthPurchaseBrandWiseIncome", query = "select new com.spice.profitmandi.dao.model.LastMonthBrandWiseIncomeModel( " +
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"
87
                "i.brand ,count(distinct ii.id),sum(cast(sio.amount As float)) ,0.0,i.catalogItemId,i.modelName,i.modelNumber) from"
Line 91... Line 91...
91
                " ii.createTimestamp <= :endDate group by i.catalogItemId,i.modelName,i.modelNumber,i.brand"),
91
                " ii.createTimestamp <= :endDate group by i.catalogItemId,i.modelName,i.modelNumber,i.brand"),
92
 
92
 
93
 
93
 
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)" +
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 "
95
                " from ScanRecord sr join InventoryItem ii on ii.id=sr.inventoryItemId "
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 "
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) "
97
                + "      join  Item i on i.id=foi.itemId join Scheme sc on sc.id=sio.schemeId   where   sc.type != 'IN' 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 "
97
                + "      join  Item i on i.id=foi.itemId join Scheme sc on sc.id=sio.schemeId   where   sc.type != 'IN' 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 "
98
                + "      i.catalogItemId= :catalogItemId and sr.fofoId = :fofoId"),
98
                + "      i.catalogItemId= :catalogItemId and sr.fofoId = :fofoId"),
99
 
99
 
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 "
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 "
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' and ii.fofoId = :fofoId and "
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' and ii.fofoId = :fofoId and "
Line 106... Line 106...
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 "
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 "
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"),
108
                + "     group by ii.id"),
109
 
109
 
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 "
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 "
111
                + "      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 "
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 )"
112
                + "      join  Item i on i.id=foi.itemId join Scheme sc on sc.id=sio.schemeId   where   sc.type != 'IN' and fo.cancelledTimestamp is null and (sio.status='CREDITED' or sio.status='PENDING') and sr.type='SALE' and "
112
                + "      join  Item i on i.id=foi.itemId join Scheme sc on sc.id=sio.schemeId   where   sc.type != 'IN' and fo.cancelledTimestamp is null and (sio.status='CREDITED' or sio.status='PENDING') and sr.type='SALE' and "
113
                + "      fli.serialNumber in :imeis and sr.fofoId = :fofoId"),
113
                + "      fli.serialNumber in :imeis and sr.fofoId = :fofoId"),
114
 
114
 
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 "
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 "
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' and ii.fofoId = :fofoId and "
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' and ii.fofoId = :fofoId and "
Line 126... Line 126...
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 "
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"),
127
                + "  and sr.type='SALE' and sr.createTimestamp >= :startDate and sr.createTimestamp <= :endDate and sr.fofoId = :fofoId group by foi.brand"),
128
 
128
 
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)) " +
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 "
130
                " from ScanRecord sr join InventoryItem ii on ii.id=sr.inventoryItemId "
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  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 "
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 "
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"),
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"),
133
 
133
 
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 " +
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 "
135
                " ScanRecord sr join InventoryItem ii on ii.id=sr.inventoryItemId "
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 "
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) "
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 "
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"),
138
                + "      i.catalogItemId= :catalogItemId and sr.fofoId = :fofoId group by fli.serialNumber"),
139
 
139
 
140
 
140
 
141
        @NamedQuery(name = "SchemeInOut.selectPaidMargins", query = "select new com.spice.profitmandi.service.transaction.InventoryMarginModel("
141
        @NamedQuery(name = "SchemeInOut.selectPaidMargins", query = "select new com.spice.profitmandi.service.transaction.InventoryMarginModel("