diff --git a/accounts/admin.py b/accounts/admin.py index 1d58e16..5530abc 100644 --- a/accounts/admin.py +++ b/accounts/admin.py @@ -33,9 +33,9 @@ class ProfileAdmin(admin.ModelAdmin): @admin.register(Company) class CompanyAdmin(admin.ModelAdmin): - list_display = ['name', 'logo', 'signature', 'address', 'phone'] + list_display = ['name', 'logo', 'signature', 'address', 'phone', 'broker'] prepopulated_fields = {'slug': ('name',)} search_fields = ['name', 'address', 'phone'] - list_filter = ['is_active'] + list_filter = ['is_active', 'broker'] date_hierarchy = 'created' ordering = ['-created'] \ No newline at end of file diff --git a/accounts/migrations/0002_company_broker.py b/accounts/migrations/0002_company_broker.py new file mode 100644 index 0000000..df12560 --- /dev/null +++ b/accounts/migrations/0002_company_broker.py @@ -0,0 +1,20 @@ +# Generated by Django 5.2.4 on 2025-09-07 13:43 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0001_initial'), + ('locations', '0003_remove_broker_company'), + ] + + operations = [ + migrations.AddField( + model_name='company', + name='broker', + field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='company', to='locations.broker', verbose_name='کارگزار'), + ), + ] diff --git a/accounts/migrations/0003_company_account_number_company_bank_name_and_more.py b/accounts/migrations/0003_company_account_number_company_bank_name_and_more.py new file mode 100644 index 0000000..6e692ff --- /dev/null +++ b/accounts/migrations/0003_company_account_number_company_bank_name_and_more.py @@ -0,0 +1,34 @@ +# Generated by Django 5.2.4 on 2025-09-07 14:11 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0002_company_broker'), + ] + + operations = [ + migrations.AddField( + model_name='company', + name='account_number', + field=models.CharField(blank=True, max_length=20, null=True, validators=[django.core.validators.RegexValidator(code='invalid_account_number', message='شماره حساب باید فقط شامل اعداد باشد.', regex='^\\d+$')], verbose_name='شماره حساب'), + ), + migrations.AddField( + model_name='company', + name='bank_name', + field=models.CharField(blank=True, choices=[('mellat', 'بانک ملت'), ('saman', 'بانک سامان'), ('parsian', 'بانک پارسیان'), ('sina', 'بانک سینا'), ('tejarat', 'بانک تجارت'), ('tosee', 'بانک توسعه'), ('iran_zamin', 'بانک ایران زمین'), ('meli', 'بانک ملی'), ('saderat', 'بانک توسعه صادرات'), ('iran_zamin', 'بانک ایران زمین'), ('refah', 'بانک رفاه'), ('eghtesad_novin', 'بانک اقتصاد نوین'), ('pasargad', 'بانک پاسارگاد'), ('other', 'سایر')], max_length=255, null=True, verbose_name='نام بانک'), + ), + migrations.AddField( + model_name='company', + name='card_number', + field=models.CharField(blank=True, max_length=16, null=True, validators=[django.core.validators.RegexValidator(code='invalid_card_number', message='شماره کارت باید فقط شامل اعداد باشد.', regex='^\\d+$')], verbose_name='شماره کارت'), + ), + migrations.AddField( + model_name='company', + name='sheba_number', + field=models.CharField(blank=True, max_length=30, null=True, verbose_name='شماره شبا'), + ), + ] diff --git a/accounts/migrations/0004_company_branch_name.py b/accounts/migrations/0004_company_branch_name.py new file mode 100644 index 0000000..25114e1 --- /dev/null +++ b/accounts/migrations/0004_company_branch_name.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.4 on 2025-09-07 14:12 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0003_company_account_number_company_bank_name_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='company', + name='branch_name', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='شعبه بانک'), + ), + ] diff --git a/accounts/models.py b/accounts/models.py index a94311a..c1e78fd 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -181,11 +181,82 @@ class Profile(BaseModel): class Company(NameSlugModel): - logo = models.ImageField(upload_to='companies/logos', null=True, blank=True, verbose_name='لوگوی شرکت') - signature = models.ImageField(upload_to='companies/signatures', null=True, blank=True, verbose_name='امضای شرکت') - address = models.TextField(null=True, blank=True, verbose_name='آدرس') - phone = models.CharField(max_length=11, null=True, blank=True, verbose_name='شماره تماس') - + logo = models.ImageField( + upload_to='companies/logos', + null=True, + blank=True, + verbose_name='لوگوی شرکت' + ) + signature = models.ImageField( + upload_to='companies/signatures', + null=True, + blank=True, + verbose_name='امضای شرکت' + ) + address = models.TextField( + null=True, + blank=True, + verbose_name='آدرس' + ) + phone = models.CharField( + max_length=11, + null=True, + blank=True, + verbose_name='شماره تماس' + ) + broker = models.OneToOneField( + Broker, + on_delete=models.SET_NULL, + verbose_name="کارگزار", + null=True, + blank=True, + related_name='company' + ) + card_number = models.CharField( + max_length=16, + null=True, + verbose_name="شماره کارت", + blank=True, + validators=[ + RegexValidator( + regex=r'^\d+$', + message='شماره کارت باید فقط شامل اعداد باشد.', + code='invalid_card_number' + ) + ] + ) + account_number = models.CharField( + max_length=20, + null=True, + verbose_name="شماره حساب", + blank=True, + validators=[ + RegexValidator( + regex=r'^\d+$', + message='شماره حساب باید فقط شامل اعداد باشد.', + code='invalid_account_number' + ) + ] + ) + sheba_number = models.CharField( + max_length=30, + null=True, + verbose_name="شماره شبا", + blank=True, + ) + bank_name = models.CharField( + max_length=255, + choices=BANK_CHOICES, + null=True, + verbose_name="نام بانک", + blank=True + ) + branch_name = models.CharField( + max_length=255, + null=True, + verbose_name="شعبه بانک", + blank=True + ) class Meta: verbose_name = 'شرکت' verbose_name_plural = 'شرکت‌ها' diff --git a/db.sqlite3 b/db.sqlite3 index e02ec79..94e4e20 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/invoices/templates/invoices/quote_preview_step.html b/invoices/templates/invoices/quote_preview_step.html index e6e405a..509c138 100644 --- a/invoices/templates/invoices/quote_preview_step.html +++ b/invoices/templates/invoices/quote_preview_step.html @@ -24,6 +24,10 @@ {% block content %} {% include '_toasts.html' %} + + +{% instance_info_modal instance %} + {% csrf_token %}
@@ -32,15 +36,17 @@

