Task #9530 bills that include vat per month in html or pdf format
This commit is contained in:
parent
1c3d3efb3a
commit
1aeb757e22
17 changed files with 298 additions and 39 deletions
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.4 on 2021-08-12 16:00
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('uncloud_pay', '0026_remove_order_description'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='stripecreditcard',
|
||||
name='card_name',
|
||||
field=models.CharField(default='', max_length=128),
|
||||
),
|
||||
]
|
||||
18
uncloud_pay/migrations/0028_bill_currency.py
Normal file
18
uncloud_pay/migrations/0028_bill_currency.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.4 on 2021-08-12 16:06
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('uncloud_pay', '0027_alter_stripecreditcard_card_name'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='bill',
|
||||
name='currency',
|
||||
field=models.CharField(choices=[('CHF', 'Swiss Franc')], default='CHF', max_length=32),
|
||||
),
|
||||
]
|
||||
|
|
@ -997,6 +997,8 @@ class Bill(models.Model):
|
|||
on_delete=models.CASCADE,
|
||||
editable=True,
|
||||
null=False)
|
||||
|
||||
currency = models.CharField(max_length=32, choices=Currency.choices, default=Currency.CHF)
|
||||
|
||||
# FIXME: editable=True -> is in the admin, but also editable in DRF
|
||||
# Maybe filter fields in the serializer?
|
||||
|
|
@ -1030,6 +1032,10 @@ class Bill(models.Model):
|
|||
bill_records = BillRecord.objects.filter(bill=self)
|
||||
return sum([ br.subtotal for br in bill_records ])
|
||||
|
||||
@property
|
||||
def vat_amount(self):
|
||||
return round(self.vat_rate * self.subtotal, 2)
|
||||
|
||||
@property
|
||||
def vat_rate(self):
|
||||
return VATRate.get_vat_rate(self.billing_address, when=self.ending_date)
|
||||
|
|
@ -1086,8 +1092,6 @@ class Bill(models.Model):
|
|||
Create the next bill for a specific order of a user
|
||||
"""
|
||||
bill = cls.get_or_create_bill(order.billing_address, ending_date=ending_date)
|
||||
print("??????????????????????????????")
|
||||
print(bill.id)
|
||||
order.create_bill_record(bill)
|
||||
return bill
|
||||
|
||||
|
|
@ -1206,9 +1210,6 @@ class BillRecord(models.Model):
|
|||
return bill_line
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
|
||||
print(self.ending_date)
|
||||
print(self.starting_date)
|
||||
if self.ending_date < self.starting_date:
|
||||
raise ValidationError("End date cannot be before starting date")
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class CardActivateView(View):
|
|||
def post(self, request, **args):
|
||||
card_id = request.POST.get('card_id')
|
||||
if card_id:
|
||||
matched_card = StripeCreditCard.objects.filter(owner=self.request.user, card_id=card_id).first()
|
||||
matched_card = StripeCreditCard.objects.filter(owner=self.request.user, id=card_id).first()
|
||||
matched_card.activate()
|
||||
return JsonResponse({'success': 1})
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue