From 9d52cbb36156e8888f2144a72c119ce46a679c83 Mon Sep 17 00:00:00 2001 From: Khai Tran Date: Tue, 23 Apr 2024 16:20:04 +0700 Subject: [PATCH] chore: Update payment model --- .../api_orm/model_parsers/payment_parsers.py | 2 ++ locker_server/core/entities/payment/payment.py | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/locker_server/api_orm/model_parsers/payment_parsers.py b/locker_server/api_orm/model_parsers/payment_parsers.py index 5ac532a..95fd7ab 100644 --- a/locker_server/api_orm/model_parsers/payment_parsers.py +++ b/locker_server/api_orm/model_parsers/payment_parsers.py @@ -105,5 +105,7 @@ def parse_payment(cls, payment_orm: PaymentORM) -> Payment: saas_market=payment_orm.saas_market, user=user_parser.parse_user(user_orm=payment_orm.user), promo_code=cls.parse_promo_code(promo_code_orm=payment_orm.promo_code) if payment_orm.promo_code else None, + net_price=payment_orm.net_price, + channel=payment_orm.channel, customer=cls.parse_customer(customer_orm=payment_orm.customer) if payment_orm.customer else None, ) diff --git a/locker_server/core/entities/payment/payment.py b/locker_server/core/entities/payment/payment.py index 51ca8b4..72503a3 100644 --- a/locker_server/core/entities/payment/payment.py +++ b/locker_server/core/entities/payment/payment.py @@ -3,8 +3,7 @@ from locker_server.core.entities.payment.customer import Customer from locker_server.core.entities.payment.promo_code import PromoCode from locker_server.core.entities.user.user import User -from locker_server.shared.constants.transactions import CURRENCY_USD, TRANSACTION_TYPE_PAYMENT, DURATION_MONTHLY, \ - DURATION_YEARLY, DURATION_HALF_YEARLY +from locker_server.shared.constants.transactions import * class Payment(object): @@ -14,7 +13,9 @@ def __init__(self, id: int, payment_id: str, created_time: float = None, total_p failure_reason: str = None, stripe_invoice_id: str = None, mobile_invoice_id: str = None, code: str = None, bank_id: int = None, scope: str = None, plan: str = None, duration: str = DURATION_MONTHLY, metadata: str = None, enterprise_id: str = None, - saas_market: str = None, user: User = None, promo_code: PromoCode = None, customer: Customer = None): + saas_market: str = None, user: User = None, promo_code: PromoCode = None, + net_price: float = 0, channel: str = PAYMENT_CHANNEL_ORGANIC, + customer: Customer = None): self._id = id self._payment_id = payment_id self._created_time = created_time @@ -38,6 +39,8 @@ def __init__(self, id: int, payment_id: str, created_time: float = None, total_p self._saas_market = saas_market self._user = user self._promo_code = promo_code + self._net_price = net_price + self._channel = channel self._customer = customer @property @@ -136,6 +139,14 @@ def user(self): def promo_code(self): return self._promo_code + @property + def net_price(self): + return self._net_price + + @property + def channel(self): + return self._channel + @property def customer(self): return self._customer