Skip to content

Commit

Permalink
* Rename paymentdeadline => paymentdueby
Browse files Browse the repository at this point in the history
* Add documentation
* Default paymentterms to 30 days
  • Loading branch information
ssinger committed Nov 15, 2024
1 parent 61f691e commit b4d085b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
12 changes: 12 additions & 0 deletions docs/confreg/sponsors.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,18 @@ Instant buy available
administrator must manually move the sponsorship forward in the
process once a signed contract is received.

Number of days until payment is due
: The number of days until a sponsorship invoice is due. This is defaults to 30
to give net 30 terms. The actual due date for an invoice might be restricted
by either *The Date the payment is due by* field.

The Date the payment is due by
: The latest date that *Number of days until payment is due* applies until.
Invoices that would be due after this date are instead due at this time or
now(if this time is in the past). If this field is unset then invoices created
within 5 days of the conference start are due now and invoices created within
30 days of the conference start date are due in 5 days.

Payment methods for generated invoices
: Which payment methods will be listed on the generated
invoices. Typically the instant buy levels support payment by
Expand Down
6 changes: 3 additions & 3 deletions postgresqleu/confsponsor/backendforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,12 @@ class BackendSponsorshipLevelForm(BackendForm):
})
allow_copy_previous = True
auto_cascade_delete_to = ['sponsorshiplevel_paymentmethods', 'sponsorshipbenefit']
exclude_date_validators = ['paymentdeadline', ]
exclude_date_validators = ['paymentdueby', ]

class Meta:
model = SponsorshipLevel
fields = ['levelname', 'urlname', 'levelcost', 'available', 'public', 'maxnumber', 'instantbuy',
'paymentterms', 'paymentdeadline', 'paymentmethods', 'invoiceextradescription', 'contract', 'canbuyvoucher', 'canbuydiscountcode']
'paymentterms', 'paymentdueby', 'paymentmethods', 'invoiceextradescription', 'contract', 'canbuyvoucher', 'canbuydiscountcode']
widgets = {
'paymentmethods': django.forms.CheckboxSelectMultiple,
}
Expand All @@ -328,7 +328,7 @@ class Meta:
{
'id': 'contract',
'legend': 'Contract information',
'fields': ['instantbuy', 'contract', 'paymentterms', 'paymentdeadline'],
'fields': ['instantbuy', 'contract', 'paymentterms', 'paymentdueby'],
},
{
'id': 'payment',
Expand Down
20 changes: 7 additions & 13 deletions postgresqleu/confsponsor/invoicehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,34 +172,28 @@ def create_sponsor_invoice(user, sponsor, override_duedate=None):
level = sponsor.level

invoicerows, reverse_vat = _invoicerows_for_sponsor(sponsor)

terms = timedelta(days=30)
if level.paymentterms is not None:
terms = timedelta(days=level.paymentterms)

daystopay = timedelta(days=level.paymentterms)
if override_duedate:
duedate = override_duedate
elif level.paymentdeadline is not None and level.paymentdeadline < timezone.now():
elif level.paymentdueby is not None and level.paymentdueby < timezone.now():
# The payment deadline has passed. Invoices are due immediately
duedate = timezone.now()
elif level.paymentdeadline is not None and level.paymentdeadline < timezone.now() + terms:
elif level.paymentdueby is not None and level.paymentdueby < timezone.now() + daystopay:
# The payment terms go beyond the payment deadline. The payment is due
# at the deadline
duedate = level.paymentdeadline
elif conference.startdate < today_conference() + timedelta(days=5):
duedate = level.paymentdueby
elif level.paymentdueby is None and conference.startdate < today_conference() + timedelta(days=5):
# If conference happens in the next 5 days, invoice is due immediately
duedate = timezone.now()
elif conference.startdate < today_conference() + terms:
elif level.paymentdueby is None and conference.startdate < today_conference() + daystopay:
# Less than 30 days before the conference, set the due date to
# 5 days before the conference
duedate = timezone.make_aware(datetime.combine(
conference.startdate - timedelta(days=5),
timezone.now().time()
))
else:
# More than 30 days before the conference, set the due date
# to 30 days from now.
duedate = timezone.now() + terms
duedate = timezone.now() + daystopay

manager = InvoiceManager()
processor = invoicemodels.InvoiceProcessor.objects.get(processorname="confsponsor processor")
Expand Down
8 changes: 4 additions & 4 deletions postgresqleu/confsponsor/migrations/0033_payment_terms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.2.22 on 2024-11-10 01:59
# Generated by Django 3.2.22 on 2024-11-15 22:27

from django.db import migrations, models

Expand All @@ -12,12 +12,12 @@ class Migration(migrations.Migration):
operations = [
migrations.AddField(
model_name='sponsorshiplevel',
name='paymentdeadline',
field=models.DateTimeField(blank=True, null=True, verbose_name='payment deadline'),
name='paymentdueby',
field=models.DateTimeField(blank=True, help_text='The last acceptable due date for payments. If payment terms go behond this date then the invoice is due at this date', null=True, verbose_name='The date the payment is due by'),
),
migrations.AddField(
model_name='sponsorshiplevel',
name='paymentterms',
field=models.IntegerField(blank=True, default=None, null=True, verbose_name='Number of days until payment is due'),
field=models.IntegerField(default=30, null=True, verbose_name='Number of days until payment is due'),
),
]
7 changes: 5 additions & 2 deletions postgresqleu/confsponsor/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ class SponsorshipLevel(models.Model):
contract = models.ForeignKey(SponsorshipContract, blank=True, null=True, on_delete=models.CASCADE)
canbuyvoucher = models.BooleanField(null=False, blank=False, default=True, verbose_name="Can buy vouchers")
canbuydiscountcode = models.BooleanField(null=False, blank=False, default=True, verbose_name="Can buy discount codes")
paymentterms = models.IntegerField(null=True, blank=True, default=None, verbose_name="Number of days until payment is due")
paymentdeadline = models.DateTimeField(null=True, blank=True, verbose_name="payment deadline")
paymentterms = models.IntegerField(null=True, blank=False, default=30, verbose_name="Number of days until payment is due")
paymentdueby = models.DateTimeField(
null=True, blank=True, verbose_name="The date the payment is due by",
help_text="The last acceptable due date for payments. If payment terms go behond this date then the invoice is due at this date",
)

def __str__(self):
return self.levelname
Expand Down

0 comments on commit b4d085b

Please sign in to comment.