{{ step.name }}: {{ instance.process.name }}

- اشتراک آب: {{ instance.well.water_subscription_number|default:"-" }} - | نماینده: {{ instance.representative.profile.national_code|default:"-" }} + {% instance_info instance %}
@@ -50,100 +56,116 @@
-
+
-
- - شرکت آب منطقه‌ای + +
+
+ + {% if instance.broker.company %} + لوگوی شرکت + {% else %} + + {% endif %} + +
+
+
+ {% if instance.broker.company %} + {{ instance.broker.company.name }} + {% else %} + شرکت آب منطقه‌ای + {% endif %} +
+ {% if instance.broker.company %} +
+ {% if instance.broker.company.address %} +
{{ instance.broker.company.address }}
+ {% endif %} + {% if instance.broker.affairs.county.city.name %} +
{{ instance.broker.affairs.county.city.name }}، ایران
+ {% endif %} + {% if instance.broker.company.phone %} +
{{ instance.broker.company.phone }}
+ {% endif %} +
+ {% endif %} +
-

دفتر مرکزی، خیابان اصلی

-

تهران، ایران

-

۰۲۱-۱۲۳۴۵۶۷۸

-
-

پیش‌فاکتور #{{ quote.name }}

-
- تاریخ صدور: - {{ quote.jcreated }} + +
+
+
#{{ quote.name }}
-
- معتبر تا: - {{ quote.valid_until|date:"Y/m/d" }} +
+
+ تاریخ صدور: + {{ quote.jcreated_date }} +

