def test_match_payment_simple(self): officer = create_test_officer(custom_props={"code": "TSTSIMP1"}) insuree = create_test_insuree(custom_props={"chf_id": "paysimp"}) product = create_test_product("ELI1") (policy, insuree_policy) = create_test_policy2(product, insuree, custom_props={ "value": 1000, "status": Policy.STATUS_IDLE}) service = create_test_service("A") svc_pl_detail = add_service_to_hf_pricelist(service) product_service = create_test_product_service(product, service, custom_props={"limit_no_adult": 20}) premium = create_test_premium(policy_id=policy.id, with_payer=False) payment, payment_detail = create_test_payment2( insuree_code=insuree.chf_id, product_code=product.code, officer_code=officer.code, ) match_payment(payment=payment, audit_user_id=-1) payment_detail.refresh_from_db() self.assertEqual(payment_detail.premium, premium) payment_detail.delete() payment.delete() premium.delete() product_service.delete() svc_pl_detail.delete() service.delete() policy.insuree_policies.all().delete() policy.delete() product.delete() insuree.delete() officer.delete()
def test_validate_no_insuree(self): officer = create_test_officer(custom_props={"code": "TSTSIMP1"}) insuree = create_test_insuree(custom_props={"chf_id": "paysimp"}) product = create_test_product("ELI1") (policy, insuree_policy) = create_test_policy2(product, insuree, custom_props={ "value": 1000, "status": Policy.STATUS_IDLE}) service = create_test_service("A") svc_pl_detail = add_service_to_hf_pricelist(service) product_service = create_test_product_service(product, service, custom_props={"limit_no_adult": 20}) premium = create_test_premium(policy_id=policy.id, with_payer=False) payment, payment_detail = create_test_payment2( insuree_code=None, product_code=product.code, officer_code=officer.code, ) errors = validate_payment_detail(payment_detail) self.assertGreater(len(errors), 0) self.assertEqual(errors[0]["code"], PAYMENT_DETAIL_REJECTION_INSURANCE_NB) payment_detail.delete() payment.delete() premium.delete() product_service.delete() svc_pl_detail.delete() service.delete() policy.insuree_policies.all().delete() policy.delete() product.delete() insuree.delete() officer.delete()
def test_simple_monthly_batch_run(self) -> None: insuree1 = create_test_insuree() self.assertIsNotNone(insuree1) product = create_test_product("TEST1", custom_props={ "location_id": 1, "period_rel_prices": 4 }) policy = create_test_policy(product, insuree1, link=True) service = create_test_service("V") product_service = create_test_product_service( product, service, custom_props={"price_origin": ProductService.ORIGIN_RELATIVE}) pricelist_detail = add_service_to_hf_pricelist(service) premium = create_test_premium(policy_id=policy.id, with_payer=True) create_test_rel_distr_range(product.id, RelativeDistribution.TYPE_QUARTER, RelativeDistribution.CARE_TYPE_BOTH, 10) claim1 = create_test_claim({"insuree_id": insuree1.id}) service1 = create_test_claimservice(claim1, custom_props={ "service_id": service.id, "price_origin": ProductService.ORIGIN_RELATIVE, "product": product }) errors = validate_claim(claim1, True) self.assertEquals(len(errors), 0) errors = validate_assign_prod_to_claimitems_and_services(claim1) self.assertEquals(len(errors), 0) _mark_as_processed(claim1) claim1.refresh_from_db() result = process_batch(1, location_id=1, period=6, year=2019) # tearDown premium.delete() premium.payer.delete() service1.delete() claim1.delete() policy.insuree_policies.first().delete() policy.delete() product_service.delete() pricelist_detail.delete() service.delete() for rd in product.relative_distributions.all(): rd.delete() product.delete()
def test_validate_invalid_product_location(self): location_r1 = Location.filter_queryset().get(code="R1") location_r2 = Location.filter_queryset().get(code="R2") officer = create_test_officer(custom_props={"code": "TSTSIMP1"}) insuree = create_test_insuree(custom_props={"chf_id": "paysimp"}, family_custom_props={"location": location_r1}) # Family in R1 ! product = create_test_product("ELI1", custom_props={"location": location_r2}) # Product in R2 ! (policy, insuree_policy) = create_test_policy2( product, insuree, custom_props={"value": 1000, "status": Policy.STATUS_IDLE}) service = create_test_service("A") svc_pl_detail = add_service_to_hf_pricelist(service) product_service = create_test_product_service(product, service, custom_props={"limit_no_adult": 20}) premium = create_test_premium(policy_id=policy.id, with_payer=False) payment, payment_detail = create_test_payment2( insuree_code=insuree.chf_id, product_code=product.code, officer_code=officer.code, ) errors = validate_payment_detail(payment_detail) self.assertGreater(len(errors), 0) self.assertEqual(errors[0]["code"], PAYMENT_DETAIL_REJECTION_PRODUCT_NOT_ALLOWED) payment_detail.delete() payment.delete() premium.delete() product_service.delete() svc_pl_detail.delete() service.delete() policy.insuree_policies.all().delete() policy.delete() product.delete() insuree.delete() officer.delete()