1
0
forked from erp-dev/erp

feat: add discount_amount to payment_order and receipt_order, and change total_amount logic

This commit is contained in:
2025-12-04 09:36:59 +08:00
parent 0b8146d972
commit d8eb66821e
19 changed files with 1144 additions and 398 deletions

View File

@@ -558,6 +558,21 @@ class PaymentOrder(OrderDirectionMixin, OrderCounterpartyMixin, ModelBase):
)
payment_date = models.DateField(verbose_name='付款日期')
amount = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='金额')
discount_amount = models.DecimalField(
max_digits=15,
decimal_places=2,
default=Decimal('0'),
verbose_name='折扣金额',
)
bank_account = models.ForeignKey(
basic_info_models.BankAccount,
on_delete=models.PROTECT,
related_name='payment_orders',
verbose_name='银行账户',
blank=True,
null=True,
)
markup = models.CharField(max_length=255, blank=True, null=True, verbose_name='附言')
operator = models.ForeignKey(
basic_info_models.Employee,
on_delete=models.PROTECT,
@@ -578,8 +593,13 @@ class PaymentOrder(OrderDirectionMixin, OrderCounterpartyMixin, ModelBase):
def __str__(self):
return f'付款单 {self.id} - {self.supplier.name}'
@property
def settlement_amount(self) -> Decimal:
discount = self.discount_amount or Decimal('0')
return self.amount + discount
def get_total_amount(self) -> Decimal:
return self.amount
return self.settlement_amount
def get_direction(self) -> int:
return -1
@@ -610,6 +630,21 @@ class ReceiptOrder(OrderDirectionMixin, OrderCounterpartyMixin, ModelBase):
)
receipt_date = models.DateField(verbose_name='收款日期')
amount = models.DecimalField(max_digits=15, decimal_places=2, verbose_name='金额')
discount_amount = models.DecimalField(
max_digits=15,
decimal_places=2,
default=Decimal('0'),
verbose_name='折扣金额',
)
bank_account = models.ForeignKey(
basic_info_models.BankAccount,
on_delete=models.PROTECT,
related_name='receipt_orders',
verbose_name='银行账户',
blank=True,
null=True,
)
markup = models.CharField(max_length=255, blank=True, null=True, verbose_name='附言')
operator = models.ForeignKey(
basic_info_models.Employee,
on_delete=models.PROTECT,
@@ -630,8 +665,13 @@ class ReceiptOrder(OrderDirectionMixin, OrderCounterpartyMixin, ModelBase):
def __str__(self):
return f'收款单 {self.id} - {self.customer.name}'
@property
def settlement_amount(self) -> Decimal:
discount = self.discount_amount or Decimal('0')
return self.amount + discount
def get_total_amount(self) -> Decimal:
return self.amount
return self.settlement_amount
def get_direction(self) -> int:
return -1