trex-model 1.5.10__tar.gz → 1.5.12__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.

Files changed (63) hide show
  1. {trex-model-1.5.10 → trex-model-1.5.12}/PKG-INFO +1 -1
  2. {trex-model-1.5.10 → trex-model-1.5.12}/setup.py +1 -1
  3. {trex-model-1.5.10 → trex-model-1.5.12}/trex_model.egg-info/PKG-INFO +1 -1
  4. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/conf.py +2 -0
  5. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/helper/reward_transaction_helper.py +40 -5
  6. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/message_model_helper.py +51 -20
  7. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/message_models.py +5 -8
  8. {trex-model-1.5.10 → trex-model-1.5.12}/LICENSE +0 -0
  9. {trex-model-1.5.10 → trex-model-1.5.12}/MANIFEST.in +0 -0
  10. {trex-model-1.5.10 → trex-model-1.5.12}/README.md +0 -0
  11. {trex-model-1.5.10 → trex-model-1.5.12}/setup.cfg +0 -0
  12. {trex-model-1.5.10 → trex-model-1.5.12}/trex_model.egg-info/SOURCES.txt +0 -0
  13. {trex-model-1.5.10 → trex-model-1.5.12}/trex_model.egg-info/dependency_links.txt +0 -0
  14. {trex-model-1.5.10 → trex-model-1.5.12}/trex_model.egg-info/requires.txt +0 -0
  15. {trex-model-1.5.10 → trex-model-1.5.12}/trex_model.egg-info/top_level.txt +0 -0
  16. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/__init__.py +0 -0
  17. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/__init__.py +0 -0
  18. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/__init__.py +0 -0
  19. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/admin_models.py +0 -0
  20. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/analytic_models.py +0 -0
  21. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/app_models.py +0 -0
  22. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/coporate_models.py +0 -0
  23. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/customer_model_helpers.py +0 -0
  24. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/customer_models.py +0 -0
  25. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/fb_subsriber_models.py +0 -0
  26. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/helper/__init__.py +0 -0
  27. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/helper/reward_model_helpers.py +0 -0
  28. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/import_models.py +0 -0
  29. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/inventory_model.py +0 -0
  30. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/loyalty_models.py +0 -0
  31. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/lucky_draw_models.py +0 -0
  32. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/marketing_models.py +0 -0
  33. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/membership_models.py +0 -0
  34. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/merchant_models.py +0 -0
  35. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/model_decorators.py +0 -0
  36. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/ndb_models.py +0 -0
  37. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/pos_models.py +0 -0
  38. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/prepaid_models.py +0 -0
  39. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/product_models.py +0 -0
  40. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/program_models.py +0 -0
  41. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/rating_models.py +0 -0
  42. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/recruit_models.py +0 -0
  43. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/redeem_models.py +0 -0
  44. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/redemption_catalogue_models.py +0 -0
  45. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/referral_program_model.py +0 -0
  46. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/reward_models.py +0 -0
  47. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/spending_base_program_model.py +0 -0
  48. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/system_models.py +0 -0
  49. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/task_models.py +0 -0
  50. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/test_models.py +0 -0
  51. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/transaction_models.py +0 -0
  52. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/user_models.py +0 -0
  53. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/datastore/voucher_models.py +0 -0
  54. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/merchant_helpers.py +0 -0
  55. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/model_decorator.py +0 -0
  56. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/models/prepaid_helpers.py +0 -0
  57. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/pos_conf.py +0 -0
  58. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/program_conf.py +0 -0
  59. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/utils/__init__.py +0 -0
  60. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/utils/gcloud/__init__.py +0 -0
  61. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/utils/gcloud/datastore_util.py +0 -0
  62. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/utils/model/__init__.py +0 -0
  63. {trex-model-1.5.10 → trex-model-1.5.12}/trexmodel/utils/model/model_util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: trex-model
3
- Version: 1.5.10
3
+ Version: 1.5.12
4
4
  Summary: TRex database module package
5
5
  Home-page: https://bitbucket.org/lokjac/trex-model
6
6
  Author: Jack Lok
@@ -3,7 +3,7 @@ with open("README.md", "r") as fh:
3
3
  long_description = fh.read()
