-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add PosProduct(Cost), PosTransaction, PosSale models, import code, an…
…d backoffice views to interact with point-of-sale sales data
- Loading branch information
Showing
38 changed files
with
2,035 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
29 changes: 29 additions & 0 deletions
29
src/backoffice/management/commands/import_pos_sales_json.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import json | ||
import logging | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
from economy.utils import import_pos_sales_json | ||
|
||
logger = logging.getLogger("bornhack.%s" % __name__) | ||
|
||
|
||
class Command(BaseCommand): | ||
args = "none" | ||
help = "Import Pos sales JSON" | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
"jsonpath", | ||
type=str, | ||
help="The path to the Pos sales json file to import. The import is idempotent, no duplicates will be created.", | ||
) | ||
|
||
def handle(self, *args, **options): | ||
with open(options["jsonpath"]) as f: | ||
data = json.load(f) | ||
products, transactions, sales, costs = import_pos_sales_json(data) | ||
self.stdout.write(f"{products} new products created") | ||
self.stdout.write(f"{transactions} new transactions created") | ||
self.stdout.write(f"{sales} new sales created") | ||
self.stdout.write(f"{costs} new product_costs created") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% load querystring %} | ||
<div class="lead"> | ||
Per page: | ||
<div class="btn-group" role="group" aria-label="Per page"> | ||
<a href="{% querystring per_page=25 %}" class="btn btn-default">25</a> | ||
<a href="{% querystring per_page=100 %}" class="btn btn-default">100</a> | ||
<a href="{% querystring per_page=250 %}" class="btn btn-default">250</a> | ||
<a href="{% querystring per_page=1000 %}" class="btn btn-default">1000</a> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{% extends 'base.html' %} | ||
{% load render_table from django_tables2 %} | ||
{% load bootstrap3 %} | ||
{% load django_tables2 %} | ||
|
||
{% block title %} | ||
Pos Product Costs | BackOffice | {{ block.super }} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title">Pos Product Costs | BackOffice</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<p> | ||
<a href="{% url 'backoffice:index' camp_slug=camp.slug %}" class="btn btn-default"><i class="fas fa-undo"></i> Backoffice</a> | ||
<a href="{% url 'backoffice:pos_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos List</a> | ||
<a href="{% url 'backoffice:posproduct_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos Product List</a> | ||
<a href="{% url 'backoffice:posproductcost_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos Product Cost List</a> | ||
<a href="{% url 'backoffice:postransaction_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos Transaction List</a> | ||
<a href="{% url 'backoffice:possale_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos Sales List</a> | ||
</p> | ||
<p class="lead">A Pos Product Cost shows the cost of selling one of a product. Pos Product Costs are applied to all sales after the timestamp, until a newer Pos Product Cost is created.</p> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Filter Pos Product Costs</div> | ||
<div class="panel-body"> | ||
{% if filter %} | ||
<form action="" method="get" class="form form-inline"> | ||
{% bootstrap_form filter.form layout='inline' %} | ||
<br> | ||
<button class="btn btn-success"><i class="fas fa-search"></i> Filter</button> | ||
<a href="{% url 'backoffice:posproductcost_list' camp_slug=camp.slug %}" class="btn btn-danger"><i class="fas fa-times"></i> Clear</a> | ||
</form> | ||
{% endif %} | ||
</div> | ||
</div> | ||
<div class="lead">Showing {{ object_list.count }} costs out of {{ total_costs }} costs for {{ camp.title }}</div> | ||
{% include "includes/table_pagination.html" %} | ||
{% render_table table %} | ||
{% include "includes/table_pagination.html" %} | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{% extends 'base.html' %} | ||
{% load render_table from django_tables2 %} | ||
{% load bootstrap3 %} | ||
|
||
{% block title %} | ||
Pos Products | BackOffice | {{ block.super }} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title">Pos Products | BackOffice</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<p> | ||
<a href="{% url 'backoffice:index' camp_slug=camp.slug %}" class="btn btn-default"><i class="fas fa-undo"></i> Backoffice</a> | ||
<a href="{% url 'backoffice:pos_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos List</a> | ||
<a href="{% url 'backoffice:posproduct_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos Product List</a> | ||
<a href="{% url 'backoffice:posproductcost_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos Product Cost List</a> | ||
<a href="{% url 'backoffice:postransaction_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos Transaction List</a> | ||
<a href="{% url 'backoffice:possale_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos Sales List</a> | ||
</p> | ||
<p class="lead">A Pos Product is something sold at a Pos. Price, name and other product details might change over time. The sales numbers shown in this table only include transactions related to {{ camp.title }}.</p> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Filter Pos Products</div> | ||
<div class="panel-body"> | ||
{% if filter %} | ||
<form action="" method="get" class="form form-inline"> | ||
{% bootstrap_form filter.form layout='inline' %} | ||
<br> | ||
<button class="btn btn-success"><i class="fas fa-search"></i> Filter</button> | ||
<a href="{% url 'backoffice:posproduct_list' camp_slug=camp.slug %}" class="btn btn-danger"><i class="fas fa-times"></i> Clear</a> | ||
</form> | ||
{% endif %} | ||
</div> | ||
</div> | ||
<div class="lead">Showing {{ object_list|length }} products ({{ filtered_sales_count }} sales for {{ filtered_sales_sum }} HAX) out of total {{ total_products }} products ({{ total_sales_count }} sales for {{ total_sales_sum }} HAX) for {{ camp.title }}</div> | ||
{% include "includes/table_pagination.html" %} | ||
{% render_table table %} | ||
{% include "includes/table_pagination.html" %} | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{% extends 'base.html' %} | ||
{% load render_table from django_tables2 %} | ||
{% load bootstrap3 %} | ||
{% load django_tables2 %} | ||
|
||
{% block title %} | ||
{{ pos.name }} | Pos Sales | BackOffice | {{ block.super }} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title">Pos Sales | BackOffice</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<p> | ||
<a href="{% url 'backoffice:index' camp_slug=camp.slug %}" class="btn btn-default"><i class="fas fa-undo"></i> Backoffice</a> | ||
<a href="{% url 'backoffice:pos_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos List</a> | ||
<a href="{% url 'backoffice:posproduct_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos Product List</a> | ||
<a href="{% url 'backoffice:posproductcost_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos Product Cost List</a> | ||
<a href="{% url 'backoffice:postransaction_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos Transaction List</a> | ||
<a href="{% url 'backoffice:possale_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos Sales List</a> | ||
</p> | ||
<p class="lead">A Pos Sale is created every time an item is sold and paid with HAX at a Pos. Buying two Mate creates one Pos Transaction with two Pos Sales.</p> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Filter Pos Sales</div> | ||
<div class="panel-body"> | ||
{% if filter %} | ||
<form action="" method="get" class="form form-inline"> | ||
{% bootstrap_form filter.form layout='inline' %} | ||
<br> | ||
<button class="btn btn-success"><i class="fas fa-search"></i> Filter</button> | ||
<a href="{% url 'backoffice:possale_list' camp_slug=camp.slug %}" class="btn btn-danger"><i class="fas fa-times"></i> Clear</a> | ||
</form> | ||
{% endif %} | ||
</div> | ||
</div> | ||
<div class="lead">Showing {{ possale_list.count }} sales ({{ filtered_sales_sum }} HAX) out of {{ total_sales_count }} sales ({{total_sales_sum}} HAX) for {{ camp.title }}</div> | ||
{% include "includes/table_pagination.html" %} | ||
{% render_table table %} | ||
{% include "includes/table_pagination.html" %} | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{% extends 'base.html' %} | ||
{% load bootstrap3 %} | ||
|
||
{% block content %} | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title">Pos Sales JSON Upload</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<p class="lead">Pos Sales JSON Upload</p> | ||
<form method="POST" enctype="multipart/form-data"> | ||
{% csrf_token %} | ||
{% bootstrap_form form %} | ||
<button type="submit" class="btn btn-success"><i class="fas fa-check"></i> Upload</button> | ||
<a href="{% url 'backoffice:pos_list' camp_slug=camp.slug %}" class="btn btn-default"><i class="fas fa-undo"></i> Cancel</a> | ||
</form> | ||
</div> | ||
</div> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{% extends 'base.html' %} | ||
{% load render_table from django_tables2 %} | ||
{% load bootstrap3 %} | ||
{% load django_tables2 %} | ||
|
||
{% block title %} | ||
Pos Transactions | BackOffice | {{ block.super }} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title">Pos Transactions | BackOffice</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<p> | ||
<a href="{% url 'backoffice:index' camp_slug=camp.slug %}" class="btn btn-default"><i class="fas fa-undo"></i> Backoffice</a> | ||
<a href="{% url 'backoffice:pos_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos List</a> | ||
<a href="{% url 'backoffice:posproduct_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos Product List</a> | ||
<a href="{% url 'backoffice:posproductcost_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos Product Cost List</a> | ||
<a href="{% url 'backoffice:postransaction_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos Transaction List</a> | ||
<a href="{% url 'backoffice:possale_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-list"></i> Pos Sales List</a> | ||
</p> | ||
<p class="lead">A Pos Transaction is created every time one or more items are sold and paid with HAX. Buying two Mate creates one Pos Transaction with two Pos Sales.</p> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Filter Pos Transactions</div> | ||
<div class="panel-body"> | ||
{% if filter %} | ||
<form action="" method="get" class="form form-inline"> | ||
{% bootstrap_form filter.form layout='inline' %} | ||
<br> | ||
<button class="btn btn-success"><i class="fas fa-search"></i> Filter</button> | ||
<a href="{% url 'backoffice:postransaction_list' camp_slug=camp.slug %}" class="btn btn-danger"> | ||
<i class="fas fa-times"></i> Clear | ||
</a> | ||
</form> | ||
{% endif %} | ||
</div> | ||
</div> | ||
<div class="lead">Filter showing {{ object_list|length }} transactions ({{ filtered_sales_count }} sales for {{ filtered_sales_sum }} HAX) of {{ total_transactions }} transactions ({{ total_sales_count }} sales for {{ total_sales_sum }} HAX)</div> | ||
{% include "includes/table_pagination.html" %} | ||
{% render_table table %} | ||
{% include "includes/table_pagination.html" %} | ||
</div> | ||
</div> | ||
{% endblock %} |
Oops, something went wrong.