@@ -3173,7 +3173,8 @@ private Family familyFromJSONObject(
31733173 /* confirmationNumber = */ JsonUtils .getStringOrDefault (json , "ConfirmationNo" ),
31743174 /* confirmationType = */ JsonUtils .getStringOrDefault (json , "ConfirmationType" ),
31753175 /* isOffline = */ JsonUtils .getBooleanOrDefault (json , "isOffline" , false ),
3176- /* members = */ members
3176+ /* members = */ members ,
3177+ null
31773178 );
31783179 }
31793180
@@ -4722,6 +4723,7 @@ public int ModifyFamily(final String insuranceNumber) {
47224723 Family family = new FetchFamily ().execute (insuranceNumber );
47234724 InsertFamilyDataFromOnline (family );
47244725 InsertInsureeDataFromOnline (family .getMembers ());
4726+ InsertPolicyDataFromOnline (family .getPolicies ());
47254727 return 1 ;
47264728 } catch (Exception e ) {
47274729 Log .e ("MODIFYFAMILY" , "Error while downloading a family" , e );
@@ -4793,6 +4795,22 @@ private void InsertInsureeDataFromOnline(@NonNull List<Family.Member> members) t
47934795 sqlHandler .insertData ("tblInsuree" , Columns , array , "" );
47944796 }
47954797
4798+ private void InsertPolicyDataFromOnline (@ NonNull List <Family .Policy > policies ) throws JSONException {
4799+ JSONArray array = new JSONArray ();
4800+ for (Family .Policy policy : policies ) {
4801+ @ Language ("SQL" )
4802+ String QueryCheck = "SELECT PolicyId FROM tblPolicy WHERE PolicyId = " + policy .getId ();
4803+ if (sqlHandler .getResult (QueryCheck , null ).length () == 0 ) {
4804+ array .put (toPolicyJSONObject (policy ));
4805+ }
4806+ }
4807+ String [] Columns = {"PolicyId" , "FamilyId" , "EnrollDate" , "StartDate" , "EffectiveDate" , "ExpiryDate" , "PolicyStatus" ,
4808+ "PolicyValue" , "ProdId" , "OfficerId" , "IsOffline" };
4809+ final String [] policyColumns ;
4810+ policyColumns = Columns ;
4811+ sqlHandler .insertData ("tblPolicy" , policyColumns , array , "" );
4812+ }
4813+
47964814 @ NonNull
47974815 private JSONObject toJSONObject (@ NonNull Family .Member member ) throws JSONException {
47984816 JSONObject jsonObject = new JSONObject ();
@@ -4824,6 +4842,23 @@ private JSONObject toJSONObject(@NonNull Family.Member member) throws JSONExcept
48244842 return jsonObject ;
48254843 }
48264844
4845+ @ NonNull
4846+ private JSONObject toPolicyJSONObject (Family .Policy policy ) throws JSONException {
4847+ JSONObject policyObject = new JSONObject ();
4848+ policyObject .put ("PolicyId" ,policy .getId ());
4849+ policyObject .put ("FamilyId" ,policy .getFamilyId ());
4850+ policyObject .put ("EnrollDate" ,policy .getEnrollDate ());
4851+ policyObject .put ("StartDate" ,DateUtils .toDateString (Objects .requireNonNull (policy .getStartDate ())));
4852+ policyObject .put ("EffectiveDate" , DateUtils .toDateString (Objects .requireNonNull (policy .getEffectiveDate ())));
4853+ policyObject .put ("ExpiryDate" , DateUtils .toDateString (Objects .requireNonNull (policy .getExpiryDate ())));
4854+ policyObject .put ("PolicyStatus" ,policy .getStatus ());
4855+ policyObject .put ("PolicyValue" ,policy .getValue ());
4856+ policyObject .put ("ProdId" ,policy .getProductId ());
4857+ policyObject .put ("OfficerId" ,policy .getOfficerId ());
4858+ policyObject .put ("IsOffline" ,false );
4859+ return policyObject ;
4860+ }
4861+
48274862 //****************************Online Statistics ******************************//
48284863 @ JavascriptInterface
48294864 @ SuppressWarnings ("unused" )
0 commit comments