Merge branch 'new_branch'
This commit is contained in:
commit
82ed9b20ac
2
.gitignore
vendored
2
.gitignore
vendored
@ -17,7 +17,7 @@ media
|
|||||||
.idea/**/usage.statistics.xml
|
.idea/**/usage.statistics.xml
|
||||||
.idea/**/dictionaries
|
.idea/**/dictionaries
|
||||||
.idea/**/shelf
|
.idea/**/shelf
|
||||||
|
Makefile
|
||||||
# AWS User-specific
|
# AWS User-specific
|
||||||
.idea/**/aws.xml
|
.idea/**/aws.xml
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,10 @@ import django_tables2 as tables
|
|||||||
from django.forms import formset_factory
|
from django.forms import formset_factory
|
||||||
|
|
||||||
|
|
||||||
|
class AdditionalServiceForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = AdditionalServices
|
||||||
|
fields = ['name', 'price','description','taxable', 'uom']
|
||||||
|
|
||||||
class PaymentForm(forms.ModelForm):
|
class PaymentForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|||||||
17
inventory/migrations/0031_remove_salequotation_entity.py
Normal file
17
inventory/migrations/0031_remove_salequotation_entity.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Generated by Django 4.2.17 on 2024-12-26 07:58
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('inventory', '0030_account'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='salequotation',
|
||||||
|
name='entity',
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
# Generated by Django 4.2.17 on 2024-12-26 08:02
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('inventory', '0031_remove_salequotation_entity'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='additionalservices',
|
||||||
|
name='vatable',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='additionalservices',
|
||||||
|
name='taxable',
|
||||||
|
field=models.BooleanField(default=False, verbose_name='taxable'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -148,6 +148,9 @@ class AdditionalServices(models.Model, LocalizedNameMixin):
|
|||||||
arabic_name = models.CharField(max_length=255, verbose_name=_("Arabic Name"))
|
arabic_name = models.CharField(max_length=255, verbose_name=_("Arabic Name"))
|
||||||
description = models.TextField(verbose_name=_("Description"))
|
description = models.TextField(verbose_name=_("Description"))
|
||||||
price = models.DecimalField(max_digits=14, decimal_places=2, verbose_name=_("Price"))
|
price = models.DecimalField(max_digits=14, decimal_places=2, verbose_name=_("Price"))
|
||||||
|
taxable = models.BooleanField(default=False, verbose_name=_("taxable"))
|
||||||
|
uom = models.CharField(max_length=10, choices=UNIT_CHOICES, verbose_name=_("Unit of Measurement"))
|
||||||
|
dealer = models.ForeignKey("Dealer", on_delete=models.CASCADE, verbose_name=_("Dealer"))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("Additional Services")
|
verbose_name = _("Additional Services")
|
||||||
|
|||||||
@ -5,10 +5,12 @@ from django.dispatch import receiver
|
|||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django_ledger.models import EntityModel
|
from django_ledger.models import EntityModel
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django.contrib.auth import get_user_model
|
||||||
|
from django_ledger.io import roles
|
||||||
|
from django_ledger.models import EntityModel,AccountModel,ItemModel,ItemModelAbstract,UnitOfMeasureModel
|
||||||
from . import models
|
from . import models
|
||||||
|
|
||||||
|
User = get_user_model()
|
||||||
|
|
||||||
# @receiver(post_save, sender=models.SaleQuotation)
|
# @receiver(post_save, sender=models.SaleQuotation)
|
||||||
# def link_quotation_to_entity(sender, instance, created, **kwargs):
|
# def link_quotation_to_entity(sender, instance, created, **kwargs):
|
||||||
@ -22,6 +24,25 @@ from . import models
|
|||||||
# user = instance.user
|
# user = instance.user
|
||||||
# if user:
|
# if user:
|
||||||
# user.delete()
|
# user.delete()
|
||||||
|
|
||||||
|
@receiver(post_save, sender=User)
|
||||||
|
def create_dealer(instance, created, *args, **kwargs):
|
||||||
|
if created:
|
||||||
|
models.Dealer.objects.create(user=instance,name=instance.username,email=instance.email)
|
||||||
|
|
||||||
|
@receiver(post_save, sender=models.Dealer)
|
||||||
|
def create_user_account(sender, instance, created, **kwargs):
|
||||||
|
if created:
|
||||||
|
if instance.dealer_type != "Owner":
|
||||||
|
user = User.objects.create_user(
|
||||||
|
username=instance.name,
|
||||||
|
email=instance.email,
|
||||||
|
)
|
||||||
|
user.set_password("Tenhal@123")
|
||||||
|
user.save()
|
||||||
|
instance.user = user
|
||||||
|
instance.save()
|
||||||
|
|
||||||
@receiver(post_save, sender=models.Car)
|
@receiver(post_save, sender=models.Car)
|
||||||
def create_car_location(sender, instance, created, **kwargs):
|
def create_car_location(sender, instance, created, **kwargs):
|
||||||
"""
|
"""
|
||||||
@ -62,71 +83,106 @@ def update_car_status_on_reservation_delete(sender, instance, **kwargs):
|
|||||||
# Create Entity
|
# Create Entity
|
||||||
@receiver(post_save, sender=models.Dealer)
|
@receiver(post_save, sender=models.Dealer)
|
||||||
def create_ledger_entity(sender, instance, created, **kwargs):
|
def create_ledger_entity(sender, instance, created, **kwargs):
|
||||||
if created:
|
if created:
|
||||||
entity, created = EntityModel.objects.get_or_create(
|
root_dealer = instance.get_root_dealer
|
||||||
name=instance.get_root_dealer.name,
|
if not root_dealer.entity:
|
||||||
admin=instance.get_root_dealer.user,
|
entity_name = f"{root_dealer.name}-{root_dealer.joined_at.date()}"
|
||||||
# address_1=instance.address,
|
entity = EntityModel.create_entity(
|
||||||
accrual_method=False,
|
name=entity_name,
|
||||||
fy_start_month=1,
|
admin=root_dealer.user,
|
||||||
depth=0,
|
use_accrual_method=False,
|
||||||
)
|
fy_start_month=1,
|
||||||
print(entity)
|
)
|
||||||
if created:
|
|
||||||
default_coa = entity.create_chart_of_accounts(assign_as_default=True,
|
|
||||||
commit=True,
|
|
||||||
coa_name=_("Chart of Accounts"))
|
|
||||||
if default_coa:
|
|
||||||
entity.populate_default_coa(activate_accounts=True, coa_model=default_coa)
|
|
||||||
print(f"Ledger entity created for Dealer: {instance.name}")
|
|
||||||
|
|
||||||
# entity.create_account(
|
if entity:
|
||||||
# coa_model=coa,
|
instance.entity = entity
|
||||||
# code=1010,
|
instance.save()
|
||||||
# role='asset_ca_cash',
|
coa = entity.create_chart_of_accounts(
|
||||||
# name=_('Cash'),
|
assign_as_default=True, commit=True, coa_name=_(f"{entity_name}-COA")
|
||||||
# balance_type="debit",
|
)
|
||||||
# )
|
if coa:
|
||||||
# entity.create_account(
|
# entity.populate_default_coa(activate_accounts=True, coa_model=coa)
|
||||||
# coa_model=coa,
|
print(f"Ledger entity created for Dealer: {instance.name}")
|
||||||
# code=1100,
|
|
||||||
# role='asset_ca_recv',
|
|
||||||
# name=_('Accounts Receivable'),
|
|
||||||
# balance_type="debit",
|
|
||||||
# )
|
|
||||||
# entity.create_account(
|
|
||||||
# coa_model=coa,
|
|
||||||
# code=1200,
|
|
||||||
# role='asset_ca_inv',
|
|
||||||
# name=_('Inventory'),
|
|
||||||
# balance_type="debit",
|
|
||||||
# active=True)
|
|
||||||
#
|
|
||||||
# entity.create_account(
|
|
||||||
# coa_model=coa,
|
|
||||||
# code=2010,
|
|
||||||
# role='lia_cl_acc_payable',
|
|
||||||
# name=_('Accounts Payable'),
|
|
||||||
# balance_type="credit",
|
|
||||||
# active=True)
|
|
||||||
#
|
|
||||||
# entity.create_account(
|
|
||||||
# coa_model=coa,
|
|
||||||
# code=4010,
|
|
||||||
# role='in_operational',
|
|
||||||
# name=_('Sales Income'),
|
|
||||||
# balance_type="credit",
|
|
||||||
# active=True)
|
|
||||||
#
|
|
||||||
# entity.create_account(
|
|
||||||
# coa_model=coa,
|
|
||||||
# code=5010,
|
|
||||||
# role='cogs_regular',
|
|
||||||
# name=_('Cost of Goods Sold'),
|
|
||||||
# balance_type="debit",
|
|
||||||
# active=True)
|
|
||||||
|
|
||||||
|
# Create Cash Account
|
||||||
|
entity.create_account(
|
||||||
|
coa_model=coa,
|
||||||
|
code="1010",
|
||||||
|
role=roles.ASSET_CA_CASH,
|
||||||
|
name=_("Cash"),
|
||||||
|
balance_type="debit",
|
||||||
|
active=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create Accounts Receivable Account
|
||||||
|
entity.create_account(
|
||||||
|
coa_model=coa,
|
||||||
|
code="1020",
|
||||||
|
role=roles.ASSET_CA_RECEIVABLES,
|
||||||
|
name=_("Accounts Receivable"),
|
||||||
|
balance_type="debit",
|
||||||
|
active=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create Inventory Account
|
||||||
|
entity.create_account(
|
||||||
|
coa_model=coa,
|
||||||
|
code="1030",
|
||||||
|
role=roles.ASSET_CA_INVENTORY,
|
||||||
|
name=_("Inventory"),
|
||||||
|
balance_type="debit",
|
||||||
|
active=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create Accounts Payable Account
|
||||||
|
entity.create_account(
|
||||||
|
coa_model=coa,
|
||||||
|
code="2010",
|
||||||
|
role=roles.LIABILITY_CL_ACC_PAYABLE,
|
||||||
|
name=_("Accounts Payable"),
|
||||||
|
balance_type="credit",
|
||||||
|
active=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create Sales Revenue Account
|
||||||
|
entity.create_account(
|
||||||
|
coa_model=coa,
|
||||||
|
code="4010",
|
||||||
|
role=roles.INCOME_OPERATIONAL,
|
||||||
|
name=_("Sales Revenue"),
|
||||||
|
balance_type="credit",
|
||||||
|
active=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create Cost of Goods Sold Account
|
||||||
|
entity.create_account(
|
||||||
|
coa_model=coa,
|
||||||
|
code="5010",
|
||||||
|
role=roles.COGS,
|
||||||
|
name=_("Cost of Goods Sold"),
|
||||||
|
balance_type="debit",
|
||||||
|
active=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create Rent Expense Account
|
||||||
|
entity.create_account(
|
||||||
|
coa_model=coa,
|
||||||
|
code="6010",
|
||||||
|
role=roles.EXPENSE_OPERATIONAL,
|
||||||
|
name=_("Rent Expense"),
|
||||||
|
balance_type="debit",
|
||||||
|
active=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create Utilities Expense Account
|
||||||
|
entity.create_account(
|
||||||
|
coa_model=coa,
|
||||||
|
code="6020",
|
||||||
|
role=roles.EXPENSE_OPERATIONAL,
|
||||||
|
name=_("Utilities Expense"),
|
||||||
|
balance_type="debit",
|
||||||
|
active=True,
|
||||||
|
)
|
||||||
|
|
||||||
# uom_name = _("Unit")
|
# uom_name = _("Unit")
|
||||||
# unit_abbr = _("U")
|
# unit_abbr = _("U")
|
||||||
@ -175,7 +231,7 @@ def create_customer(sender, instance, created, **kwargs):
|
|||||||
"sales_tax_rate": 0.15,
|
"sales_tax_rate": 0.15,
|
||||||
"active": True,
|
"active": True,
|
||||||
"hidden": False,
|
"hidden": False,
|
||||||
"additional_info": {}
|
"additional_info": {},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -183,65 +239,31 @@ def create_customer(sender, instance, created, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
# Create Item
|
# Create Item
|
||||||
# @receiver(post_save, sender=models.Car)
|
@receiver(post_save, sender=models.Car)
|
||||||
# def create_item_model(sender, instance, created, **kwargs):
|
def create_item_model(sender, instance, created, **kwargs):
|
||||||
# item_name = f"{instance.year} - {instance.id_car_make} - {instance.id_car_model} - {instance.id_car_trim}"
|
item_name = f"{instance.year} - {instance.id_car_make} - {instance.id_car_model} - {instance.id_car_trim}"
|
||||||
# uom_name = _("Car")
|
dealer = instance.dealer
|
||||||
# unit_abbr = _("C")
|
entity = dealer.entity
|
||||||
#
|
|
||||||
# uom, uom_created = UnitOfMeasureModel.objects.get_or_create(
|
if not entity:
|
||||||
# name=uom_name,
|
return
|
||||||
# unit_abbr=unit_abbr
|
|
||||||
# )
|
uom_name = _("Car")
|
||||||
#
|
unit_abbr = _("C")
|
||||||
# if uom_created:
|
uom = entity.get_uom_all().filter(name=uom_name, unit_abbr=unit_abbr).first()
|
||||||
# print(f"UOM created: {uom_name}")
|
if not uom:
|
||||||
# else:
|
uom = entity.create_uom(
|
||||||
# print(f"Using existing UOM: {uom_name}")
|
name=uom_name,
|
||||||
#
|
unit_abbr=unit_abbr
|
||||||
# entity = EntityModel.objects.filter(name=instance.dealer.name).first()
|
)
|
||||||
#
|
|
||||||
# inventory_account = AccountModel.objects.first()
|
entity.create_item_product(
|
||||||
# cogs_account = AccountModel.objects.first()
|
name=item_name,
|
||||||
# earnings_account = AccountModel.objects.first()
|
uom_model=uom,
|
||||||
#
|
item_type=ItemModel.ITEM_TYPE_MATERIAL)
|
||||||
# entity.create_item_product(
|
|
||||||
# item_name=item_name,
|
print(f"ItemModel for Car:")
|
||||||
# item_role=ItemModelAbstract.ITEM_ROLE_PRODUCT,
|
|
||||||
# item_type=ItemModelAbstract.ITEM_TYPE_MATERIAL,
|
|
||||||
# item_id=instance.vin,
|
|
||||||
# sold_as_unit=True,
|
|
||||||
# inventory_received=1.00,
|
|
||||||
# inventory_received_value=0.00,
|
|
||||||
# inventory_account=inventory_account,
|
|
||||||
# for_inventory=True,)
|
|
||||||
#
|
|
||||||
# item = ItemModel.objects.create(
|
|
||||||
# entity=entity,
|
|
||||||
# uom=uom,
|
|
||||||
# name=item_name,
|
|
||||||
# item_role=ItemModelAbstract.ITEM_ROLE_INVENTORY,
|
|
||||||
# item_type=ItemModelAbstract.ITEM_TYPE_MATERIAL,
|
|
||||||
# item_id=instance.vin,
|
|
||||||
# sold_as_unit=True,
|
|
||||||
# inventory_received=1.00,
|
|
||||||
# inventory_received_value=0.00,
|
|
||||||
# inventory_account=inventory_account,
|
|
||||||
# for_inventory=True,
|
|
||||||
# is_product_or_service=True,
|
|
||||||
# cogs_account=cogs_account,
|
|
||||||
# earnings_account=earnings_account,
|
|
||||||
# is_active=True,
|
|
||||||
# additional_info={
|
|
||||||
# "remarks": instance.remarks,
|
|
||||||
# "status": instance.status,
|
|
||||||
# "stock_type": instance.stock_type,
|
|
||||||
# "mileage": instance.mileage,
|
|
||||||
# },
|
|
||||||
# )
|
|
||||||
#
|
|
||||||
# print(f"ItemModel {'created' if created else 'updated'} for Car: {item.name}")
|
|
||||||
#
|
|
||||||
#
|
#
|
||||||
# # update price - CarFinance
|
# # update price - CarFinance
|
||||||
# @receiver(post_save, sender=CarFinance)
|
# @receiver(post_save, sender=CarFinance)
|
||||||
|
|||||||
@ -23,22 +23,12 @@ def get_financial_value(name,vat=False):
|
|||||||
|
|
||||||
def get_total_financials(instance,vat=False):
|
def get_total_financials(instance,vat=False):
|
||||||
total = 0
|
total = 0
|
||||||
if instance.additional_services.exists():
|
if instance.additional_services.count() != 0:
|
||||||
total = sum(x.price for x in instance.additional_services.all()) + instance.selling_price
|
total = sum(x.price for x in instance.additional_services) + instance.selling_price
|
||||||
|
|
||||||
if vat:
|
if vat:
|
||||||
total = (total * settings.VAT_RATE).quantize(Decimal('0.01')) + total
|
total = (total * settings.VAT_RATE).quantize(Decimal('0.01')) + total
|
||||||
# price_after_discount = get_financial_value(instance,"selling_price",vat) - get_financial_value(instance,"discount_amount",vat)
|
|
||||||
# subtotal = (
|
|
||||||
# price_after_discount +
|
|
||||||
# get_financial_value("registration_fee") +
|
|
||||||
# get_financial_value("administration_fee",vat) +
|
|
||||||
# get_financial_value("transportation_fee",vat) +
|
|
||||||
# get_financial_value("custom_card_fee",vat))
|
|
||||||
|
|
||||||
return total
|
return total
|
||||||
|
|
||||||
def get_total(instance):
|
def get_total(instance):
|
||||||
total = get_total_financials(instance,vat=True)
|
total = get_total_financials(instance,vat=True)
|
||||||
# total_vat = get_total_financials(instance,vat=True)
|
|
||||||
return total
|
return total
|
||||||
@ -759,8 +759,8 @@ class QuotationCreateView(LoginRequiredMixin, PermissionRequiredMixin, CreateVie
|
|||||||
permission_required = ("inventory.add_salequotation",)
|
permission_required = ("inventory.add_salequotation",)
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
dealer = self.request.user.dealer.get_root_dealer
|
dealer = self.request.user.dealer.get_root_dealer
|
||||||
form.instance.dealer = dealer
|
form.instance.dealer = dealer
|
||||||
quotation = form.save()
|
quotation = form.save()
|
||||||
selected_cars = form.cleaned_data.get("cars")
|
selected_cars = form.cleaned_data.get("cars")
|
||||||
for car in selected_cars:
|
for car in selected_cars:
|
||||||
@ -810,12 +810,12 @@ class QuotationDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailVie
|
|||||||
def generate_invoice(request, pk):
|
def generate_invoice(request, pk):
|
||||||
quotation = get_object_or_404(models.SaleQuotation, pk=pk)
|
quotation = get_object_or_404(models.SaleQuotation, pk=pk)
|
||||||
dealer = request.user.dealer.get_root_dealer
|
dealer = request.user.dealer.get_root_dealer
|
||||||
|
entity = dealer.entity
|
||||||
if not quotation.is_approved:
|
if not quotation.is_approved:
|
||||||
messages.error(
|
messages.error(
|
||||||
request, "Quotation must be approved before converting to an invoice."
|
request, "Quotation must be approved before converting to an invoice."
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
entity = dealer.entity
|
|
||||||
coa_qs, coa_map = entity.get_all_coa_accounts()
|
coa_qs, coa_map = entity.get_all_coa_accounts()
|
||||||
cash_account = coa_qs.first().get_coa_accounts().filter(name="Cash")
|
cash_account = coa_qs.first().get_coa_accounts().filter(name="Cash")
|
||||||
recivable_account = coa_qs.first().get_coa_accounts().filter(name="Accounts Receivable")
|
recivable_account = coa_qs.first().get_coa_accounts().filter(name="Accounts Receivable")
|
||||||
@ -956,10 +956,11 @@ def generate_invoice(request, pk):
|
|||||||
@login_required
|
@login_required
|
||||||
def post_quotation(request, pk):
|
def post_quotation(request, pk):
|
||||||
qoutation = get_object_or_404(models.SaleQuotation, pk=pk)
|
qoutation = get_object_or_404(models.SaleQuotation, pk=pk)
|
||||||
|
dealer = request.user.dealer.get_root_dealer
|
||||||
|
entity = dealer.entity
|
||||||
if qoutation.posted:
|
if qoutation.posted:
|
||||||
messages.error(request, "Quotation is already posted")
|
messages.error(request, "Quotation is already posted")
|
||||||
return redirect("quotation_detail", pk=pk)
|
return redirect("quotation_detail", pk=pk)
|
||||||
entity = qoutation.entity
|
|
||||||
coa_qs, coa_map = entity.get_all_coa_accounts()
|
coa_qs, coa_map = entity.get_all_coa_accounts()
|
||||||
cash_account = coa_qs.first().get_coa_accounts().filter(name="Cash")
|
cash_account = coa_qs.first().get_coa_accounts().filter(name="Cash")
|
||||||
recivable_account = coa_qs.first().get_coa_accounts().filter(name="Accounts Receivable")
|
recivable_account = coa_qs.first().get_coa_accounts().filter(name="Accounts Receivable")
|
||||||
@ -1011,7 +1012,8 @@ def post_quotation(request, pk):
|
|||||||
def mark_quotation(request, pk):
|
def mark_quotation(request, pk):
|
||||||
qoutation = get_object_or_404(models.SaleQuotation, pk=pk)
|
qoutation = get_object_or_404(models.SaleQuotation, pk=pk)
|
||||||
status = request.GET.get("status")
|
status = request.GET.get("status")
|
||||||
entity = qoutation.entity
|
dealer = request.user.dealer.get_root_dealer
|
||||||
|
entity = dealer.entity
|
||||||
date = datetime.datetime.now()
|
date = datetime.datetime.now()
|
||||||
customer = entity.get_customers().filter(customer_name=qoutation.customer.get_full_name).first()
|
customer = entity.get_customers().filter(customer_name=qoutation.customer.get_full_name).first()
|
||||||
invoice_model = entity.get_invoices().filter(customer=customer)
|
invoice_model = entity.get_invoices().filter(customer=customer)
|
||||||
@ -1355,9 +1357,9 @@ def download_quotation_pdf(request, quotation_id):
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def invoice_detail(request,pk):
|
def invoice_detail(request,pk):
|
||||||
quotation = get_object_or_404(models.SaleQuotation, pk=pk)
|
quotation = get_object_or_404(models.SaleQuotation, pk=pk)
|
||||||
dealer = request.user.dealer.get_root_dealer
|
dealer = request.user.dealer.get_root_dealer
|
||||||
entity = dealer.entity
|
entity = dealer.entity
|
||||||
customer = entity.get_customers().filter(customer_name=quotation.customer.get_full_name).first()
|
customer = entity.get_customers().filter(customer_name=quotation.customer.get_full_name).first()
|
||||||
invoice_model = entity.get_invoices()
|
invoice_model = entity.get_invoices()
|
||||||
|
|
||||||
@ -1366,9 +1368,9 @@ def invoice_detail(request,pk):
|
|||||||
return redirect('quotation_detail', pk=pk)
|
return redirect('quotation_detail', pk=pk)
|
||||||
@login_required
|
@login_required
|
||||||
def payment_invoice(request,pk):
|
def payment_invoice(request,pk):
|
||||||
quotation = get_object_or_404(models.SaleQuotation, pk=pk)
|
quotation = get_object_or_404(models.SaleQuotation, pk=pk)
|
||||||
dealer = request.user.dealer.get_root_dealer
|
dealer = request.user.dealer.get_root_dealer
|
||||||
entity = dealer.entity
|
entity = dealer.entity
|
||||||
customer = entity.get_customers().filter(customer_name=quotation.customer.get_full_name).first()
|
customer = entity.get_customers().filter(customer_name=quotation.customer.get_full_name).first()
|
||||||
invoice_model = entity.get_invoices()
|
invoice_model = entity.get_invoices()
|
||||||
invoice = invoice_model.filter(customer=customer,date_draft=quotation.date_draft).first()
|
invoice = invoice_model.filter(customer=customer,date_draft=quotation.date_draft).first()
|
||||||
@ -1403,7 +1405,9 @@ def payment_create(request, pk):
|
|||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
form.instance.quotation = quotation
|
form.instance.quotation = quotation
|
||||||
insatnce = form.save()
|
insatnce = form.save()
|
||||||
entity = dealer.entity
|
|
||||||
|
dealer = request.user.dealer.get_root_dealer
|
||||||
|
entity = dealer.entity
|
||||||
customer = entity.get_customers().filter(customer_name=quotation.customer.get_full_name).first()
|
customer = entity.get_customers().filter(customer_name=quotation.customer.get_full_name).first()
|
||||||
coa_qs, coa_map = entity.get_all_coa_accounts()
|
coa_qs, coa_map = entity.get_all_coa_accounts()
|
||||||
cash_account = coa_qs.first().get_coa_accounts().filter(name="Cash")
|
cash_account = coa_qs.first().get_coa_accounts().filter(name="Cash")
|
||||||
|
|||||||
@ -41,6 +41,7 @@
|
|||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="">
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="">
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@300;400;600;700;800;900&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@300;400;600;700;800;900&display=swap" rel="stylesheet">
|
||||||
<link href="{% static 'vendors/simplebar/simplebar.min.css' %}" rel="stylesheet">
|
<link href="{% static 'vendors/simplebar/simplebar.min.css' %}" rel="stylesheet">
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/sweetalert2@11.15.3/dist/sweetalert2.min.css" rel="stylesheet">
|
||||||
<link rel="stylesheet" href="https://unicons.iconscout.com/release/v4.0.8/css/line.css">
|
<link rel="stylesheet" href="https://unicons.iconscout.com/release/v4.0.8/css/line.css">
|
||||||
<link href="https://cdn.jsdelivr.net/npm/sweetalert2@11.15.3/dist/sweetalert2.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/sweetalert2@11.15.3/dist/sweetalert2.min.css" rel="stylesheet">
|
||||||
{% if LANGUAGE_CODE == 'ar' %}
|
{% if LANGUAGE_CODE == 'ar' %}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user