Add voucher-line party (تفصیل) and allow cache-control CORS headers.
Supports accounting journal detail parties and preflight from the Vite client that sends Cache-Control/Pragma. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
23
accounting/migrations/0011_voucherline_party.py
Normal file
23
accounting/migrations/0011_voucherline_party.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounting', '0010_voucher_regarding_invoiceline_event_name'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='voucherline',
|
||||
name='party',
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name='voucher_lines',
|
||||
to='accounting.party',
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -137,6 +137,14 @@ class VoucherLine(models.Model):
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
voucher = models.ForeignKey(Voucher, on_delete=models.CASCADE, related_name='lines')
|
||||
account = models.ForeignKey(Account, on_delete=models.PROTECT, related_name='voucher_lines')
|
||||
# تفصیل / طرف حساب — who the line is with (optional for non-party accounts)
|
||||
party = models.ForeignKey(
|
||||
Party,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name='voucher_lines',
|
||||
)
|
||||
description = models.CharField(max_length=255, blank=True, default='')
|
||||
debit = models.FloatField(default=0)
|
||||
credit = models.FloatField(default=0)
|
||||
|
||||
@@ -65,10 +65,16 @@ class VoucherLineSerializer(serializers.ModelSerializer):
|
||||
# Lenient: accepts client-generated ids (ignored on write, recreated server-side).
|
||||
id = serializers.CharField(required=False)
|
||||
accountId = serializers.PrimaryKeyRelatedField(source='account', queryset=Account.objects.all())
|
||||
partyId = serializers.PrimaryKeyRelatedField(
|
||||
source='party',
|
||||
queryset=Party.objects.all(),
|
||||
required=False,
|
||||
allow_null=True,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = VoucherLine
|
||||
fields = ['id', 'accountId', 'description', 'debit', 'credit']
|
||||
fields = ['id', 'accountId', 'partyId', 'description', 'debit', 'credit']
|
||||
|
||||
|
||||
class VoucherSerializer(serializers.ModelSerializer):
|
||||
|
||||
@@ -154,9 +154,11 @@ CORS_ALLOW_HEADERS = [
|
||||
'accept',
|
||||
'accept-encoding',
|
||||
'authorization',
|
||||
'cache-control',
|
||||
'content-type',
|
||||
'dnt',
|
||||
'origin',
|
||||
'pragma',
|
||||
'user-agent',
|
||||
'x-csrftoken',
|
||||
'x-requested-with',
|
||||
|
||||
Reference in New Issue
Block a user