Subversion Repositories SmartDukaan

Rev

Rev 37008 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
37008 amit 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(ii.unitPrice-ii.priceDropAmount As int ))) "
32071 amit.gupta 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
 
37008 amit 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 -(ii.unitPrice-ii.priceDropAmount) 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
 
37009 amit 105
        @NamedQuery(name = "SchemeInOut.selectLastMonthFrontEndImei", query = "select new com.spice.profitmandi.dao.model.LastMonthFrontEndImeiModel( ii.serialNumber,foi.sellingPrice, ii.unitPrice-ii.priceDropAmount) from InventoryItem ii "
32071 amit.gupta 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
 
36508 ranu 141
        @NamedQuery(name = "SchemeInOut.selectSchemeEarningsByFofoId",
142
                query = "select new com.spice.profitmandi.dao.model.SchemeEarningModel("
36525 ranu 143
                        + " s.id, s.name, s.description, i.brand, count(distinct ii.id), sum(sio.amount))"
144
                        + " from SchemeInOut sio"
145
                        + " join Scheme s on s.id=sio.schemeId"
36508 ranu 146
                        + " join InventoryItem ii on ii.id=sio.inventoryItemId"
147
                        + " join Item i on i.id=ii.itemId"
148
                        + " where ii.fofoId = :fofoId"
36525 ranu 149
                        + " and sio.status = 'CREDITED'"
36508 ranu 150
                        + " and sio.rolledBackTimestamp is null"
36525 ranu 151
                        + " and sio.creditTimestamp >= :startDate and sio.creditTimestamp <= :endDate"
36508 ranu 152
                        + " group by s.id, s.name, s.description, i.brand"),
153
 
32071 amit.gupta 154
        @NamedQuery(name = "SchemeInOut.selectPaidMargins", query = "select new com.spice.profitmandi.service.transaction.InventoryMarginModel("
155
                + " ii.fofoId, ii.sgstRate, ii.cgstRate, ii.igstRate," +
36485 amit 156
                " cast(case when sio.creditTimestamp >= :startDate and sio.creditTimestamp <= :endDate then sio.amount " +
157
                "			when sio.creditTimestamp is not null and sio.rolledBackTimestamp >= :startDate and sio.rolledBackTimestamp <= :endDate then -sio.amount" +
33459 amit.gupta 158
                "			else 0 end as float), ii.id, ii.serialNumber, s.name, p.purchaseReference, " +
36485 amit 159
                " case when sio.rolledBackTimestamp >= :startDate and sio.rolledBackTimestamp <= :endDate then sio.rolledBackTimestamp else sio.creditTimestamp end, ii.hsnCode)  from "
32071 amit.gupta 160
                + " 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"
36485 amit 161
                + " where sio.createTimestamp >= :cnDate and (:fofoId IS NULL OR ii.fofoId = :fofoId) and ((sio.creditTimestamp >= :startDate and sio.creditTimestamp <= :endDate) or (sio.creditTimestamp is not null and sio.rolledBackTimestamp >= :startDate and sio.rolledBackTimestamp <= :endDate))"
36489 amit 162
                + " and not (sio.rolledBackTimestamp is not null and sio.creditTimestamp >= :startDate and sio.creditTimestamp <= :endDate and sio.rolledBackTimestamp >= :startDate and sio.rolledBackTimestamp <= :endDate)")
29578 tejbeer 163
})
27377 amit.gupta 164
public class SchemeInOut implements Serializable {
165
 
32071 amit.gupta 166
    private static final long serialVersionUID = 1L;
167
    @Id
168
    @GeneratedValue(strategy = GenerationType.IDENTITY)
169
    private int id;
170
    @Column(name = "scheme_id")
171
    private int schemeId;
172
    @Column(name = "inventory_item_id")
173
    private int inventoryItemId;
174
    @Column(name = "amount")
175
    private float amount;
176
    @Column(name = "status")
177
    @Enumerated(EnumType.STRING)
178
    private SchemePayoutStatus status;
179
    @Column(name = "create_timestamp")
180
    private LocalDateTime createTimestamp = LocalDateTime.now();
181
    @Column(name = "rolled_back_timestamp")
182
    private LocalDateTime rolledBackTimestamp;
183
    @Column(name = "credit_timestamp")
184
    private LocalDateTime creditTimestamp;
185
    @Column(name = "description")
186
    private String statusDescription;
187
    @Transient
188
    private int reference;
189
    @Transient
190
    private String serialNumber;
191
    @Transient
192
    private String storeCode;
193
    @Transient
194
    private SchemeType schemeType;
195
    @Transient
196
    private Scheme scheme;
22653 ashik.ali 197
 
32071 amit.gupta 198
    public SchemeInOut(int schemeId, int inventoryItemId) {
199
        this.schemeId = schemeId;
200
        this.inventoryItemId = inventoryItemId;
201
    }
27377 amit.gupta 202
 
32071 amit.gupta 203
    public SchemeInOut() {
204
    }
24592 amit.gupta 205
 
32071 amit.gupta 206
    public int getId() {
207
        return id;
208
    }
24592 amit.gupta 209
 
32071 amit.gupta 210
    public void setId(int id) {
211
        this.id = id;
212
    }
22653 ashik.ali 213
 
32071 amit.gupta 214
    public SchemePayoutStatus getStatus() {
215
        return status;
216
    }
24592 amit.gupta 217
 
32071 amit.gupta 218
    public void setStatus(SchemePayoutStatus status) {
219
        this.status = status;
220
    }
24592 amit.gupta 221
 
32071 amit.gupta 222
    public LocalDateTime getCreditTimestamp() {
223
        return creditTimestamp;
224
    }
27377 amit.gupta 225
 
32071 amit.gupta 226
    public void setCreditTimestamp(LocalDateTime creditTimestamp) {
227
        this.creditTimestamp = creditTimestamp;
228
    }
24592 amit.gupta 229
 
32071 amit.gupta 230
    public String getStatusDescription() {
231
        return statusDescription;
232
    }
27377 amit.gupta 233
 
32071 amit.gupta 234
    public void setStatusDescription(String statusDescription) {
235
        this.statusDescription = statusDescription;
236
    }
27377 amit.gupta 237
 
32071 amit.gupta 238
    public int getReference() {
239
        return reference;
240
    }
27377 amit.gupta 241
 
32071 amit.gupta 242
    public void setReference(int reference) {
243
        this.reference = reference;
244
    }
27377 amit.gupta 245
 
32071 amit.gupta 246
    public Scheme getScheme() {
247
        return scheme;
248
    }
27377 amit.gupta 249
 
32071 amit.gupta 250
    public void setScheme(Scheme scheme) {
251
        this.scheme = scheme;
252
    }
27377 amit.gupta 253
 
32071 amit.gupta 254
    @Override
255
    public String toString() {
256
        return "SchemeInOut{" +
257
                "id=" + id +
258
                ", schemeId=" + schemeId +
259
                ", inventoryItemId=" + inventoryItemId +
260
                ", amount=" + amount +
261
                ", status=" + status +
262
                ", createTimestamp=" + createTimestamp +
263
                ", rolledBackTimestamp=" + rolledBackTimestamp +
264
                ", creditTimestamp=" + creditTimestamp +
265
                ", statusDescription='" + statusDescription + '\'' +
266
                ", reference=" + reference +
267
                ", serialNumber='" + serialNumber + '\'' +
268
                ", storeCode='" + storeCode + '\'' +
269
                ", schemeType=" + schemeType +
270
                ", scheme=" + scheme +
271
                '}';
272
    }
27377 amit.gupta 273
 
32071 amit.gupta 274
    @Override
275
    public boolean equals(Object o) {
276
        if (this == o) return true;
277
        if (o == null || getClass() != o.getClass()) return false;
278
        SchemeInOut that = (SchemeInOut) o;
279
        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);
280
    }
27377 amit.gupta 281
 
32071 amit.gupta 282
    @Override
283
    public int hashCode() {
284
        return Objects.hash(id, schemeId, inventoryItemId, amount, status, createTimestamp, rolledBackTimestamp, creditTimestamp, statusDescription, reference, serialNumber, storeCode, schemeType, scheme);
285
    }
27377 amit.gupta 286
 
32071 amit.gupta 287
    public String getStoreCode() {
288
        return storeCode;
289
    }
27377 amit.gupta 290
 
32071 amit.gupta 291
    public void setStoreCode(String storeCode) {
292
        this.storeCode = storeCode;
293
    }
27377 amit.gupta 294
 
32071 amit.gupta 295
    public SchemeType getSchemeType() {
296
        return schemeType;
297
    }
27377 amit.gupta 298
 
32071 amit.gupta 299
    public void setSchemeType(SchemeType schemeType) {
300
        this.schemeType = schemeType;
301
    }
24671 amit.gupta 302
 
32071 amit.gupta 303
    public String getSerialNumber() {
304
        return serialNumber;
305
    }
24671 amit.gupta 306
 
32071 amit.gupta 307
    public void setSerialNumber(String serialNumber) {
308
        this.serialNumber = serialNumber;
309
    }
27377 amit.gupta 310
 
32071 amit.gupta 311
    public int getSchemeId() {
312
        return schemeId;
313
    }
27377 amit.gupta 314
 
32071 amit.gupta 315
    public void setSchemeId(int schemeId) {
316
        this.schemeId = schemeId;
317
    }
23509 amit.gupta 318
 
32071 amit.gupta 319
    public int getInventoryItemId() {
320
        return inventoryItemId;
321
    }
31903 amit.gupta 322
 
32071 amit.gupta 323
    public void setInventoryItemId(int inventoryItemId) {
324
        this.inventoryItemId = inventoryItemId;
325
    }
31903 amit.gupta 326
 
32071 amit.gupta 327
    public float getAmount() {
328
        return amount;
329
    }
31903 amit.gupta 330
 
32071 amit.gupta 331
    public void setAmount(float amount) {
332
        this.amount = amount;
333
    }
31903 amit.gupta 334
 
32071 amit.gupta 335
    public LocalDateTime getCreateTimestamp() {
336
        return createTimestamp;
337
    }
31903 amit.gupta 338
 
32071 amit.gupta 339
    public void setCreateTimestamp(LocalDateTime createTimestamp) {
340
        this.createTimestamp = createTimestamp;
341
    }
31903 amit.gupta 342
 
32071 amit.gupta 343
    public LocalDateTime getRolledBackTimestamp() {
344
        return rolledBackTimestamp;
345
    }
24592 amit.gupta 346
 
32071 amit.gupta 347
    public void setRolledBackTimestamp(LocalDateTime rolledBackTimestamp) {
348
        this.rolledBackTimestamp = rolledBackTimestamp;
349
    }
24592 amit.gupta 350
 
22653 ashik.ali 351
}