@@ -38,6 +38,9 @@ public void Save(PolicyDocument policy)
3838 new StringField ( "agentLogin" , policy . AgentLogin ?? string . Empty , Field . Store . YES ) ,
3939 new StringField ( "productCode" , policy . ProductCode ?? string . Empty , Field . Store . YES ) ,
4040 new StringField ( "from" , policy . From . ToString ( "o" , CultureInfo . InvariantCulture ) , Field . Store . YES ) ,
41+ new StringField ( "to" , policy . To . ToString ( "o" , CultureInfo . InvariantCulture ) , Field . Store . YES ) ,
42+ new StringField ( "salesDate" , policy . SalesDate . ToString ( "o" , CultureInfo . InvariantCulture ) , Field . Store . YES ) ,
43+ new StringField ( "policyHolder" , policy . PolicyHolder ?? string . Empty , Field . Store . YES ) ,
4144 new DoubleField ( "totalPremium" , Convert . ToDouble ( policy . TotalPremium ) , Field . Store . YES )
4245 } ;
4346
@@ -94,7 +97,7 @@ public SalesTrendsResult GetSalesTrend(SalesTrendsQuery query)
9497 var docs = SearchByFilters ( null , query . FilterByProductCode , query . FilterBySalesDateStart , query . FilterBySalesDateEnd ) ;
9598 var periods = docs . GroupBy ( d =>
9699 {
97- var dt = DateTime . Parse ( d . Get ( "from " ) , null , DateTimeStyles . RoundtripKind ) ;
100+ var dt = DateTime . Parse ( d . Get ( "salesDate " ) , null , DateTimeStyles . RoundtripKind ) ;
98101 return query . AggregationUnit switch
99102 {
100103 TimeAggregationUnit . Month => new DateTime ( dt . Year , dt . Month , 1 ) ,
@@ -145,7 +148,7 @@ private IEnumerable<Document> SearchByFilters(string agentLogin, string productC
145148 {
146149 docs = docs . Where ( d =>
147150 {
148- var dt = DateTime . Parse ( d . Get ( "from " ) , null , DateTimeStyles . RoundtripKind ) ;
151+ var dt = DateTime . Parse ( d . Get ( "salesDate " ) , null , DateTimeStyles . RoundtripKind ) ;
149152 if ( fromDate != default && dt < fromDate ) return false ;
150153 if ( toDate != default && dt > toDate ) return false ;
151154 return true ;
@@ -159,13 +162,14 @@ private static PolicyDocument DocToPolicy(Document doc)
159162 {
160163 var number = doc . Get ( "number" ) ;
161164 var from = DateTime . Parse ( doc . Get ( "from" ) , null , DateTimeStyles . RoundtripKind ) ;
162- var to = from . AddYears ( 1 ) . AddDays ( - 1 ) ;
163- var insured = doc . Get ( "insuredName" ) ;
165+ var to = DateTime . Parse ( doc . Get ( "to" ) , null , DateTimeStyles . RoundtripKind ) ;
166+ var salesDate = DateTime . Parse ( doc . Get ( "salesDate" ) , null , DateTimeStyles . RoundtripKind ) ;
167+ var insured = doc . Get ( "policyHolder" ) ;
164168 var product = doc . Get ( "productCode" ) ;
165169 var premium = Convert . ToDecimal ( doc . Get ( "totalPremium" ) ) ;
166170 var agent = doc . Get ( "agentLogin" ) ;
167171
168- return new PolicyDocument ( number , from , to , insured , product , premium , agent ) ;
172+ return new PolicyDocument ( number , from , to , salesDate , insured , product , premium , agent ) ;
169173 }
170174
171175 public void Dispose ( )
0 commit comments