4
4
  setuptools.setup(
5
5
  name='trex-model',
6
- version='1.5.10',
6
+ version='1.5.12',
7
7
  author="Jack Lok",
8
8
  author_email="sglok77@gmail.com",
9
9
  description="TRex database module package",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: trex-model
3
- Version: 1.5.10
3
+ Version: 1.5.12
4
4
  Summary: TRex database module package
5
5
  Home-page: https://bitbucket.org/lokjac/trex-model
6
6
  Author: Jack Lok
@@ -37,6 +37,7 @@ MESSAGE_CATEGORY_REWARD = 'reward'
37
37
  MESSAGE_CATEGORY_REFERRAL = 'referral'
38
38
  MESSAGE_CATEGORY_BIRTHDAY = 'birthday'
39
39
  MESSAGE_CATEGORY_REDEEM = 'redeem'
40
+ MESSAGE_CATEGORY_PAYMENT = 'payment'
40
41
  MESSAGE_CATEGORY_REDEMPTION_CATALOGUE = 'redemption_catalogue'
41
42
 
42
43
  MESSAGE_CATEGORIES = (
@@ -48,6 +49,7 @@ MESSAGE_CATEGORIES = (
48
49
  MESSAGE_CATEGORY_REWARD,
49
50
  MESSAGE_CATEGORY_REDEEM,
50
51
  MESSAGE_CATEGORY_REDEMPTION_CATALOGUE,
52
+ MESSAGE_CATEGORY_PAYMENT,
51
53
  )
52
54
 
53
55
  MESSAGE_STATUS_NEW = 'n'
@@ -37,7 +37,7 @@ from trexlib.utils.string_util import is_not_empty
37
37
  from trexlib.utils.log_util import get_tracelog
38
38
  from trexmodel.models.datastore.lucky_draw_models import LuckyDrawTicket
39
39
  from trexmodel.models.datastore.message_model_helper import create_transaction_message,\
40
- create_redemption_message
40
+ create_redemption_message, create_payment_message
41
41
  from trexmodel.models.datastore.helper.reward_model_helpers import list_merchant_birthday_program_configuration
42
42
  from dateutil.relativedelta import relativedelta
43
43
 
@@ -668,7 +668,7 @@ def check_giveaway_reward_for_membership_purchase_transaction(customer_acct, tra
668
668
 
669
669
  def redeem_reward_transaction(customer, redeem_outlet=None, reward_format=None, reward_amount=.0, invoice_id=None, remarks=None,
670
670
  redeemed_by=None, redeemed_datetime=None, transaction_id=None, prepaid_redeem_code=None,
671
- redeemed_voucher_keys_list=None
671
+ redeemed_voucher_keys_list=None,
672
672
  ):
673
673
  logger.debug('---redeem_reward_transaction---')
674
674
 
@@ -701,6 +701,40 @@ def redeem_reward_transaction(customer, redeem_outlet=None, reward_format=None,
701
701
  else:
702
702
  raise Exception("Invalid reward format")
703
703
 
704
+ def prepaid_payment_transaction(customer, redeem_outlet=None, reward_format=None, reward_amount=.0, invoice_id=None, remarks=None,
705
+ redeemed_by=None, redeemed_datetime=None, transaction_id=None, prepaid_redeem_code=None,
706
+
707
+ ):
708
+ logger.debug('---prepaid_payment_transaction---')
709
+
710
+ if reward_format in program_conf.REWARD_FORMAT_SET:
711
+
712
+ @model_transactional(desc='redeem_reward_transaction')
713
+ def __start_transaction_for_customer_transaction():
714
+
715
+ logger.debug('reward_format=%s', reward_format)
716
+
717
+ customer_redemption = CustomerRedemption.create(customer, reward_format,
718
+ redeemed_outlet = redeem_outlet,
719
+ redeemed_amount = reward_amount,
720
+ prepaid_redeem_code = prepaid_redeem_code,
721
+ invoice_id = invoice_id,
722
+ transaction_id = transaction_id,
723
+ remarks = remarks,
724
+ redeemed_by = redeemed_by,
725
+ redeemed_datetime = redeemed_datetime,
726
+ )
727
+
728
+ if customer_redemption:
729
+ create_payment_message(customer_redemption)
730
+ create_merchant_customer_redemption_upstream_for_merchant(customer_redemption, streamed_datetime=redeemed_datetime)
731
+
732
+ return customer_redemption
733
+
734
+ return __start_transaction_for_customer_transaction()
735
+ else:
736
+ raise Exception("Invalid reward format")
737
+
704
738
  def update_customer_reward_summary(customer):
705
739
  entitled_point_details_list = CustomerPointReward.list_by_customer(customer)
706
740
  entitled_stamp_details_list = CustomerStampReward.list_by_customer(customer)
@@ -1238,7 +1272,8 @@ def _giveaway_birthday_reward_to_customer(customer, program_configuration, trans
1238
1272
  else:
1239
1273
  logger.debug('Skip, because it is test user account')
1240
1274
 
1241
- logger.debug('------> Customer(%s) entitled before (%s) =%s %s', customer.name, program_desc)
1275
+ logger.debug('------> Customer(%s) entitled before (%s)', customer.name, program_desc)
1276
+ logger.debug('------> remarks=%s', remarks)
1242
1277
 
1243
1278
  if is_entitled_before == False:
1244
1279
  transaction_details = create_non_sales_system_transaction(customer, transact_datetime=transact_datetime, remarks=remarks)
@@ -1249,11 +1284,11 @@ def _giveaway_birthday_reward_to_customer(customer, program_configuration, trans
1249
1284
  program_configuration_list = [program_configuration],
1250
1285
  )
1251
1286
  Customer.update_customer_entitled_birthday_reward_summary(customer, program_key)
1252
- create_transaction_message(transaction_details, remarks=program_configuration.get('remarks'))
1287
+ create_transaction_message(transaction_details, remarks=remarks, message_category=conf.MESSAGE_CATEGORY_BIRTHDAY)
1253
1288
  else:
1254
1289
  logger.info('Customer(%s) have entitled birthday reward (%s) on year %d', customer.name, program_desc, this_year)
1255
1290
  except:
1256
- logger.error('Failed to process for customer=%s', customer.name)
1291
+ logger.error('Failed to process for customer=%s, due to %s', customer.name, get_tracelog())
1257
1292
 
1258
1293
  @model_transactional(desc="giveaway_membership_reward_to_customer")
1259
1294
  def giveaway_membership_reward_to_customer(customer, program_configuration, transact_datetime, merchant_acct ):
@@ -6,7 +6,8 @@ Created on 9 Nov 2023
6
6
  from trexmodel.program_conf import REWARD_FORMAT_MAP, REWARD_FORMAT_PREPAID
7
7
  from trexmodel.models.datastore.message_models import Message
8
8
  from trexmodel.conf import MESSAGE_CATEGORY_REWARD, MESSAGE_STATUS_NEW,\
9
- MESSAGE_CATEGORY_REDEEM, MESSAGE_CATEGORY_REDEMPTION_CATALOGUE
9
+ MESSAGE_CATEGORY_REDEEM, MESSAGE_CATEGORY_REDEMPTION_CATALOGUE,\
10
+ MESSAGE_CATEGORY_PAYMENT
10
11
  from trexconf import program_conf
11
12
  from babel.numbers import format_currency
12
13
  import logging
@@ -189,6 +190,30 @@ def create_redemption_message(customer_redemption):
189
190
 
190
191
  return message
191
192
 
193
+ def create_payment_message(customer_redemption):
194
+ user_acct = customer_redemption.redeemed_user_acct
195
+ merchant_acct = customer_redemption.redeemed_merchant_acct
196
+ source_key = customer_redemption.key_in_str
197
+ message = Message.get_by_source_key(source_key)
198
+
199
+ if message is None:
200
+ message = Message(
201
+ parent = user_acct.create_ndb_key(),
202
+ source_key = source_key,
203
+ message_to = user_acct.create_ndb_key(),
204
+ title = 'Payment',
205
+ message_category = MESSAGE_CATEGORY_PAYMENT,
206
+ message_content = __create_message_from_redeem_transaction(merchant_acct, customer_redemption),
207
+ message_data = __create_message_data_from_redemption(customer_redemption),
208
+ status = MESSAGE_STATUS_NEW,
209
+ message_from = merchant_acct.brand_name,
210
+ )
211
+ message.put()
212
+ #user_acct.new_message_count+=1
213
+ #user_acct.put()
214
+
215
+ return message
216
+
192
217
 
193
218
  def create_redeem_catalogue_item_message(customer, entitled_vouchers_summary, redemption_catalogue_transaction):
194
219
  user_acct = customer.registered_user_acct
@@ -253,8 +278,31 @@ def __create_entiled_message_from_customer_transaction(customer_transaction, rem
253
278
 
254
279
  messages_for_json_list = []
255
280
 
281
+ header_message_list = [
282
+ {
283
+ 'type': 'image',
284
+ 'value': {
285
+ 'url': 'https://storage.googleapis.com/augmigo-image-storage/app/customer-rewards-min.png',
286
+ 'height': 100,
287
+ }
288
+
289
+ },
290
+ {
291
+ 'type': 'image',
292
+ 'value': {
293
+ 'url': 'https://storage.googleapis.com/augmigo-image-storage/app/congratulations-min.png',
294
+ 'height': 80,
295
+ }
296
+
297
+ },
298
+ ]
299
+
256
300
  if is_not_empty(remarks):
257
- message_list.append('<p>{remarks}</p>'.format(remarks=remarks))
301
+ header_message_list.append({
302
+ 'type' : 'text',
303
+ 'value' : remarks,
304
+ 'font-size' : 20,
305
+ })
258
306
 
259
307
  for message in entitled_messages_list:
260
308
  message_list.append('<li class="pt-2">{message}</li>'.format(message=message))
@@ -267,24 +315,7 @@ def __create_entiled_message_from_customer_transaction(customer_transaction, rem
267
315
  return {
268
316
  'type' : 'json',
269
317
  'content' : {
270
- 'header':[
271
- {
272
- 'type': 'image',
273
- 'value': {
274
- 'url': 'https://storage.googleapis.com/augmigo-image-storage/app/customer-rewards-min.png',
275
- 'height': 100,
276
- }
277
-
278
- },
279
- {
280
- 'type': 'image',
281
- 'value': {
282
- 'url': 'https://storage.googleapis.com/augmigo-image-storage/app/congratulations-min.png',
283
- 'height': 80,
284
- }
285
-
286
- },
287
- ],
318
+ 'header':header_message_list,
288
319
  'title':[
289
320
  {
290
321
  'type':'text',
@@ -10,12 +10,9 @@ from trexmodel.models.datastore.user_models import User
10
10
  from datetime import datetime
11
11
  import logging
12
12
  from trexconf import conf
13
- from trexmodel.conf import MESSAGE_STATUS_SET, MESSAGE_STATUS_NEW, MESSAGE_CATEGORY_SYSTEM,\
14
- MESSAGE_STATUS_READ, MESSAGE_CATEGORIES, MESSAGE_CATEGORY_ANNOUNCEMENT
15
13
  from trexmodel.models.datastore.transaction_models import CustomerTransaction
16
14
  from trexmodel.models.datastore.redeem_models import RedemptionCatalogueTransaction,\
17
15
  CustomerRedemption
18
- from trexmodel.models.datastore.customer_models import Customer
19
16
 
20
17
 
21
18
  logger = logging.getLogger('model')
@@ -38,11 +35,11 @@ class Message(BaseNModel, DictModel):
38
35
  message_to = ndb.KeyProperty(name="message_to", kind=User)
39
36
  source_key = ndb.StringProperty(required=False)
40
37
  title = ndb.StringProperty(required=True)
41
- message_category = ndb.StringProperty(required=True, default=MESSAGE_CATEGORY_SYSTEM, choices=MESSAGE_CATEGORIES)
38
+ message_category = ndb.StringProperty(required=True, default=conf.MESSAGE_CATEGORY_SYSTEM, choices=conf.MESSAGE_CATEGORIES)
42
39
  message_content = ndb.JsonProperty(required=True, indexed=False)
43
40
  message_data = ndb.JsonProperty(required=True, indexed=False)
44
41
  message_from = ndb.StringProperty(required=False)
45
- status = ndb.StringProperty(required=True, default=MESSAGE_STATUS_NEW, choices=MESSAGE_STATUS_SET)
42
+ status = ndb.StringProperty(required=True, default=conf.MESSAGE_STATUS_NEW, choices=conf.MESSAGE_STATUS_SET)
46
43
  created_datetime = ndb.DateTimeProperty(required=True, auto_now_add=True)
47
44
  read_datetime = ndb.DateTimeProperty(required=False)
48
45
  email_sent_datetime = ndb.DateTimeProperty(required=False)
@@ -76,7 +73,7 @@ class Message(BaseNModel, DictModel):
76
73
 
77
74
 
78
75
  @staticmethod
79
- def create(user_acct, source_key=None, message_to=None, title=None, message_type=MESSAGE_CATEGORY_ANNOUNCEMENT, message_content={}):
76
+ def create(user_acct, source_key=None, message_to=None, title=None, message_type=conf.MESSAGE_CATEGORY_ANNOUNCEMENT, message_content={}):
80
77
  Message(
81
78
  parent = user_acct.create_ndb_key(),
82
79
  source_key = source_key,
@@ -84,7 +81,7 @@ class Message(BaseNModel, DictModel):
84
81
  title = title,
85
82
  message_type = message_type,
86
83
  message_content = message_content,
87
- #created_datetime= datetime.utcnow(),
84
+ created_datetime= datetime.utcnow(),
88
85
  ).put()
89
86
 
90
87
  @staticmethod
@@ -93,7 +90,7 @@ class Message(BaseNModel, DictModel):
93
90
  if message:
94
91
  user_acct = message.user_acct_entity
95
92
  logger.debug('found message title=%s', message.title)
96
- message.status = MESSAGE_STATUS_READ
93
+ message.status = conf.MESSAGE_STATUS_READ
97
94
  message.read_datetime = datetime.utcnow()
98
95
  message.put()
99
96
  '''
File without changes
File without changes
File without changes
File without changes