Skip to content

Commit

Permalink
OM-190: added mapping VoucherStatus from SOAP to system and viceversa
Browse files Browse the repository at this point in the history
  • Loading branch information
sniedzielski committed Aug 26, 2024
1 parent bd093c1 commit 987c34c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions msystems/views/vouchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from spyne.server.django import DjangoApplication
from spyne.service import ServiceBase
from zeep.exceptions import SignatureVerificationFailed
from msystems.soap.models import VoucherStatus

from msystems.apps import MsystemsConfig
from msystems.soap.datetime import SoapDatetime
Expand All @@ -19,6 +20,23 @@
namespace = 'https://mpay.gov.md'
logger = logging.getLogger(__name__)

_voucher_status_map_system_to_soap = {
WorkerVoucher.Status.ASSIGNED: VoucherStatus.Assigned,
WorkerVoucher.Status.AWAITING_PAYMENT: VoucherStatus.AwaitingPayment,
WorkerVoucher.Status.CANCELED: VoucherStatus.Canceled,
WorkerVoucher.Status.CLOSED: VoucherStatus.Closed,
WorkerVoucher.Status.EXPIRED: VoucherStatus.Expired,
WorkerVoucher.Status.UNASSIGNED: VoucherStatus.Unassigned,
}

_voucher_status_map_soap_to_system = {
VoucherStatus.Assigned: WorkerVoucher.Status.ASSIGNED,
VoucherStatus.AwaitingPayment: WorkerVoucher.Status.AWAITING_PAYMENT,
VoucherStatus.Canceled: WorkerVoucher.Status.CANCELED,
VoucherStatus.Closed: WorkerVoucher.Status.CLOSED,
VoucherStatus.Expired: WorkerVoucher.Status.EXPIRED,
VoucherStatus.Unassigned: WorkerVoucher.Status.UNASSIGNED,
}

def _get_vouchers(query: VouchersDetailsQuery):
vouchers = WorkerVoucher.objects.filter(is_deleted=False)
Expand All @@ -40,7 +58,7 @@ def _get_vouchers(query: VouchersDetailsQuery):
vouchers = vouchers.filter(code=query.VoucherCode)

if query.VoucherStatus:
vouchers = vouchers.filter(status=query.VoucherStatus)
vouchers = vouchers.filter(status=_voucher_status_map_soap_to_system[query.VoucherStatus])

return vouchers

Expand Down Expand Up @@ -97,7 +115,7 @@ def GetVouchersDetails(ctx, query: VouchersDetailsQuery) -> GetVouchersDetailsRe
EmployerCode=str(voucher.policyholder.code) if voucher.policyholder else None,
WorkerNationalID=str(voucher.insuree.chf_id) if voucher.insuree else None,
VoucherCode=str(voucher.code),
VoucherStatus=str(voucher.status),
VoucherStatus=_voucher_status_map_system_to_soap[voucher.status],
))

if not vouchers_details:
Expand Down

0 comments on commit 987c34c

Please sign in to comment.