diff --git a/README.md b/README.md index bdf0e1c..5ac89fe 100644 --- a/README.md +++ b/README.md @@ -107,18 +107,15 @@ The `VouchersDetailsQuery` complex model allows filtering vouchers based on vari ### Example Request ```xml - - - - - - 2024-08-20T00:00:00Z - CC - AwaitingPayment - - + + + + 2024-08-20T00:00:00Z + CC + AwaitingPayment + + - ``` ### Example Response @@ -184,9 +181,11 @@ If no vouchers match the provided criteria, the service will return a SOAP fault ### Filtering by `VoucherCode` **Request:** ```xml - - 123e4567-e89b-12d3-a456-426614174000 - + + + 123e4567-e89b-12d3-a456-426614174000 + + ``` **Description:** This request retrieves the details of a specific voucher identified by the VoucherCode `123e4567-e89b-12d3-a456-426614174000`. @@ -194,10 +193,12 @@ This request retrieves the details of a specific voucher identified by the Vouch ### Filtering by WorkerNationalID and ExpiryDate **Request:** ```xml - - 111111111111 - 2024-12-31T00:00:00Z - + + + 111111111111 + 2024-12-31T00:00:00Z + + ``` **Description:** This request fetches all vouchers assigned to the worker with the National ID `111111111111` that are set to expire on `2024-12-31`. @@ -205,10 +206,12 @@ This request fetches all vouchers assigned to the worker with the National ID `1 ### Filtering by WorkerNationalID and VoucherCode **Request:** ```xml - - 111111111111 - 123e4567-e89b-12d3-a456-426614174000 - + + + 111111111111 + 123e4567-e89b-12d3-a456-426614174000 + + ``` **Description:** This request retrieves the details for a voucher identified by VoucherCode `123e4567-e89b-12d3-a456-426614174000`, assigned to the worker with National ID `111111111111`. @@ -216,10 +219,12 @@ This request retrieves the details for a voucher identified by VoucherCode `123e ### Filtering by Status and ExpiryDate **Request:** ```xml - - Expired - 2023-12-31T00:00:00Z - + + + Expired + 2023-12-31T00:00:00Z + + ``` **Description:** This request fetches all vouchers that are `Expired` as of `2023-12-31`. \ No newline at end of file diff --git a/msystems/views/vouchers.py b/msystems/views/vouchers.py index 35cbb7d..28b1ade 100644 --- a/msystems/views/vouchers.py +++ b/msystems/views/vouchers.py @@ -49,10 +49,10 @@ def _get_vouchers(query: VouchersDetailsQuery): vouchers = vouchers.filter(expiry_date=query.ExpiryDate) if query.EmployerCode: - vouchers = vouchers.filter(policyholder__code=query.EmployerCode) + vouchers = vouchers.filter(policyholder__code=query.EmployerCode, policyholder__is_deleted=False) if query.WorkerNationalID: - vouchers = vouchers.filter(insuree__chf_id=query.WorkerNationalID) + vouchers = vouchers.filter(insuree__chf_id=query.WorkerNationalID, insuree__validity_to__isnull=True) if query.VoucherCode: vouchers = vouchers.filter(code=query.VoucherCode)