add some aggregation and stuff on posreports in backoffice
This commit is contained in:
parent
ae55e48df7
commit
399b6dc16d
|
@ -4,8 +4,14 @@
|
|||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Pos</th>
|
||||
<th>Bank Responsible</th>
|
||||
<th>Pos Responsible</th>
|
||||
<th>Responsible</th>
|
||||
<th>Bank Start</th>
|
||||
<th>Pos Start</th>
|
||||
<th>Bank End</th>
|
||||
<th>Pos End</th>
|
||||
<th>Hax Income</th>
|
||||
<th>Hax Sold</th>
|
||||
<th>Hax Balance</th>
|
||||
<th class="text-center">OK?</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
|
@ -15,8 +21,14 @@
|
|||
<tr>
|
||||
<td><a href="{% url 'backoffice:posreport_detail' camp_slug=camp.slug pos_slug=pos.slug posreport_uuid=pr.uuid %}">{{ pr.date }}</a></td>
|
||||
<td>{{ pr.pos.name }}</td>
|
||||
<td>{{ pr.bank_responsible }}</td>
|
||||
<td>{{ pr.pos_responsible }}</td>
|
||||
<td>Bank: {{ pr.bank_responsible }}<br>Pos: {{ pr.pos_responsible }}</td>
|
||||
<td>{{ pr.bank_start_hax }} HAX / {{ pr.bank_count_dkk_start }} DKK</td>
|
||||
<td>{{ pr.pos_start_hax }} HAX / {{ pr.pos_count_dkk_start }} DKK</td>
|
||||
<td>{{ pr.bank_end_hax }} HAX / {{ pr.bank_count_dkk_end }} DKK</td>
|
||||
<td>{{ pr.pos_end_hax }} HAX / {{ pr.pos_count_dkk_end }} DKK</td>
|
||||
<td>{{ pr.pos_json_sales.1 }} HAX ({{ pr.pos_json_sales.0 }} tx)</td>
|
||||
<td>{{ pr.hax_sold_izettle }} HAX</td>
|
||||
<td>{{ pr.hax_balance }} HAX</td>
|
||||
<td class="text-center">{{ pr.allok | truefalseicon }}</td>
|
||||
<td>
|
||||
<div class="btn-group-vertical">
|
||||
|
|
|
@ -55,6 +55,14 @@ PosReport {{ posreport.date }} {{ posreport.pos.name }} | Pos | BackOffice | {{
|
|||
<th>All OK?</th>
|
||||
<td>{{ posreport.allok | truefalseicon }}</p>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Hax Sold from iZettle</th>
|
||||
<td>{{ posreport.hax_sold_izettle }} HAX</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Hax Balance (we want 0 here)</th>
|
||||
<td>{{ posreport.hax_balance }} HAX</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Comments</th>
|
||||
<td>{{ posreport.comments }}</td>
|
||||
|
@ -134,7 +142,7 @@ PosReport {{ posreport.date }} {{ posreport.pos.name }} | Pos | BackOffice | {{
|
|||
</tr>
|
||||
<tr>
|
||||
<th>POS JSON</th>
|
||||
<td>{{ posreport.pos_json }}</p>
|
||||
<td>{{ posreport.pos_json_sales.1 }} HAX in {{ posreport.pos_json_sales.0 }} transactions</p>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -2071,7 +2071,13 @@ class PosReportUpdateView(PosViewMixin, UpdateView):
|
|||
"""Use this view to update PosReports."""
|
||||
|
||||
model = PosReport
|
||||
fields = ["date", "bank_responsible", "pos_responsible", "comments"]
|
||||
fields = [
|
||||
"date",
|
||||
"bank_responsible",
|
||||
"pos_responsible",
|
||||
"hax_sold_izettle",
|
||||
"comments",
|
||||
]
|
||||
template_name = "posreport_form.html"
|
||||
pk_url_kwarg = "posreport_uuid"
|
||||
|
||||
|
|
21
src/economy/migrations/0016_posreport_hax_sold_izettle.py
Normal file
21
src/economy/migrations/0016_posreport_hax_sold_izettle.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Generated by Django 3.1 on 2020-09-02 20:39
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("economy", "0015_auto_20200813_2345"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="posreport",
|
||||
name="hax_sold_izettle",
|
||||
field=models.PositiveIntegerField(
|
||||
default=0,
|
||||
help_text="The number of HAX sold through the iZettle from the POS",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -555,6 +555,10 @@ class PosReport(CampRelatedModel, UUIDModel):
|
|||
blank=True, help_text="Any comments about this PosReport",
|
||||
)
|
||||
|
||||
hax_sold_izettle = models.PositiveIntegerField(
|
||||
default=0, help_text="The number of HAX sold through the iZettle from the POS",
|
||||
)
|
||||
|
||||
# bank count start of day
|
||||
|
||||
bank_count_dkk_start = models.PositiveIntegerField(
|
||||
|
@ -723,6 +727,46 @@ class PosReport(CampRelatedModel, UUIDModel):
|
|||
def hax100_start_ok(self):
|
||||
return self.bank_count_hax100_start == self.pos_count_hax100_start
|
||||
|
||||
@property
|
||||
def bank_start_hax(self):
|
||||
return (
|
||||
(self.bank_count_hax5_start * 5)
|
||||
+ (self.bank_count_hax10_start * 10)
|
||||
+ (self.bank_count_hax20_start * 20)
|
||||
+ (self.bank_count_hax50_start * 50)
|
||||
+ (self.bank_count_hax100_start * 100)
|
||||
)
|
||||
|
||||
@property
|
||||
def pos_start_hax(self):
|
||||
return (
|
||||
(self.pos_count_hax5_start * 5)
|
||||
+ (self.pos_count_hax10_start * 10)
|
||||
+ (self.pos_count_hax20_start * 20)
|
||||
+ (self.pos_count_hax50_start * 50)
|
||||
+ (self.pos_count_hax100_start * 100)
|
||||
)
|
||||
|
||||
@property
|
||||
def bank_end_hax(self):
|
||||
return (
|
||||
(self.bank_count_hax5_end * 5)
|
||||
+ (self.bank_count_hax10_end * 10)
|
||||
+ (self.bank_count_hax20_end * 20)
|
||||
+ (self.bank_count_hax50_end * 50)
|
||||
+ (self.bank_count_hax100_end * 100)
|
||||
)
|
||||
|
||||
@property
|
||||
def pos_end_hax(self):
|
||||
return (
|
||||
(self.pos_count_hax5_end * 5)
|
||||
+ (self.pos_count_hax10_end * 10)
|
||||
+ (self.pos_count_hax20_end * 20)
|
||||
+ (self.pos_count_hax50_end * 50)
|
||||
+ (self.pos_count_hax100_end * 100)
|
||||
)
|
||||
|
||||
@property
|
||||
def dkk_end_ok(self):
|
||||
return self.bank_count_dkk_end == self.pos_count_dkk_end
|
||||
|
@ -747,7 +791,6 @@ class PosReport(CampRelatedModel, UUIDModel):
|
|||
def hax100_end_ok(self):
|
||||
return self.bank_count_hax100_end == self.pos_count_hax100_end
|
||||
|
||||
@property
|
||||
def allok(self):
|
||||
return all(
|
||||
[
|
||||
|
@ -765,3 +808,28 @@ class PosReport(CampRelatedModel, UUIDModel):
|
|||
self.hax100_end_ok,
|
||||
]
|
||||
)
|
||||
|
||||
@property
|
||||
def pos_json_sales(self):
|
||||
"""Calculate the total HAX sales and number of transactions."""
|
||||
transactions = 0
|
||||
total = 0
|
||||
for tx in self.pos_json:
|
||||
transactions += 1
|
||||
total += tx["amount"]
|
||||
return transactions, total
|
||||
|
||||
@property
|
||||
def hax_balance(self):
|
||||
"""Return the hax balance all things considered."""
|
||||
balance = 0
|
||||
# start by adding what the POS got at the start of the day
|
||||
balance += self.bank_start_hax
|
||||
# then substract the HAX the POS sold via the izettle
|
||||
balance -= self.hax_sold_izettle
|
||||
# then add the HAX sales from the POS json
|
||||
balance += self.pos_json_sales[1]
|
||||
# finally substract the HAX received from the POS at the end of the day
|
||||
balance -= self.bank_end_hax
|
||||
# all good
|
||||
return balance
|
||||
|
|
Loading…
Reference in a new issue