trex-model 1.0.0__tar.gz → 1.0.1__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 (50) hide show
  1. {trex-model-1.0.0/trex_model.egg-info → trex-model-1.0.1}/PKG-INFO +1 -1
  2. {trex-model-1.0.0 → trex-model-1.0.1}/setup.py +1 -1
  3. {trex-model-1.0.0 → trex-model-1.0.1/trex_model.egg-info}/PKG-INFO +1 -1
  4. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/merchant_models.py +4 -1
  5. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/transaction_models.py +124 -43
  6. {trex-model-1.0.0 → trex-model-1.0.1}/LICENSE +0 -0
  7. {trex-model-1.0.0 → trex-model-1.0.1}/MANIFEST.in +0 -0
  8. {trex-model-1.0.0 → trex-model-1.0.1}/README.md +0 -0
  9. {trex-model-1.0.0 → trex-model-1.0.1}/setup.cfg +0 -0
  10. {trex-model-1.0.0 → trex-model-1.0.1}/trex_model.egg-info/SOURCES.txt +0 -0
  11. {trex-model-1.0.0 → trex-model-1.0.1}/trex_model.egg-info/dependency_links.txt +0 -0
  12. {trex-model-1.0.0 → trex-model-1.0.1}/trex_model.egg-info/requires.txt +0 -0
  13. {trex-model-1.0.0 → trex-model-1.0.1}/trex_model.egg-info/top_level.txt +0 -0
  14. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/__init__.py +0 -0
  15. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/conf.py +0 -0
  16. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/__init__.py +0 -0
  17. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/__init__.py +0 -0
  18. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/admin_models.py +0 -0
  19. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/analytic_models.py +0 -0
  20. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/coporate_models.py +0 -0
  21. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/customer_model_helpers.py +0 -0
  22. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/customer_models.py +0 -0
  23. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/fb_subsriber_models.py +0 -0
  24. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/inventory_model.py +0 -0
  25. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/loyalty_models.py +0 -0
  26. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/membership_models.py +0 -0
  27. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/model_decorators.py +0 -0
  28. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/ndb_models.py +0 -0
  29. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/pos_models.py +0 -0
  30. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/prepaid_models.py +0 -0
  31. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/product_models.py +0 -0
  32. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/program_models.py +0 -0
  33. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/redeem_models.py +0 -0
  34. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/reward_models.py +0 -0
  35. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/spending_base_program_model.py +0 -0
  36. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/system_models.py +0 -0
  37. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/task_models.py +0 -0
  38. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/test_models.py +0 -0
  39. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/user_models.py +0 -0
  40. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/datastore/voucher_models.py +0 -0
  41. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/merchant_helpers.py +0 -0
  42. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/model_decorator.py +0 -0
  43. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/models/prepaid_helpers.py +0 -0
  44. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/pos_conf.py +0 -0
  45. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/program_conf.py +0 -0
  46. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/utils/__init__.py +0 -0
  47. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/utils/gcloud/__init__.py +0 -0
  48. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/utils/gcloud/datastore_util.py +0 -0
  49. {trex-model-1.0.0 → trex-model-1.0.1}/trexmodel/utils/model/__init__.py +0 -0
  50. {trex-model-1.0.0 → trex-model-1.0.1}/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.0.0
3
+ Version: 1.0.1
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.0.0',
6
+ version='1.0.1',
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.0.0
3
+ Version: 1.0.1
4
4
  Summary: TRex database module package
5
5
  Home-page: https://bitbucket.org/lokjac/trex-model
6
6
  Author: Jack Lok
@@ -96,7 +96,10 @@ class MerchantAcct(MerchantMin):
96
96
 
97
97
  @property
98
98
  def program_configuration_list(self):
99
- return self.published_program_configuration.get('programs')
99
+ if is_not_empty(self.published_program_configuration):
100
+ return self.published_program_configuration.get('programs')
101
+ else:
102
+ return []
100
103
 
101
104
 
102
105
  @property
@@ -25,17 +25,17 @@ from trexmodel.models.datastore.reward_models import CustomerPointReward,\
25
25
 
26
26
  logger = logging.getLogger('model')
27
27
 
28
-
29
- class CustomerTransaction(BaseNModel, DictModel):
30
- '''
31
-
32
- '''
28
+ class SalesTransaction(BaseNModel, DictModel):
33
29
  transact_merchant = ndb.KeyProperty(name="transact_merchant", kind=MerchantAcct)
34
30
  transact_outlet = ndb.KeyProperty(name="transact_outlet", kind=Outlet)
35
31
 
36
32
  transact_datetime = ndb.DateTimeProperty(required=True)
