From b3b988a02b598d275248e54ec4b4a1b004786c36 Mon Sep 17 00:00:00 2001 From: MassiveAtoms Date: Tue, 26 May 2020 10:37:22 -0300 Subject: [PATCH] fixed stuff --- db.sqlite3 | Bin 208896 -> 208896 bytes markt/__pycache__/models.cpython-38.pyc | Bin 6671 -> 6800 bytes markt/__pycache__/views.cpython-38.pyc | Bin 886 -> 806 bytes markt/migrations/0013_factuur_date.py | 20 ++++++++++++++++++ markt/migrations/0014_auto_20200526_1037.py | 18 ++++++++++++++++ .../0013_factuur_date.cpython-38.pyc | Bin 0 -> 729 bytes .../0014_auto_20200526_1037.cpython-38.pyc | Bin 0 -> 639 bytes markt/models.py | 12 +++++------ markt/templates/markt/factuur_detail.html | 16 +++++++++----- markt/views.py | 5 ++++- 10 files changed, 59 insertions(+), 12 deletions(-) create mode 100644 markt/migrations/0013_factuur_date.py create mode 100644 markt/migrations/0014_auto_20200526_1037.py create mode 100644 markt/migrations/__pycache__/0013_factuur_date.cpython-38.pyc create mode 100644 markt/migrations/__pycache__/0014_auto_20200526_1037.cpython-38.pyc diff --git a/db.sqlite3 b/db.sqlite3 index 5b1ca5a471e574a07254c5cb7684fcbaf6928cda..bcfb26188a64135d109e3b645b2c5a9ecc00cf0b 100644 GIT binary patch delta 1568 zcmZ`(YfKzf6rOwLU3T{@ma+)6EW|3^|G0VbkTMGiE5YgJg z5E6fwG#YAd^iMHqG_gO5S;9seQ)8nsP>7W@O%;XWqY)&uCZz#u@XoSrLPBqH?wxz* zJKs5H&NsJb+SW5|doM5ZAjfeAGaoZxHu8RnK@NUie+KyiWp}^qtP+%WmEDQGPDSai zDiAqWRrvL2dsBy|>HbKxv!gZQ(|np1@C75fW`wLwsTL^p1>L$)X@n|utt_-%*ZoFd z3v({N?`%X4L>oIgJKH0%Xh(dln-*lAWrpt8jX>4r`!N$^Id!t+xQ*bLOz7IMqXvO{ zn6$*-h(w-AlhwAz;_XM3jK}yql0H)(D(1J{+eFd;wUBp_)U(iESYArJ{k7$Tq@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<@hUVA9#+7h-T#>bd6 diff --git a/markt/__pycache__/views.cpython-38.pyc b/markt/__pycache__/views.cpython-38.pyc index 112c3e3ac2446da05aae95cb2ebd07c29d7b047b..7652e8582cc7ba833a853d083065a9ed1d94c9a6 100644 GIT binary patch delta 172 zcmeyywv3H8l$V!_0SKI>&c~&0oS#>cT2T_8l30>Bc^_k=Ajm*oATDMB5)4d2tdoP7 v!c{<`w|L{@lXDV_i<47xa^mBQ1b|`?f)B(JoP3t4S^yykW(iJ?V3q>_`cNk` delta 253 zcmZ3+_Kl4+(82cD&nQE9)7$q69 zn4vU_2tx{!Gy{;wYy%{N88lh^Zn38&CYO|!7QIXX8WF{wonKUvnU}7~dW*HVv>>&p zhyy5mOCUY9BtAJmuOzjiBt9jvB=Hu%H$-7PP)%|wPhQC_j^NUylKhgyoXG`@jlw)Y zZM;BS%mySFn1mQ*7$-9^g{y$XZ}G;*C+8#<7bmCY_Bq~0t diff --git a/markt/migrations/0013_factuur_date.py b/markt/migrations/0013_factuur_date.py new file mode 100644 index 0000000..7b12c36 --- /dev/null +++ b/markt/migrations/0013_factuur_date.py @@ -0,0 +1,20 @@ +# Generated by Django 3.0.6 on 2020-05-26 13:06 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('markt', '0012_auto_20200525_0113'), + ] + + operations = [ + migrations.AddField( + model_name='factuur', + name='Date', + field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now), + preserve_default=False, + ), + ] diff --git a/markt/migrations/0014_auto_20200526_1037.py b/markt/migrations/0014_auto_20200526_1037.py new file mode 100644 index 0000000..2426821 --- /dev/null +++ b/markt/migrations/0014_auto_20200526_1037.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.6 on 2020-05-26 13:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('markt', '0013_factuur_date'), + ] + + operations = [ + migrations.AlterField( + model_name='factuur', + name='Orders', + field=models.ManyToManyField(blank=True, to='markt.Order'), + ), + ] diff --git a/markt/migrations/__pycache__/0013_factuur_date.cpython-38.pyc b/markt/migrations/__pycache__/0013_factuur_date.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b9f68ad999860befd21fdc07601d8dc625449599 GIT binary patch literal 729 zcmYjP&2G~`5Z<-du@e%hs)`W2K`xP#svHnPt*FYWy+Aow7AupP1iN0_-L;F#6|Q{{ z9)=g#D<@t7fy%6th_1Dx{pM$9zHfawnT!~%_Xj^d{N;@Obl~9<1deH&85v-}OQv|j zm6v$jVXyQP@rHp9;u`~jya>MfNdVqkHVuAJ4V!v)r1G`S+Ptoe9jF?xG#5)3d$>XZ z$F$9JGRP7REb)M^dE%oe=tl5yP=wSYDu%_Vcm%t)eZqRSOHec z9F6vfwT(^y&fKlqcW}~=l`HIhb^t|It!o=}ZC)B1wG{bMS7?12*pBK3w<3RM`YF}- z=C^wNBE6&mO?sXgli%P;TPu^EqPc48CRM~QFY{_mgULqM^iWC>ObgVgZqrY7*Y+}| zTf5WOq$KO1+)5~c6r44;+Wj!@Da}5a$oK9=Ah<{0KKK5J`#wG$*x`oD3_kYEd%nrz kt+VGh+tJepj*GkZKda5@8ToAVa-;7nCz)|+dpz?00n$UzApigX literal 0 HcmV?d00001 diff --git a/markt/migrations/__pycache__/0014_auto_20200526_1037.cpython-38.pyc b/markt/migrations/__pycache__/0014_auto_20200526_1037.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..92c235a837f07bb4cf4bbd3741218e8a92758915 GIT binary patch literal 639 zcmYjO&2H2%5O(5ZHyc_}4shX)w3k)7_}XwA~6?%Ej15xSWn z2vSBs${3$PFFFw2vKB_ixR=Y1TPyTie~YF*aDTzO&8hMjqApjx*lP8I z=!aMn;E#EISe+T1xms{z>M!EhDru@W!mO?8D><~bZtHG^?OCrC>MbSGsu5bqP4!6) zHmq80@m4QWp-fL1AFN{YVqO%_=Fi!Faqwc+Z?u2)5xUt!$Y^|>q)8OxxAQl-4%w4w l;wI4WZlz{$9+nJ?h2;P7Z%&W!7MH!ek?WP;-*{E_=szj%u}%O0 literal 0 HcmV?d00001 diff --git a/markt/models.py b/markt/models.py index 653db66..2afd162 100644 --- a/markt/models.py +++ b/markt/models.py @@ -132,7 +132,8 @@ class Order(models.Model): verbose_name_plural = "Orders" def save(self, *args, **kwargs): - self.Prijs = self.Voorraad_ID.Prijs * self.Amount + self.Prijs = round(self.Voorraad_ID.Prijs * self.Amount, 2) + new_amount = self.Voorraad_ID.Voorraad_Amount - self.Amount if new_amount < 0: raise ValueError("Er zijn maar {} in voorraad".format( @@ -145,11 +146,11 @@ class Order(models.Model): class Factuur(models.Model): Factuur_ID = models.AutoField(primary_key=True) Klant_ID = models.ForeignKey("Klant", on_delete=models.PROTECT) - Orders = models.ManyToManyField("Order", null=True, blank=True) + Orders = models.ManyToManyField("Order", blank=True) Korting_percent = models.FloatField() Subtotal = models.FloatField(null=True, blank=True) Total = models.FloatField(null=True, blank=True) - + Date = models.DateTimeField(auto_now_add=True) def get_absolute_url(self): """Returns the url to access a particular instance of the model.""" return reverse('factuur-detail', args=[str(self.Factuur_ID)]) @@ -161,8 +162,7 @@ class Factuur(models.Model): @property def subtotal(self): if not self.Subtotal: - # TODO: Korting moet mischien hier verwerkt worden - self.Subtotal = self.Orders.all().aggregate(Sum('Prijs'))['Prijs__sum'] + self.Subtotal = round(self.Orders.all().aggregate(Sum('Prijs'))['Prijs__sum'], 2) self.save() return self.Subtotal @@ -170,8 +170,8 @@ class Factuur(models.Model): def total(self): if self.pk: if not self.Total: - # TODO: Taxes moet eigenlijk hier verwerkt worden, niet korting self.Total = (100 - self.Korting_percent) * self.subtotal / 100 + self.Total = round(1.08 * self.Total , 2) self.save() return self.Total else: diff --git a/markt/templates/markt/factuur_detail.html b/markt/templates/markt/factuur_detail.html index b8fc37f..4ffb866 100644 --- a/markt/templates/markt/factuur_detail.html +++ b/markt/templates/markt/factuur_detail.html @@ -3,6 +3,7 @@ {% block content %} {% load static %} +{% load l10n %}

FACTUUR HOUTMARKTNAAM

@@ -11,7 +12,7 @@ - +
DatumTBD{{ factuur.Date|date:"D d/m/Y G:i" }}
@@ -28,24 +29,29 @@ {{order.Voorraad_ID}} {{order.Amount}} - SRD {{order.Prijs}} + SRD {{order.Prijs |floatformat:2}} {% endfor %} Subotaal - SRD {{factuur.Subtotal}} + SRD {{factuur.Subtotal |floatformat:2}} Korting {{factuur.Korting_percent}} % - SRD {{korting}} + + + + Belasting + 8% + Totaal - SRD {{factuur.Total}} + SRD {{factuur.Total |floatformat:2}} diff --git a/markt/views.py b/markt/views.py index ee64dec..32a2de8 100644 --- a/markt/views.py +++ b/markt/views.py @@ -13,5 +13,8 @@ class FactuurDetailView(generic.DetailView): def get_context_data(self, **kwargs): # Call the base implementation first to get the context context = super(FactuurDetailView, self).get_context_data(**kwargs) - context['korting'] = context["factuur"].Korting_percent * context["factuur"].Subtotal / 100 + # context['korting'] = context["factuur"].Korting_percent * context["factuur"].Subtotal / 100 + # context["beforetax"] = context["factuur"].Subtotal - context["korting"] + # context["tax"] = context["beforetax"] * 0.08 + return context \ No newline at end of file