Merge branch 'main' of http://10.10.1.136:3000/ismail/haikal into frontend

This commit is contained in:
Faheed 2025-09-11 18:26:27 +03:00
commit c3fe1817c3
2 changed files with 35 additions and 33 deletions

View File

@ -53,6 +53,7 @@ from encrypted_model_fields.fields import (
EncryptedCharField,
EncryptedDateField,
EncryptedEmailField,
EncryptedTextField,
)
# from plans.models import AbstractPlan
# from simple_history.models import HistoricalRecords
@ -621,7 +622,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()
@ -1491,7 +1492,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 = models.CharField(
phone_number = EncryptedCharField(
max_length=255,
verbose_name=_("Phone Number"),
validators=[SaudiPhoneNumberValidator()],
@ -1499,7 +1500,7 @@ class Staff(models.Model):
staff_type = models.CharField(
choices=StaffTypes.choices, max_length=255, verbose_name=_("Staff Type")
)
address = models.CharField(
address = EncryptedCharField(
max_length=200, blank=True, null=True, verbose_name=_("Address")
)
logo = models.ImageField(
@ -1803,22 +1804,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
@ -1837,9 +1838,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:
@ -1906,13 +1907,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 = models.EmailField(verbose_name=_("Email"))
phone_number = models.CharField(
email = EncryptedEmailField(verbose_name=_("Email"))
phone_number = EncryptedCharField(
max_length=255,
verbose_name=_("Phone Number"),
validators=[SaudiPhoneNumberValidator()],
)
address = models.CharField(
address = EncryptedCharField(
max_length=200, blank=True, null=True, verbose_name=_("Address")
)
logo = models.ImageField(
@ -1968,9 +1969,9 @@ class Organization(models.Model, LocalizedNameMixin):
commit=False,
customer_model_kwargs={
"customer_name": self.name,
"address_1": self.address,
"phone": self.phone_number,
"email": self.email,
"address_1": "",
# "phone": self.phone_number,
# "email": self.email,
},
)
try:
@ -1991,16 +1992,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
@ -2072,13 +2073,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 = models.EmailField(verbose_name=_("Email"))
phone_number = models.CharField(
email = EncryptedEmailField(verbose_name=_("Email"))
phone_number = EncryptedCharField(
max_length=255,
verbose_name=_("Phone Number"),
validators=[SaudiPhoneNumberValidator()],
)
address = models.CharField(
address = EncryptedCharField(
max_length=200, blank=True, null=True, verbose_name=_("Address")
)
lead_type = models.CharField(
@ -3572,7 +3573,7 @@ class PaymentHistory(models.Model):
blank=False,
related_name="payments",
)
user_data = models.JSONField(null=True, blank=True)
user_data = EncryptedTextField(null=True, blank=True)
amount = models.DecimalField(
max_digits=10, decimal_places=2, validators=[MinValueValidator(0.01)]
)
@ -3591,7 +3592,7 @@ class PaymentHistory(models.Model):
order_reference = models.CharField(max_length=100, blank=True, null=True)
# Payment processor details
gateway_response = models.JSONField(
gateway_response = EncryptedTextField(
blank=True, null=True
) # Raw response from payment gateway
gateway_name = models.CharField(max_length=50, blank=True, null=True)

View File

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