Skip to content

Commit

Permalink
OM-190: fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
sniedzielski committed Aug 27, 2024
1 parent ddbaa65 commit 7b0a3e3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
57 changes: 31 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,15 @@ The `VouchersDetailsQuery` complex model allows filtering vouchers based on vari
### Example Request

```xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="https://mpay.gov.md">
<soapenv:Header/>
<soapenv:Body>
<tns:GetVouchersDetails>
<tns:VouchersDetailsQuery>
<tns:AssignedDate>2024-08-20T00:00:00Z</tns:AssignedDate>
<tns:EmployerCode>CC</tns:EmployerCode>
<tns:VoucherStatus>AwaitingPayment</tns:VoucherStatus>
</tns:VouchersDetailsQuery>
</tns:GetVouchersDetails>
<soap-env:Body>
<ns0:GetVouchersDetails xmlns:ns0="https://mpay.gov.md">
<ns0:query>
<ns0:AssignedDate>2024-08-20T00:00:00Z</ns0:AssignedDate>
<ns0:EmployerCode>CC</ns0:EmployerCode>
<ns0:VoucherStatus>AwaitingPayment</ns0:VoucherStatus>
</tns:query>
</ns0:GetVouchersDetails>
</soapenv:Body>
</soapenv:Envelope>
```

### Example Response
Expand Down Expand Up @@ -184,42 +181,50 @@ If no vouchers match the provided criteria, the service will return a SOAP fault
### Filtering by `VoucherCode`
**Request:**
```xml
<tns:VouchersDetailsQuery xmlns:tns="https://mpay.gov.md">
<tns:VoucherCode>123e4567-e89b-12d3-a456-426614174000</tns:VoucherCode>
</tns:VouchersDetailsQuery>
<ns0:GetVouchersDetails xmlns:ns0="https://mpay.gov.md">
<ns0:query>
<ns0:VoucherCode>123e4567-e89b-12d3-a456-426614174000</ns0:VoucherCode>
</ns0:query>
</ns0:GetVouchersDetails>
```
**Description:**
This request retrieves the details of a specific voucher identified by the VoucherCode `123e4567-e89b-12d3-a456-426614174000`.

### Filtering by WorkerNationalID and ExpiryDate
**Request:**
```xml
<tns:VouchersDetailsQuery xmlns:tns="https://mpay.gov.md">
<tns:WorkerNationalID>111111111111</tns:WorkerNationalID>
<tns:ExpiryDate>2024-12-31T00:00:00Z</tns:ExpiryDate>
</tns:VouchersDetailsQuery>
<ns0:GetVouchersDetails xmlns:ns0="https://mpay.gov.md">
<ns0:query>
<ns0:WorkerNationalID>111111111111</ns0:WorkerNationalID>
<ns0:ExpiryDate>2024-12-31T00:00:00Z</ns0:ExpiryDate>
</ns0:query>
</ns0:GetVouchersDetails>
```
**Description:**
This request fetches all vouchers assigned to the worker with the National ID `111111111111` that are set to expire on `2024-12-31`.

### Filtering by WorkerNationalID and VoucherCode
**Request:**
```xml
<tns:VouchersDetailsQuery xmlns:tns="https://mpay.gov.md">
<tns:WorkerNationalID>111111111111</tns:WorkerNationalID>
<tns:VoucherCode>123e4567-e89b-12d3-a456-426614174000</tns:VoucherCode>
</tns:VouchersDetailsQuery>
<ns0:GetVouchersDetails xmlns:ns0="https://mpay.gov.md">
<ns0:query>
<ns0:WorkerNationalID>111111111111</ns0:WorkerNationalID>
<ns0:VoucherCode>123e4567-e89b-12d3-a456-426614174000</ns0:VoucherCode>
</ns0:query>
</ns0:GetVouchersDetails>
```
**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`.

### Filtering by Status and ExpiryDate
**Request:**
```xml
<tns:VouchersDetailsQuery xmlns:tns="https://mpay.gov.md">
<tns:Status>Expired</tns:Status>
<tns:ExpiryDate>2023-12-31T00:00:00Z</tns:ExpiryDate>
</tns:VouchersDetailsQuery>
<ns0:GetVouchersDetails xmlns:ns0="https://mpay.gov.md">
<ns0:query>
<ns0:Status>Expired</ns0:Status>
<ns0:ExpiryDate>2023-12-31T00:00:00Z</ns0:ExpiryDate>
</ns0:query>
</ns0:GetVouchersDetails>
```
**Description:**
This request fetches all vouchers that are `Expired` as of `2023-12-31`.
4 changes: 2 additions & 2 deletions msystems/views/vouchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7b0a3e3

Please sign in to comment.