Skip to content

Commit

Permalink
feat: Fee Updates for host application (#235)
Browse files Browse the repository at this point in the history
* feat: New fee codes for host application

* no message

* no message
  • Loading branch information
kris-daxiom authored Oct 28, 2024
1 parent 1e8e243 commit 06f3e18
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion strr-api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "strr-api"
version = "0.0.17"
version = "0.0.18"
description = ""
authors = ["thorwolpert <[email protected]>"]
license = "BSD 3-Clause"
Expand Down
52 changes: 41 additions & 11 deletions strr-api/src/strr_api/services/payment_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@

from strr_api.enums.enum import RegistrationType
from strr_api.exceptions import ExternalServiceException
from strr_api.models import Application, Events
from strr_api.models import Application, Events, RentalProperty
from strr_api.services.events_service import EventsService
from strr_api.services.user_service import UserService

HOST_REGISTRATION_FEE_2 = "HOSTREG_2"

HOST_REGISTRATION_FEE_1 = "HOSTREG_1"

PLATFORM_SMALL_USER_BASE = "PLATREG_SM"

PLATFORM_LARGE_USER_BASE = "PLATREG_LG"
Expand Down Expand Up @@ -110,20 +114,15 @@ def create_invoice(self, user_jwt: JwtManager, account_id, application=None):

def _get_payment_request(self, application_json):
filing_type = None
quantity = 1
registration_json = application_json.get("registration", {})
registration_type = registration_json.get("registrationType")
if registration_type == RegistrationType.HOST.value:
filing_type = "RENTAL_FEE"
if registration_type == RegistrationType.PLATFORM.value:
cpbc_number = registration_json.get("businessDetails").get("consumerProtectionBCLicenceNumber")
if cpbc_number and (not cpbc_number.isspace()):
filing_type = PLATFORM_FEE_WAIVED
elif registration_json.get("platformDetails").get("listingSize") == "GREATER_THAN_THOUSAND":
filing_type = PLATFORM_LARGE_USER_BASE
else:
filing_type = PLATFORM_SMALL_USER_BASE
filing_type, quantity = self._get_host_filing_type(registration_json)
elif registration_type == RegistrationType.PLATFORM.value:
filing_type = self._get_platform_filing_type(registration_json)

filing_type_dict = {"filingTypeCode": filing_type}
filing_type_dict = {"filingTypeCode": filing_type, "quantity": quantity}

# Workaround to charge the service fee when the filing fee is 0.
if filing_type == PLATFORM_FEE_WAIVED:
Expand All @@ -139,6 +138,37 @@ def _get_payment_request(self, application_json):

return payload

def _get_platform_filing_type(self, registration_json):
cpbc_number = registration_json.get("businessDetails").get("consumerProtectionBCLicenceNumber")
if cpbc_number and (not cpbc_number.isspace()):
filing_type = PLATFORM_FEE_WAIVED
elif registration_json.get("platformDetails").get("listingSize") == "GREATER_THAN_THOUSAND":
filing_type = PLATFORM_LARGE_USER_BASE
else:
filing_type = PLATFORM_SMALL_USER_BASE
return filing_type

def _get_host_filing_type(self, registration_json):
quantity = 1
filing_type = None
rental_unit_space_type = registration_json.get("unitDetails").get("rentalUnitSpaceType")
is_rental_unit_on_principal_residence = registration_json.get("unitDetails").get(
"isUnitOnPrincipalResidenceProperty"
)
if rental_unit_space_type == RentalProperty.RentalUnitSpaceType.ENTIRE_HOME:
if is_rental_unit_on_principal_residence:
host_residence = registration_json.get("unitDetails").get("hostResidence")
if host_residence == RentalProperty.HostResidence.SAME_UNIT:
filing_type = HOST_REGISTRATION_FEE_1
elif host_residence == RentalProperty.HostResidence.ANOTHER_UNIT:
filing_type = HOST_REGISTRATION_FEE_2
else:
filing_type = HOST_REGISTRATION_FEE_2
elif rental_unit_space_type == RentalProperty.RentalUnitSpaceType.SHARED_ACCOMMODATION:
quantity = registration_json.get("unitDetails").get("numberOfRoomsForRent")
filing_type = HOST_REGISTRATION_FEE_1
return filing_type, quantity

def get_payment_details_by_invoice_id(self, user_jwt: JwtManager, account_id, invoice_id: int):
"""Get payment details by invoice id."""
token = user_jwt.get_token_auth_header()
Expand Down

0 comments on commit 06f3e18

Please sign in to comment.