37
33
  created_datetime = ndb.DateTimeProperty(required=True, auto_now=True)
38
34
 
35
+ reverted_datetime = ndb.DateTimeProperty(required=False)
36
+ reverted_by = ndb.KeyProperty(name="reverted_by", kind=MerchantUser)
37
+ reverted_by_username = ndb.StringProperty(required=False)
38
+
39
39
  transact_timestamp = ndb.FloatProperty(required=False)
40
40
 
41
41
  transaction_id = ndb.StringProperty(required=True)
@@ -51,6 +51,117 @@ class CustomerTransaction(BaseNModel, DictModel):
51
51
 
52
52
  sales_channel = ndb.StringProperty(required=False)
53
53
 
54
+ is_revert = ndb.BooleanProperty(required=False, default=False)
55
+ is_sales_transaction = ndb.BooleanProperty(required=False, default=True)
56
+ allow_to_revert = ndb.BooleanProperty(required=False, default=True)
57
+
58
+ reward_expiry_date = ndb.DateProperty(required=False)
59
+
60
+ dict_properties = [
61
+ 'transaction_id', 'invoice_id', 'remarks', 'system_remarks', 'tax_amount', 'transact_amount',
62
+ 'transact_customer_acct', 'transact_outlet_details', 'transact_merchant_acct',
63
+ 'transact_datetime', 'created_datetime', 'transact_outlet_key',
64
+ 'is_sales_transaction', 'allow_to_revert', 'reward_expiry_date',
65
+ 'transact_by', 'transact_by_username',
66
+
67
+ ]
68
+
69
+ @property
70
+ def transact_customer_key(self):
71
+ return ''
72
+
73
+ @property
74
+ def transact_merchant_acct(self):
75
+ return MerchantAcct.fetch(self.transact_merchant.urlsafe())
76
+
77
+ @property
78
+ def transact_outlet_key(self):
79
+ if self.transact_outlet:
80
+ return self.transact_outlet.urlsafe().decode('utf-8')
81
+
82
+ @property
83
+ def transact_merchant_acct_key(self):
84
+ return self.transact_merchant.urlsafe().decode('utf-8')
85
+
86
+ @property
87
+ def transact_by_user(self):
88
+ if self.transact_by:
89
+ return MerchantUser.fetch(self.transact_by.urlsafe())
90
+
91
+ @property
92
+ def transact_user_acct_key(self):
93
+ return self.transact_by.urlsafe()
94
+
95
+ @property
96
+ def after_deduct_tax_sales_amount(self):
97
+ if self.tax_amount:
98
+ return self.transact_amount - self.tax_amount
99
+ else:
100
+ return self.transact_amount
101
+
102
+ @classmethod
103
+ def get_by_invoice_id(cls, invoice_id):
104
+ return cls.query(cls.invoice_id==invoice_id).get()
105
+
106
+ @staticmethod
107
+ def create(transact_amount=.0, tax_amount=.0, invoice_id=None, remarks=None, system_remarks=None,
108
+ transact_outlet=None, transact_by=None, transact_datetime=None,
109
+
110
+ ):
111
+
112
+ transact_by_username = None
113
+
114
+ if is_not_empty(transact_by):
115
+ if isinstance(transact_by, MerchantUser):
116
+ transact_by_username = transact_by.username
117
+
118
+
119
+ transaction_id = generate_transaction_id()
120
+
121
+ if transact_datetime is None:
122
+ transact_datetime = datetime.utcnow()
123
+
124
+ logger.debug('generated transaction_id=%s', transaction_id)
125
+ logger.debug('invoice_id=%s', invoice_id)
126
+ logger.debug('tax_amount=%s', tax_amount)
127
+ logger.debug('transact_amount=%s', transact_amount)
128
+ logger.debug('transact_datetime=%s', transact_datetime)
129
+ logger.debug('transact_by_username=%s', transact_by_username)
130
+ logger.debug('system_remarks=%s', system_remarks)
131
+
132
+ customer_transaction = SalesTransaction(
133
+ transact_merchant = transact_outlet.merchant_acct_entity.create_ndb_key(),
134
+ transact_outlet = transact_outlet.create_ndb_key() if transact_outlet else None,
135
+
136
+ tax_amount = tax_amount,
137
+ transact_amount = transact_amount,
138
+
139
+ transaction_id = transaction_id,
140
+ invoice_id = invoice_id,
141
+ remarks = remarks,
142
+ system_remarks = system_remarks,
143
+
144
+ transact_by = transact_by.create_ndb_key() if transact_by else None,
145
+ transact_by_username = transact_by_username,
146
+
147
+ transact_datetime = transact_datetime,
148
+
149
+ is_sales_transaction = True,
150
+ allow_to_revert = True,
151
+
152
+ )
153
+
154
+ customer_transaction.put()
155
+ #customer.put()
156
+
157
+ return customer_transaction
158
+
159
+ class CustomerTransaction(SalesTransaction):
160
+ '''
161
+ Customer as ancestor
162
+ '''
163
+
164
+
54
165
  entitled_reward_summary = ndb.JsonProperty()
