invoicing: credit cancellation fields (#89810)
This commit is contained in:
parent
2f9f811fe2
commit
73f2cafd40
|
@ -0,0 +1,40 @@
|
|||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('invoicing', '0088_credit_from_pool'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='credit',
|
||||
name='cancellation_description',
|
||||
field=models.TextField(blank=True, verbose_name='Description'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='credit',
|
||||
name='cancellation_reason',
|
||||
field=models.ForeignKey(
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
to='invoicing.invoicecancellationreason',
|
||||
verbose_name='Cancellation reason',
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='credit',
|
||||
name='cancelled_at',
|
||||
field=models.DateTimeField(null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='credit',
|
||||
name='cancelled_by',
|
||||
field=models.ForeignKey(
|
||||
null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
|
||||
),
|
||||
),
|
||||
]
|
|
@ -1034,6 +1034,10 @@ class DraftInvoice(AbstractInvoice):
|
|||
credit.assigned_amount = 0
|
||||
credit.remaining_amount = 0
|
||||
credit.label = _('Credit from %s') % datetime.date.today().strftime('%d/%m/%Y')
|
||||
credit.cancelled_at = None
|
||||
credit.cancelled_by = None
|
||||
credit.cancellation_reason = None
|
||||
credit.cancellation_description = ''
|
||||
credit.save()
|
||||
|
||||
for line in self.lines.all().order_by('pk'):
|
||||
|
@ -1148,6 +1152,12 @@ class Credit(AbstractInvoiceObject):
|
|||
formatted_number = models.CharField(max_length=200)
|
||||
assigned_amount = models.DecimalField(max_digits=9, decimal_places=2, default=0)
|
||||
remaining_amount = models.DecimalField(max_digits=9, decimal_places=2, default=0)
|
||||
cancelled_at = models.DateTimeField(null=True)
|
||||
cancelled_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True)
|
||||
cancellation_reason = models.ForeignKey(
|
||||
InvoiceCancellationReason, verbose_name=_('Cancellation reason'), on_delete=models.PROTECT, null=True
|
||||
)
|
||||
cancellation_description = models.TextField(_('Description'), blank=True)
|
||||
|
||||
class Meta:
|
||||
constraints = [
|
||||
|
|
Loading…
Reference in New Issue