Store location name, group name and tax group description in order

Also delete compiled entry JS and add a Makefile
This commit is contained in:
Paul Brinkmeier 2023-08-20 23:27:39 +02:00
parent a82e75999b
commit 1e4aadee06
7 changed files with 59 additions and 12430 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ jon/config.json
elm-stuff/ elm-stuff/
venv/ venv/
.venv/ .venv/
jon/static/*.js

6
Makefile Normal file
View File

@ -0,0 +1,6 @@
.PHONY: frontend
frontend: jon/static/entry.js
jon/static/entry.js: $(shell find $(SOURCEDIR) -name '*.c')
elm make --optimize frontend/Entry.elm --output $@

View File

@ -11,6 +11,19 @@ pip install -r requirements.txt
You should probably use a virtualenv for that. You should probably use a virtualenv for that.
I develop `jon` using Python 3.10 but it should work with older versions as well. I develop `jon` using Python 3.10 but it should work with older versions as well.
### Building Frontend JS
Most of jon works without JS but there are some features that require it.
The frontend code lives in `./frontend` and is written using Elm, a functional language that compiles to JS.
To compile the Elm code to `.js` files, first make sure that the Elm compiler is installed:
```
elm --version
# 0.19.1
```
Then run `make frontend`.
## Running ## Running
``` ```

View File

@ -227,15 +227,33 @@ view { globals, state } = case state of
] ]
, div [ class "form-input" ] , div [ class "form-input" ]
[ label [ for "group" ] [ text "Gruppe" ] [ label [ for "group" ] [ text "Gruppe" ]
, Select.view [ name "group", id "group" ] SetGroup model.group , Select.view [ name "group-id", id "group" ] SetGroup model.group
, input
[ type_ "hidden"
, name "group-name"
, value <| (Select.get model.group).name
]
[]
] ]
, div [ class "form-input" ] , div [ class "form-input" ]
[ label [ for "location" ] [ text "Raum" ] [ label [ for "location" ] [ text "Raum" ]
, Select.view [ name "location", id "location" ] SetLocation model.location , Select.view [ name "location-id", id "location" ] SetLocation model.location
, input
[ type_ "hidden"
, name "location-name"
, value <| (Select.get model.location).name
]
[]
] ]
, div [ class "form-input" ] , div [ class "form-input" ]
[ label [ for "tax-group" ] [ text "Steuergruppe" ] [ label [ for "tax-group" ] [ text "Steuergruppe" ]
, Select.view [ name "tax-group", id "tax-group" ] SetTaxGroup model.taxGroup , Select.view [ name "tax-group-id", id "tax-group" ] SetTaxGroup model.taxGroup
, input
[ type_ "hidden"
, name "tax-group-description"
, value <| (Select.get model.taxGroup).description
]
[]
] ]
, Html.map CalculatorMsg <| Calculator.view model.calculator (Select.get model.taxGroup) , Html.map CalculatorMsg <| Calculator.view model.calculator (Select.get model.taxGroup)
, div [ class "form-input" ] , div [ class "form-input" ]

View File

@ -37,9 +37,15 @@ def new_order():
barcode = request.form["barcode"] barcode = request.form["barcode"]
name = request.form["name"] name = request.form["name"]
sales_units = int(request.form["sales-units"]) sales_units = int(request.form["sales-units"])
group_id = int(request.form["group"]) group_id = int(request.form["group-id"])
location_id = int(request.form["location"]) # group_name, location_name and tax_group_description are not
tax_group_id = int(request.form["tax-group"]) # necessarily needed here but storing them makes it easier to
# render the list of orders.
group_name = request.form["group-name"]
location_id = int(request.form["location-id"])
location_name = request.form["location-name"]
tax_group_id = int(request.form["tax-group-id"])
tax_group_description = request.form["tax-group-description"]
net_unit_price = float(request.form["net-unit-price"]) net_unit_price = float(request.form["net-unit-price"])
gross_unit_price = float(request.form["gross-unit-price"]) gross_unit_price = float(request.form["gross-unit-price"])
except: except:
@ -52,8 +58,11 @@ def new_order():
"name": name, "name": name,
"sales_units": sales_units, "sales_units": sales_units,
"group_id": group_id, "group_id": group_id,
"group_name": group_name,
"location_id": location_id, "location_id": location_id,
"location_name": location_name,
"tax_group_id": tax_group_id, "tax_group_id": tax_group_id,
"tax_group_description": tax_group_description,
"net_unit_price": net_unit_price, "net_unit_price": net_unit_price,
"gross_unit_price": gross_unit_price "gross_unit_price": gross_unit_price
}) })

File diff suppressed because it is too large Load Diff

View File

@ -8,9 +8,9 @@
<th>Barcode</th> <th>Barcode</th>
<th>Name</th> <th>Name</th>
<th>Eingekauft</th> <th>Eingekauft</th>
<th>Gruppen-ID</th> <th>Gruppe</th>
<th>Raum-ID</th> <th>Raum</th>
<th>Steuergruppen-ID</th> <th>Steuergruppe</th>
<th>EK-Preis (Netto)</th> <th>EK-Preis (Netto)</th>
<th>VK-Preis (Brutto)</th> <th>VK-Preis (Brutto)</th>
<th>Aktionen</th> <th>Aktionen</th>
@ -20,9 +20,9 @@
<td><code>{{ cart_item.barcode }}</code></td> <td><code>{{ cart_item.barcode }}</code></td>
<td>{{ cart_item.name }}</td> <td>{{ cart_item.name }}</td>
<td class="--align-right">{{ cart_item.sales_units }}</td> <td class="--align-right">{{ cart_item.sales_units }}</td>
<td class="--align-right">{{ cart_item.group_id }}</td> <td class="--align-right">{{ cart_item.group_name }} ({{ cart_item.group_id }})</td>
<td class="--align-right">{{ cart_item.location_id }}</td> <td class="--align-right">{{ cart_item.location_name }} ({{ cart_item.location_id }})</td>
<td class="--align-right">{{ cart_item.tax_group_id }}</td> <td class="--align-right">{{ cart_item.tax_group_description }} ({{ cart_item.tax_group_id }})</td>
<td class="--align-right">{{ format_currency(cart_item.net_unit_price) }}</td> <td class="--align-right">{{ format_currency(cart_item.net_unit_price) }}</td>
<td class="--align-right">{{ format_currency(cart_item.gross_unit_price) }}</td> <td class="--align-right">{{ format_currency(cart_item.gross_unit_price) }}</td>
<td> <td>