55
166
  entitled_voucher_summary = ndb.JsonProperty()
56
167
  entitled_prepaid_summary = ndb.JsonProperty()
@@ -58,16 +169,13 @@ class CustomerTransaction(BaseNModel, DictModel):
58
169
 
59
170
  reward_giveaway_method = ndb.StringProperty(required=False, default=program_conf.PROGRAM_REWARD_GIVEAWAY_METHOD_SYSTEM)
60
171
 
61
- allow_to_revert = ndb.BooleanProperty(required=False, default=True)
62
172
 
63
- is_revert = ndb.BooleanProperty(required=False, default=False)
64
- reverted_datetime = ndb.DateTimeProperty(required=False)
65
- reverted_by = ndb.KeyProperty(name="reverted_by", kind=MerchantUser)
66
- reverted_by_username = ndb.StringProperty(required=False)
173
+
174
+ is_from_instant_transaction = ndb.BooleanProperty(required=False, default=False)
67
175
 
68
176
  is_reward_redeemed = ndb.BooleanProperty(required=False, default=False)
69
177
 
70
- is_sales_transaction = ndb.BooleanProperty(required=False, default=True)
178
+
71
179
 
72
180
  is_membership_purchase = ndb.BooleanProperty(required=False, default=False)
73
181
  is_membership_renew = ndb.BooleanProperty(required=False, default=False)
@@ -120,23 +228,6 @@ class CustomerTransaction(BaseNModel, DictModel):
120
228
  def transact_customer_acct(self):
121
229
  return Customer.fetch(self.key.parent().urlsafe())
122
230
 
123
- @property
124
- def transact_user_acct_key(self):
125
- return Customer.fetch(self.key.parent().urlsafe()).registered_user_acct_key
126
-
127
- @property
128
- def transact_merchant_acct(self):
129
- return MerchantAcct.fetch(self.transact_merchant.urlsafe())
130
-
131
- @property
132
- def transact_outlet_key(self):
133
- if self.transact_outlet:
134
- return self.transact_outlet.urlsafe().decode('utf-8')
135
-
136
- @property
137
- def transact_merchant_acct_key(self):
138
- return self.transact_merchant.urlsafe().decode('utf-8')
139
-
140
231
  @property
141
232
  def transact_customer_key(self):
142
233
  return self.key.parent().urlsafe().decode('utf-8')
@@ -146,22 +237,16 @@ class CustomerTransaction(BaseNModel, DictModel):
146
237
  if self.transact_outlet:
147
238
  return Outlet.fetch(self.transact_outlet.urlsafe())
148
239
 
149
- @property
150
- def transact_by_user(self):
151
- if self.transact_by:
152
- return MerchantUser.fetch(self.transact_by.urlsafe())
153
-
154
- @property
155
- def after_deduct_tax_sales_amount(self):
156
- if self.tax_amount:
157
- return self.transact_amount - self.tax_amount
158
- else:
159
- return self.transact_amount
160
240
 
161
241
  @property
162
242
  def purchased_merchant_membership_key(self):
163
243
  if self.purchased_merchant_membership:
164
244
  return self.purchased_merchant_membership.urlsafe().decode('utf-8')
245
+
246
+ @property
247
+ def purchased_merchant_membership_entity(self):
248
+ if self.purchased_merchant_membership:
249
+ return MerchantMembership.fetch(self.purchased_merchant_membership.urlsafe())
165
250
 
166
251
  @property
167
252
  def purchased_customer_membership_entity(self):
@@ -453,10 +538,6 @@ class CustomerTransaction(BaseNModel, DictModel):
453
538
  def get_by_transaction_id(transaction_id):
454
539
  return CustomerTransaction.query(CustomerTransaction.transaction_id==transaction_id).get()
455
540
 
456
- @staticmethod
457
- def get_by_invoice_id(invoice_id):
458
- return CustomerTransaction.query(CustomerTransaction.invoice_id==invoice_id).get()
459
-
460
541
  @staticmethod
461
542
  def list_transaction_by_date(transact_date, transact_outlet=None, including_reverted_transaction=True, offset=0, limit=conf.PAGINATION_SIZE, start_cursor=None, return_with_cursor=False):
462
543
 
File without changes
File without changes
File without changes
File without changes
File without changes