Compare commits

..

No commits in common. "c3fe1817c3ca400be7fdaf835b784937fbe268fa" and "17a881f20a2a71a2ba200b73fdf4203722179d8a" have entirely different histories.

2 changed files with 33 additions and 35 deletions

View File

@ -53,7 +53,6 @@ from encrypted_model_fields.fields import (
EncryptedCharField,
EncryptedDateField,
EncryptedEmailField,
EncryptedTextField,
)
# from plans.models import AbstractPlan
# from simple_history.models import HistoricalRecords
@ -622,7 +621,7 @@ class AdditionalServices(models.Model, LocalizedNameMixin):
if self.taxable
else self.price
)
@property
def service_tax(self):
vat = VatRate.objects.filter(dealer=self.dealer, is_active=True).first()
@ -1492,7 +1491,7 @@ class Staff(models.Model):
last_name = models.CharField(max_length=255, verbose_name=_("Last Name"))
arabic_name = models.CharField(max_length=255, verbose_name=_("Arabic Name"),null=True,blank=True)
phone_number = EncryptedCharField(
phone_number = models.CharField(
max_length=255,
verbose_name=_("Phone Number"),
validators=[SaudiPhoneNumberValidator()],
@ -1500,7 +1499,7 @@ class Staff(models.Model):
staff_type = models.CharField(
choices=StaffTypes.choices, max_length=255, verbose_name=_("Staff Type")
)
address = EncryptedCharField(
address = models.CharField(
max_length=200, blank=True, null=True, verbose_name=_("Address")
)
logo = models.ImageField(
@ -1804,22 +1803,22 @@ class Customer(models.Model):
return f"{self.first_name} {self.last_name}"
def create_customer_model(self, for_lead=False):
# customer_dict = to_dict(self)
customer_dict = to_dict(self)
customer = self.dealer.entity.get_customers().filter(email=self.email).first()
if not customer:
customer = self.dealer.entity.create_customer(
commit=False,
customer_model_kwargs={
"customer_name": self.full_name,
"address_1": "",#self.address,
# "phone": self.phone_number,
# "email": self.email,
"address_1": self.address,
"phone": self.phone_number,
"email": self.email,
},
)
# try:
# customer.additional_info.update({"customer_info": customer_dict})
# except Exception:
# pass
try:
customer.additional_info.update({"customer_info": customer_dict})
except Exception:
pass
customer.active = False if for_lead else True
customer.save()
self.customer_model = customer
@ -1838,9 +1837,9 @@ class Customer(models.Model):
customer_dict = to_dict(self)
customer = self.customer_model
customer.customer_name = self.full_name
# customer.address_1 = self.address
# customer.phone = self.phone_number
# customer.email = self.email
customer.address_1 = self.address
customer.phone = self.phone_number
customer.email = self.email
try:
customer.additional_info.update({"customer_info": customer_dict})
except Exception:
@ -1907,13 +1906,13 @@ class Organization(models.Model, LocalizedNameMixin):
max_length=15, verbose_name=_("Commercial Registration Number")
)
vrn = models.CharField(max_length=15, verbose_name=_("VAT Registration Number"))
email = EncryptedEmailField(verbose_name=_("Email"))
phone_number = EncryptedCharField(
email = models.EmailField(verbose_name=_("Email"))
phone_number = models.CharField(
max_length=255,
verbose_name=_("Phone Number"),
validators=[SaudiPhoneNumberValidator()],
)
address = EncryptedCharField(
address = models.CharField(
max_length=200, blank=True, null=True, verbose_name=_("Address")
)
logo = models.ImageField(
@ -1969,9 +1968,9 @@ class Organization(models.Model, LocalizedNameMixin):
commit=False,
customer_model_kwargs={
"customer_name": self.name,
"address_1": "",
# "phone": self.phone_number,
# "email": self.email,
"address_1": self.address,
"phone": self.phone_number,
"email": self.email,
},
)
try:
@ -1992,16 +1991,16 @@ class Organization(models.Model, LocalizedNameMixin):
return user
def update_customer_model(self):
# customer_dict = to_dict(self)
customer_dict = to_dict(self)
customer = self.customer_model
customer.customer_name = self.name
# customer.address_1 = self.address
# customer.phone = self.phone_number
# customer.email = self.email
# try:
# customer.additional_info.update({"customer_info": customer_dict})
# except Exception:
# pass
customer.address_1 = self.address
customer.phone = self.phone_number
customer.email = self.email
try:
customer.additional_info.update({"customer_info": customer_dict})
except Exception:
pass
customer.save()
return customer
@ -2073,13 +2072,13 @@ class Lead(models.Model):
dealer = models.ForeignKey(Dealer, on_delete=models.CASCADE, related_name="leads")
first_name = models.CharField(max_length=50, verbose_name=_("First Name"))
last_name = models.CharField(max_length=50, verbose_name=_("Last Name"))
email = EncryptedEmailField(verbose_name=_("Email"))
phone_number = EncryptedCharField(
email = models.EmailField(verbose_name=_("Email"))
phone_number = models.CharField(
max_length=255,
verbose_name=_("Phone Number"),
validators=[SaudiPhoneNumberValidator()],
)
address = EncryptedCharField(
address = models.CharField(
max_length=200, blank=True, null=True, verbose_name=_("Address")
)
lead_type = models.CharField(
@ -3573,7 +3572,7 @@ class PaymentHistory(models.Model):
blank=False,
related_name="payments",
)
user_data = EncryptedTextField(null=True, blank=True)
user_data = models.JSONField(null=True, blank=True)
amount = models.DecimalField(
max_digits=10, decimal_places=2, validators=[MinValueValidator(0.01)]
)
@ -3592,7 +3591,7 @@ class PaymentHistory(models.Model):
order_reference = models.CharField(max_length=100, blank=True, null=True)
# Payment processor details
gateway_response = EncryptedTextField(
gateway_response = models.JSONField(
blank=True, null=True
) # Raw response from payment gateway
gateway_name = models.CharField(max_length=50, blank=True, null=True)

View File

@ -21,7 +21,6 @@ from django_ledger.models import (
EstimateModel,
BillModel,
ChartOfAccountModel,
CustomerModel
)
from . import models
from django.utils.timezone import now