trex-model 1.5.13__tar.gz → 1.5.14__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of trex-model might be problematic. Click here for more details.
- {trex-model-1.5.13 → trex-model-1.5.14}/PKG-INFO +1 -1
- {trex-model-1.5.13 → trex-model-1.5.14}/setup.py +1 -1
- {trex-model-1.5.13 → trex-model-1.5.14}/trex_model.egg-info/PKG-INFO +1 -1
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/helper/reward_transaction_helper.py +4 -1
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/lucky_draw_models.py +14 -1
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/reward_models.py +54 -1
- {trex-model-1.5.13 → trex-model-1.5.14}/LICENSE +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/MANIFEST.in +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/README.md +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/setup.cfg +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trex_model.egg-info/SOURCES.txt +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trex_model.egg-info/dependency_links.txt +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trex_model.egg-info/requires.txt +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trex_model.egg-info/top_level.txt +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/__init__.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/conf.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/__init__.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/__init__.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/admin_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/analytic_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/app_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/coporate_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/customer_model_helpers.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/customer_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/fb_subsriber_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/helper/__init__.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/helper/reward_model_helpers.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/import_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/inventory_model.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/loyalty_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/marketing_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/membership_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/merchant_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/message_model_helper.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/message_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/model_decorators.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/ndb_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/pos_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/prepaid_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/product_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/program_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/rating_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/recruit_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/redeem_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/redemption_catalogue_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/referral_program_model.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/spending_base_program_model.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/system_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/task_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/test_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/transaction_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/user_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/voucher_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/merchant_helpers.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/model_decorator.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/prepaid_helpers.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/pos_conf.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/program_conf.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/utils/__init__.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/utils/gcloud/__init__.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/utils/gcloud/datastore_util.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/utils/model/__init__.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/utils/model/model_util.py +0 -0
|
@@ -23,7 +23,8 @@ from trexanalytics.bigquery_upstream_data_config import create_merchant_customer
|
|
|
23
23
|
create_merchant_customer_transaction_upstream_for_merchant,\
|
|
24
24
|
create_merchant_customer_redemption_upstream_for_merchant,\
|
|
25
25
|
create_merchant_customer_prepaid_upstream_for_merchant,\
|
|
26
|
-
create_merchant_customer_redemption_reverted_upstream_for_merchant
|
|
26
|
+
create_merchant_customer_redemption_reverted_upstream_for_merchant,\
|
|
27
|
+
create_revert_entitled_customer_voucher_upstream_for_merchant
|
|
27
28
|
from trexmodel.models.datastore.membership_models import MerchantTierMembership
|
|
28
29
|
from trexmodel.models.datastore.transaction_models import CustomerTransaction,\
|
|
29
30
|
SalesTransaction
|
|
@@ -920,6 +921,8 @@ def revert_transaction(transaction_details, reverted_by, reverted_datetime=None,
|
|
|
920
921
|
p.reverted_by_username = reverted_by.username
|
|
921
922
|
p.put()
|
|
922
923
|
|
|
924
|
+
create_revert_entitled_customer_voucher_upstream_for_merchant(p)
|
|
925
|
+
|
|
923
926
|
entitled_voucher_summary = update_customer_entiteld_voucher_summary_after_reverted_voucher(entitled_voucher_summary, p)
|
|
924
927
|
|
|
925
928
|
voucher_key = p.entitled_voucher_key
|
|
@@ -496,6 +496,7 @@ class LuckyDrawTicket(BaseNModel, DictModel):
|
|
|
496
496
|
merchant_acct = ndb.KeyProperty(name="merchant_acct", kind=MerchantAcct)
|
|
497
497
|
transact_outlet = ndb.KeyProperty(name="transact_outlet", kind=Outlet)
|
|
498
498
|
ticket_key = ndb.StringProperty(required=True)
|
|
499
|
+
program_key = ndb.StringProperty(required=False)
|
|
499
500
|
created_datetime = ndb.DateTimeProperty(required=True, auto_now_add=True)
|
|
500
501
|
used_datetime = ndb.DateTimeProperty(required=False)
|
|
501
502
|
expiry_date = ndb.DateProperty(required=True)
|
|
@@ -563,6 +564,17 @@ class LuckyDrawTicket(BaseNModel, DictModel):
|
|
|
563
564
|
def count_entiteld_by_customer_acct_by_date_range(customer_acct, start_datetime=None, end_datetime=None):
|
|
564
565
|
return LuckyDrawTicket.query(ndb.AND(LuckyDrawTicket.created_datetime>=start_datetime, LuckyDrawTicket.created_datetime<end_datetime), ancestor=customer_acct.create_ndb_key()).count(limit=model_conf.MAX_FETCH_RECORD)
|
|
565
566
|
|
|
567
|
+
@staticmethod
|
|
568
|
+
def count_by_merchant_acct(merchant_acct):
|
|
569
|
+
return LuckyDrawTicket.query(ndb.AND(LuckyDrawTicket.merchant_acct==merchant_acct.create_ndb_key())).count(limit=model_conf.MAX_FETCH_RECORD)
|
|
570
|
+
|
|
571
|
+
@staticmethod
|
|
572
|
+
def list_by_merchant_acct_with_cursor(merchant_acct, offset=0, limit=50, start_cursor=None):
|
|
573
|
+
query = LuckyDrawTicket.query(ndb.AND(LuckyDrawTicket.merchant_acct==merchant_acct.create_ndb_key(),))
|
|
574
|
+
(result, next_cursor) = LuckyDrawTicket.list_all_with_condition_query(query, start_cursor=start_cursor, return_with_cursor=True, offset=offset, limit=limit)
|
|
575
|
+
|
|
576
|
+
return (result, next_cursor)
|
|
577
|
+
|
|
566
578
|
@staticmethod
|
|
567
579
|
def create_for_customer_from_sales_amount(customer_acct, sales_amount=None, merchant_acct=None, transact_outlet=None):
|
|
568
580
|
number_of_ticket = 0
|
|
@@ -665,6 +677,7 @@ class LuckyDrawTicket(BaseNModel, DictModel):
|
|
|
665
677
|
|
|
666
678
|
program = LuckyDrawTicket.__get_lucky_draw_program(merchant_acct.lucky_draw_configuration, customer_acct=customer_acct)
|
|
667
679
|
if program:
|
|
680
|
+
program_key = program.get('program_key')
|
|
668
681
|
prize_details_list = program.get('program_settings').get('prize_settings').get('prizes')
|
|
669
682
|
ticket_image_url = program.get('program_settings').get('ticket_image_url')
|
|
670
683
|
|
|
@@ -688,7 +701,7 @@ class LuckyDrawTicket(BaseNModel, DictModel):
|
|
|
688
701
|
expiry_date = expiry_date.date(),
|
|
689
702
|
ticket_key = random_string(16),
|
|
690
703
|
drawed_details = drawed_details,
|
|
691
|
-
|
|
704
|
+
program_key = program_key,
|
|
692
705
|
#created_by = created_by.create_ndb_key(),
|
|
693
706
|
#created_by_username = created_by_username,
|
|
694
707
|
)
|
|
@@ -60,6 +60,10 @@ class RewardEntitlement(BaseNModel, DictModel):
|
|
|
60
60
|
def is_removed(self):
|
|
61
61
|
return self.status == program_conf.REWARD_STATUS_REMOVED
|
|
62
62
|
|
|
63
|
+
@property
|
|
64
|
+
def is_reverted(self):
|
|
65
|
+
return self.status == program_conf.REWARD_STATUS_REVERTED
|
|
66
|
+
|
|
63
67
|
|
|
64
68
|
|
|
65
69
|
class CustomerEntitledReward(RewardEntitlement):
|
|
@@ -76,13 +80,24 @@ class CustomerEntitledReward(RewardEntitlement):
|
|
|
76
80
|
def entitled_customer_key(self):
|
|
77
81
|
return self.key.parent().urlsafe().decode('utf-8')
|
|
78
82
|
|
|
83
|
+
@property
|
|
84
|
+
def entitled_user_key(self):
|
|
85
|
+
return self.user_acct.urlsafe().decode('utf-8')
|
|
86
|
+
|
|
87
|
+
@property
|
|
88
|
+
def merchant_acct_key(self):
|
|
89
|
+
return self.merchant_acct.urlsafe().decode('utf-8')
|
|
90
|
+
|
|
79
91
|
@property
|
|
80
92
|
def entitled_customer_acct(self):
|
|
81
93
|
return Customer.fetch(self.key.parent().urlsafe())
|
|
82
94
|
|
|
83
95
|
@property
|
|
84
96
|
def reward_program_key(self):
|
|
85
|
-
|
|
97
|
+
if self.reward_program:
|
|
98
|
+
return self.reward_program.urlsafe().decode('utf-8')
|
|
99
|
+
else:
|
|
100
|
+
return ''
|
|
86
101
|
|
|
87
102
|
@property
|
|
88
103
|
def rewarded_by_merchant_acct_entity(self):
|
|
@@ -327,6 +342,12 @@ class CustomerEntitledVoucher(CustomerEntitledReward):
|
|
|
327
342
|
'status', 'is_reverted', 'is_used',
|
|
328
343
|
]
|
|
329
344
|
|
|
345
|
+
@property
|
|
346
|
+
def redeemed_by_outlet_key(self):
|
|
347
|
+
return self.redeemed_by_outlet.urlsafe().decode('utf-8')
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
330
351
|
@staticmethod
|
|
331
352
|
def list_by_transaction_id(transaction_id):
|
|
332
353
|
return CustomerEntitledVoucher.query(CustomerEntitledVoucher.transaction_id==transaction_id).fetch(limit=conf.MAX_FETCH_RECORD)
|
|
@@ -363,6 +384,38 @@ class CustomerEntitledVoucher(CustomerEntitledReward):
|
|
|
363
384
|
|
|
364
385
|
return result
|
|
365
386
|
|
|
387
|
+
@staticmethod
|
|
388
|
+
def count_by_merchant_acct(merchant_acct, datetime_ranage_start=None, datetime_range_end=None):
|
|
389
|
+
if datetime_ranage_start and datetime_range_end:
|
|
390
|
+
result = CustomerEntitledVoucher.query(ndb.AND(
|
|
391
|
+
CustomerEntitledVoucher.merchant_acct==merchant_acct.create_ndb_key(),
|
|
392
|
+
CustomerEntitledVoucher.rewarded_datetime>=datetime_ranage_start,
|
|
393
|
+
CustomerEntitledVoucher.datetime_range_end<datetime_range_end,
|
|
394
|
+
)).count(limit=conf.MAX_FETCH_RECORD)
|
|
395
|
+
else:
|
|
396
|
+
result = CustomerEntitledVoucher.query(ndb.AND(
|
|
397
|
+
CustomerEntitledVoucher.merchant_acct==merchant_acct.create_ndb_key(),
|
|
398
|
+
)).count(limit=conf.MAX_FETCH_RECORD)
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
return result
|
|
402
|
+
|
|
403
|
+
@staticmethod
|
|
404
|
+
def list_by_merchant_acct_with_cursor(merchant_acct, datetime_ranage_start=None, datetime_range_end=None, offset=0, limit=50, start_cursor=None):
|
|
405
|
+
if is_not_empty(datetime_ranage_start) and is_not_empty(datetime_range_end):
|
|
406
|
+
query = CustomerEntitledVoucher.query(ndb.AND(
|
|
407
|
+
CustomerEntitledVoucher.merchant_acct==merchant_acct.create_ndb_key(),
|
|
408
|
+
CustomerEntitledVoucher.rewarded_datetime>=datetime_ranage_start,
|
|
409
|
+
CustomerEntitledVoucher.rewarded_datetime<datetime_range_end,
|
|
410
|
+
))
|
|
411
|
+
else:
|
|
412
|
+
query = CustomerEntitledVoucher.query(ndb.AND(
|
|
413
|
+
CustomerEntitledVoucher.merchant_acct==merchant_acct.create_ndb_key(),
|
|
414
|
+
))
|
|
415
|
+
(result, next_cursor) = CustomerEntitledVoucher.list_all_with_condition_query(query, start_cursor=start_cursor, return_with_cursor=True, offset=offset, limit=limit)
|
|
416
|
+
|
|
417
|
+
return (result, next_cursor)
|
|
418
|
+
|
|
366
419
|
@staticmethod
|
|
367
420
|
def count_redeemed_by_merchant_voucher_and_passed_redeemed_datetime(customer, merchant_voucher, passed_redeemed_datetime):
|
|
368
421
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/customer_model_helpers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/helper/reward_model_helpers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/redemption_catalogue_models.py
RENAMED
|
File without changes
|
{trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/referral_program_model.py
RENAMED
|
File without changes
|
{trex-model-1.5.13 → trex-model-1.5.14}/trexmodel/models/datastore/spending_base_program_model.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|