ob-dj-store 0.0.18.4__py3-none-any.whl → 0.0.18.7__py3-none-any.whl
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.
- ob_dj_store/apis/stores/rest/serializers/serializers.py +12 -0
- ob_dj_store/core/stores/admin.py +1 -0
- ob_dj_store/core/stores/models/_cart.py +6 -3
- ob_dj_store/core/stores/utils.py +10 -0
- {ob_dj_store-0.0.18.4.dist-info → ob_dj_store-0.0.18.7.dist-info}/METADATA +1 -1
- {ob_dj_store-0.0.18.4.dist-info → ob_dj_store-0.0.18.7.dist-info}/RECORD +8 -8
- {ob_dj_store-0.0.18.4.dist-info → ob_dj_store-0.0.18.7.dist-info}/WHEEL +0 -0
- {ob_dj_store-0.0.18.4.dist-info → ob_dj_store-0.0.18.7.dist-info}/top_level.txt +0 -0
@@ -1116,6 +1116,7 @@ class StoreSerializer(ArabicFieldsMixin, FavoriteMixin, serializers.ModelSeriali
|
|
1116
1116
|
"image",
|
1117
1117
|
"busy_mode",
|
1118
1118
|
"name_arabic",
|
1119
|
+
"is_open_after_midnight",
|
1119
1120
|
)
|
1120
1121
|
extra_kwargs = {
|
1121
1122
|
"image": {"read_only": True, "required": False},
|
@@ -1124,9 +1125,20 @@ class StoreSerializer(ArabicFieldsMixin, FavoriteMixin, serializers.ModelSeriali
|
|
1124
1125
|
def get_is_closed(self, obj):
|
1125
1126
|
if obj.busy_mode:
|
1126
1127
|
return True
|
1128
|
+
|
1127
1129
|
current_time = localtime(now())
|
1128
1130
|
current_op_hour = obj.current_opening_hours
|
1129
1131
|
if current_op_hour:
|
1132
|
+
|
1133
|
+
if obj.is_open_after_midnight:
|
1134
|
+
return (
|
1135
|
+
True
|
1136
|
+
if current_op_hour.to_hour
|
1137
|
+
< current_time.time()
|
1138
|
+
< current_op_hour.from_hour
|
1139
|
+
else False
|
1140
|
+
)
|
1141
|
+
|
1130
1142
|
if current_op_hour.always_open:
|
1131
1143
|
return False
|
1132
1144
|
return (
|
ob_dj_store/core/stores/admin.py
CHANGED
@@ -8,6 +8,7 @@ from django.utils.translation import gettext_lazy as _
|
|
8
8
|
|
9
9
|
from ob_dj_store.core.stores.managers import CartItemManager, CartManager
|
10
10
|
from ob_dj_store.core.stores.models._partner import PartnerAuthInfo
|
11
|
+
from ob_dj_store.core.stores.utils import round_up_tie
|
11
12
|
|
12
13
|
|
13
14
|
class Cart(models.Model):
|
@@ -32,7 +33,7 @@ class Cart(models.Model):
|
|
32
33
|
amount = Decimal(
|
33
34
|
sum(map(lambda item: Decimal(item.tax_amount), self.items.all()))
|
34
35
|
)
|
35
|
-
return amount
|
36
|
+
return round_up_tie(amount, 3)
|
36
37
|
|
37
38
|
def get_applied_tax_amount(self):
|
38
39
|
tax_amount = 0
|
@@ -75,11 +76,13 @@ class Cart(models.Model):
|
|
75
76
|
|
76
77
|
@property
|
77
78
|
def discount_offer_amount(self):
|
78
|
-
return
|
79
|
+
return round_up_tie(
|
80
|
+
sum(map(lambda item: item.discount_amount, self.items.all())), 3
|
81
|
+
)
|
79
82
|
|
80
83
|
@property
|
81
84
|
def total_price_with_discount(self):
|
82
|
-
return self.total_price - self.discount_offer_amount
|
85
|
+
return self.total_price - Decimal(self.discount_offer_amount)
|
83
86
|
|
84
87
|
def __str__(self):
|
85
88
|
return f"Cart - {self.customer.email} with total price {self.total_price}"
|
ob_dj_store/core/stores/utils.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import math
|
2
2
|
from datetime import timedelta
|
3
|
+
from decimal import ROUND_HALF_UP, Decimal
|
3
4
|
|
4
5
|
import pycountry
|
5
6
|
from django.core.exceptions import ValidationError
|
@@ -80,6 +81,15 @@ def validate_currency(value):
|
|
80
81
|
)
|
81
82
|
|
82
83
|
|
84
|
+
def round_up_tie(value, decimal_places=3):
|
85
|
+
"""Helper function to always round up when the 4th decimal is a 5"""
|
86
|
+
decimal_value = Decimal(str(value))
|
87
|
+
rounded_value = decimal_value.quantize(
|
88
|
+
Decimal("1e-{0}".format(decimal_places)), rounding=ROUND_HALF_UP
|
89
|
+
)
|
90
|
+
return Decimal(rounded_value)
|
91
|
+
|
92
|
+
|
83
93
|
def get_arabic_fields(model, static_fields):
|
84
94
|
all_fields = [field.name for field in model._meta.get_fields()]
|
85
95
|
arabic_fields = {
|
@@ -3,20 +3,20 @@ ob_dj_store/apis/stores/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
|
|
3
3
|
ob_dj_store/apis/stores/filters.py,sha256=zKBXPBoqIyFlSeZOECp97RTWvSLqNPnlPhEp7p8W5tE,9702
|
4
4
|
ob_dj_store/apis/stores/urls.py,sha256=7vwogfIGcKS0hHYK3iBXKQwi1kCA_vuHY1eZt8rAspg,2021
|
5
5
|
ob_dj_store/apis/stores/views.py,sha256=aE4LFPHzs_CtzZ8K5-vAbDn_51hyhi0KIsi7cV8dpkA,43372
|
6
|
-
ob_dj_store/apis/stores/rest/serializers/serializers.py,sha256=
|
6
|
+
ob_dj_store/apis/stores/rest/serializers/serializers.py,sha256=yZHKYh77rc37-Ve0MwuDOcf5NoCtlh20hRfP8H2hxCc,63194
|
7
7
|
ob_dj_store/apis/tap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
8
|
ob_dj_store/apis/tap/serializers.py,sha256=KPrBK4h2-fWvEVf6vOj2ww5-USV9WqpyYicIqoHIiXI,1065
|
9
9
|
ob_dj_store/apis/tap/urls.py,sha256=bnOTv6an11kxpo_FdqlhsizlGPLVpNxBjCyKcf3_C9M,367
|
10
10
|
ob_dj_store/apis/tap/views.py,sha256=R_4EJRjsgLKcIN-B3b5T_rb_IgOJhU2r4xLSlnasnWo,2665
|
11
11
|
ob_dj_store/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
12
|
ob_dj_store/core/stores/__init__.py,sha256=-izNGrxNn_nn3IQXd5pkuES9lSF-AHYb14yhNPozYCI,65
|
13
|
-
ob_dj_store/core/stores/admin.py,sha256=
|
13
|
+
ob_dj_store/core/stores/admin.py,sha256=FXu87VzZPaT1KXf3haY4YjzkK_FjxQp2A-JZXUkwA2I,13499
|
14
14
|
ob_dj_store/core/stores/admin_inlines.py,sha256=2K8iDmP4h0CLIOqy3x-ZXXpgYnT2jqL4cg5YFdiho8s,2976
|
15
15
|
ob_dj_store/core/stores/apps.py,sha256=ZadmEER_dNcQTH617b3fAsYZJSyRw0g46Kjp4eOAsOU,498
|
16
16
|
ob_dj_store/core/stores/managers.py,sha256=lz2CE4PJCI1ViO-CU61LqTr43O41aGRQkbWZUR5Fmfg,9909
|
17
17
|
ob_dj_store/core/stores/receivers.py,sha256=DljYC97C_e1mHduKw9Un6YQmxIdwSIter7yVVZwggFA,3768
|
18
18
|
ob_dj_store/core/stores/settings_validation.py,sha256=eTkRaI6CG5OEJQyI5CF-cNAcvjzXf3GwX5sR97O3v98,3977
|
19
|
-
ob_dj_store/core/stores/utils.py,sha256
|
19
|
+
ob_dj_store/core/stores/utils.py,sha256=-oHJot3pLF2sLE3Bv0AU_qXFshNOAO3h8Y1yMfgF6K8,3439
|
20
20
|
ob_dj_store/core/stores/gateway/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
21
21
|
ob_dj_store/core/stores/gateway/tap/__init__.py,sha256=5Z6azpb6tmr1nRvKwQWzlYw9ruvw-9ZMBWRqEngDKTM,40
|
22
22
|
ob_dj_store/core/stores/gateway/tap/admin.py,sha256=3KgawxLjvpMsYXl_hx1DlKYpsMd-ojSA4FNazVA4CIk,1183
|
@@ -141,7 +141,7 @@ ob_dj_store/core/stores/migrations/0105_store_is_open_after_midnight.py,sha256=8
|
|
141
141
|
ob_dj_store/core/stores/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
142
142
|
ob_dj_store/core/stores/models/__init__.py,sha256=VeWrDiIbw94ZDSFD-62rz9iTTW87iPdwDW5jcjxm7bs,2045
|
143
143
|
ob_dj_store/core/stores/models/_address.py,sha256=8zV444A8M7P8yqQHjEOCROUykWPQ1ndSdd2IIX8wwWY,2207
|
144
|
-
ob_dj_store/core/stores/models/_cart.py,sha256=
|
144
|
+
ob_dj_store/core/stores/models/_cart.py,sha256=I5Mv-OkmV3W26GLPpNBAEaDRsbSbfPCJGJ1-MR6fG4Y,7210
|
145
145
|
ob_dj_store/core/stores/models/_favorite.py,sha256=3yyMCoiftGOPAQwkMI2J29r3x6NJsRYri9f8gXiF1e8,3306
|
146
146
|
ob_dj_store/core/stores/models/_feedback.py,sha256=eCUVgprNK5hSRKOS4M_pdR7QH2-rqhoYevlpykhCOLg,1472
|
147
147
|
ob_dj_store/core/stores/models/_inventory.py,sha256=ZU8xDMQZxLnFehkBEGWr-os4AF1IlCn5XnBxvRq9IAs,4314
|
@@ -155,7 +155,7 @@ ob_dj_store/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
|
|
155
155
|
ob_dj_store/utils/helpers.py,sha256=o7wgypM7mI2vZqZKkhxnTcnHJC8GMQDOuYMnRwXr6tY,2058
|
156
156
|
ob_dj_store/utils/model.py,sha256=DV7hOhTaZL3gh9sptts2jTUFlTArKG3i7oPioq9HLFE,303
|
157
157
|
ob_dj_store/utils/utils.py,sha256=8UVAFB56qUSjJJ5f9vnermtw638gdFy4CFRCuMbns_M,1342
|
158
|
-
ob_dj_store-0.0.18.
|
159
|
-
ob_dj_store-0.0.18.
|
160
|
-
ob_dj_store-0.0.18.
|
161
|
-
ob_dj_store-0.0.18.
|
158
|
+
ob_dj_store-0.0.18.7.dist-info/METADATA,sha256=u585C53kGBFTWdVM-y8tzELuzCdvJUSGM7I98KUKpn0,2827
|
159
|
+
ob_dj_store-0.0.18.7.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
160
|
+
ob_dj_store-0.0.18.7.dist-info/top_level.txt,sha256=CZG3G0ptTkzGnc0dFYN-ZD7YKdJBmm47bsmGwofD_lk,12
|
161
|
+
ob_dj_store-0.0.18.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|