-
-
-
-
صادر شده برای:
-

{{ quote.customer.get_full_name }}

- {% if instance.representative.profile %} -

کد ملی: {{ instance.representative.profile.national_code }}

-

{{ instance.representative.profile.address|default:"آدرس نامشخص" }}

-

{{ instance.representative.profile.phone_number_1|default:"" }}

- {% endif %} +
+
+
+
+
+
+ اطلاعات مشترک +
+
+ نام: + {{ quote.customer.get_full_name }} +
+ {% if instance.representative.profile.national_code %} +
+ کد ملی: + {{ instance.representative.profile.national_code }} +
+ {% endif %} + {% if instance.representative.profile.phone_number_1 %} +
+ تلفن: + {{ instance.representative.profile.phone_number_1 }} +
+ {% endif %} + {% if instance.representative.profile.address %} +
+ آدرس: + {{ instance.representative.profile.address }} +
+ {% endif %} + +
+
-
-
اطلاعات چاه:
- - - - - - - - - - - - - - - - - - - - - - - -
شماره اشتراک آب:{{ instance.well.water_subscription_number }}
شماره اشتراک برق:{{ instance.well.electricity_subscription_number|default:"-" }}
سریال کنتور:{{ instance.well.water_meter_serial_number|default:"-" }}
قدرت چاه:{{ instance.well.well_power|default:"-" }}
کد درخواست:{{ instance.code }}
+
+
+
+
+ اطلاعات چاه +
+
+ شماره اشتراک آب: + {{ instance.well.water_subscription_number }} +
+
+ شماره اشتراک برق: + {{ instance.well.electricity_subscription_number|default:"-" }} +
+
+ سریال کنتور: + {{ instance.well.water_meter_serial_number|default:"-" }} +
+
+ قدرت چاه: + {{ instance.well.well_power|default:"-" }} +
+
+
@@ -170,11 +192,6 @@ {% endfor %} -

- صادر کننده: - {{ quote.created_by.get_full_name }} -

- با تشکر از انتخاب شما

جمع کل:

@@ -193,6 +210,72 @@ + +
+
+
+
شرایط و ضوابط:
+
    +
  • + + اعتبار پیش‌فاکتور صادر شده ۴۸ ساعت پس از تاریخ صدور می‌باشد +
  • +
  • + + مبلغ فوق به صورت علی‌الحساب دریافت می‌گردد +
  • +
  • + + این برگه صرفاً جهت اعلام قیمت بوده و ارزش قانونی دیگری ندارد +
  • + {% if instance.broker.company.signature %} +
  • + امضای شرکت +
  • + {% endif %} +
+
+ {% if instance.broker.company %} +
+
اطلاعات پرداخت:
+
+ {% if instance.broker.company.card_number %} +
+ شماره کارت: +
{{ instance.broker.company.card_number }}
+
+ {% endif %} + {% if instance.broker.company.account_number %} +
+ شماره حساب: +
{{ instance.broker.company.account_number }}
+
+ {% endif %} + {% if instance.broker.company.sheba_number %} +
+ شماره شبا: +
{{ instance.broker.company.sheba_number }}
+
+ {% endif %} + {% if instance.broker.company.bank_name %} +
+ بانک: +
{{ instance.broker.company.get_bank_name_display }}
+
+ {% endif %} + {% if instance.broker.company.branch_name %} +
+ شعبه: +
{{ instance.broker.company.branch_name }}
+
+ {% endif %} + +
+ +
+ {% endif %} +
+
{% if quote.notes %} diff --git a/invoices/templates/invoices/quote_print.html b/invoices/templates/invoices/quote_print.html index 7296d12..282ff44 100644 --- a/invoices/templates/invoices/quote_print.html +++ b/invoices/templates/invoices/quote_print.html @@ -5,8 +5,24 @@ پیش‌فاکتور {{ quote.name }} - {{ instance.code }} - - + {% load static %} + {% load humanize %} + + + + + + + + + + + + + + + +