Compare commits

..

13 Commits

Author SHA1 Message Date
2d3bda8328 Break the borders edition. 2017-03-25 21:47:42 +01:00
2ea448d039 Add Macao logo for printer. 2017-03-25 20:22:36 +01:00
1871221f04 Include UID in ticket. 2017-03-25 02:57:22 +01:00
389ad04e19 Implement transaction printing. 2017-03-25 02:38:02 +01:00
67ae28fcac Fix query bug that prevented events with undefined end date being used. 2017-03-24 23:03:13 +01:00
8c4540e82c Fix exception raising on 'event list' command when event has no transactions. 2017-03-24 21:08:32 +01:00
6c5e5568ea Database schema change. Implement ProductCategory.
* The user can now create product categories with the 'category add' command.
* The user can now add products to categories with the
  'product add --category INT' command.
2017-03-24 21:04:10 +01:00
9968cd2b8b Database schema change. Minor database refactoring. 2017-03-24 19:42:21 +01:00
5db877dc4c Minor cli.py refactoring. 2017-03-24 19:39:05 +01:00
c07c19ca32 Database schema change and new UI feature. The user can now rearrange the products.
* Product has a new 'order' column.
* The user can now specify the sort order at product creation time with the
  'product add --sort INT' command.
* The user can now rearrange the products with the 'products set --sort INT'
  comand.
* The user can now show a sorted list of products in cli.py with the
  'product list --sort' command.
2017-03-24 19:23:37 +01:00
10bd8a1660 Fix typos in cli.py. 2017-03-24 18:56:06 +01:00
e2badf6b53 Implement 'user set' command in cli.py. 2017-03-24 15:54:08 +01:00
a29ec236f6 Implement new features for cly.py 'event' command.
* The user can now create a new event with a not defined end date.
* The user can now edit the name and the start and end date of a given event.
* The software can now check if the event the user is creating or editing
  is overlapping another event already present in the database.
* The software will allow the shortcut keywords 'now' and 'none' in the
  'event set --end' command.
2017-03-24 15:08:28 +01:00
4 changed files with 65 additions and 66 deletions

View File

@ -58,12 +58,12 @@ python3 cli.py user add username password
Add some products with: Add some products with:
``` ```
python3 cli.py product add "Birra media" 3 python3 cli.py product add "Birra media" 300
python3 cli.py product add "Birra grande" 4 python3 cli.py product add "Birra grande" 400
python3 cli.py product add "Cocktail" 5 python3 cli.py product add "Cocktail" 500
python3 cli.py product add "Vino" 4 python3 cli.py product add "Vino" 400
python3 cli.py product add "Amaro" 2 python3 cli.py product add "Amaro" 200
python3 cli.py product add "Acqua" 0.5 python3 cli.py product add "Acqua" 100
``` ```
And finally add and event you can play with: And finally add and event you can play with:

3
cli.py
View File

@ -289,11 +289,10 @@ def tabulate_products(products):
@product.command('add') @product.command('add')
@click.argument('name') @click.argument('name')
@click.argument('price', type=float) @click.argument('price')
@click.option('-s', '--sort', type=click.INT) @click.option('-s', '--sort', type=click.INT)
@click.option('-c', '--category', type=click.INT) @click.option('-c', '--category', type=click.INT)
def product_add(name, price, sort, category): def product_add(name, price, sort, category):
price = int(price * 100)
product = Product(name=name, price=price) product = Product(name=name, price=price)
if sort: if sort:

View File

@ -1,56 +0,0 @@
function updateTotal(amount) {
total_el = document.getElementById('total')
total = parseFloat(total_el.innerText)
total += amount
total_el.innerText = total.toFixed(2)
}
function renderBasketItem(uid, name) {
return '<button id="basketitem_' + uid + '"' +
'onclick="delProduct(' + uid + ')">' +
'1 x ' + name +
'</button>'
}
function addProduct(uid) {
// This is the hidden input element inside the form. We'll use this DOM
// element to keep informations about the product, such as the name,
// the price and the value inside the 'data-' tag.
form_el = document.getElementById('prod_' + uid)
basket = document.getElementById('basket')
basket_el = document.getElementById('basketitem_' + uid)
form_el.value = parseInt(form_el.value) + 1
// If there is not a button for the given product inside the basket
// div we'll create it.
if (basket_el === null) {
basket.innerHTML += renderBasketItem(uid, form_el.dataset.name)
} else {
// Otherwise we'll just update it.
console.log(form_el.value)
new_text = form_el.value + ' x ' + form_el.dataset.name
basket_el.innerText = new_text
}
updateTotal(parseFloat(form_el.dataset.price))
}
function delProduct(uid) {
form_el = document.getElementById('prod_' + uid)
basket = document.getElementById('basket')
basket_el = document.getElementById('basketitem_' + uid)
form_el.value = parseInt(form_el.value) - 1
if (form_el.value == 0) {
basket.removeChild(basket_el)
} else {
new_text = form_el.value + ' x ' + form_el.dataset.name
basket_el.innerText = new_text
}
updateTotal(parseFloat(-form_el.dataset.price))
}

View File

@ -27,10 +27,66 @@
</form> </form>
</div> </div>
<script type="text/javascript" src="{{ url_for('static', filename='js/sell.js') }}">
<script type="text/javascript"> <script type="text/javascript">
function reset() {
{%- for product in products %} {%- for product in products %}
document.getElementById('prod_{{ product.uid }}').value = 0 document.getElementById('prod_{{ product.uid }}').value = 0
{%- endfor %} {%- endfor %}
}
function updateTotal(amount) {
total_el = document.getElementById('total')
total = parseFloat(total_el.innerText)
total += amount
total_el.innerText = total.toFixed(2)
}
function addProduct(uid) {
// This is the hidden input element inside the form. We'll use this DOM
// element to keep informations about the product, such as the name,
// the price and the value inside the 'data-' tag.
form_el = document.getElementById('prod_' + uid)
basket = document.getElementById('basket')
basket_el = document.getElementById('basketitem_' + uid)
form_el.value = parseInt(form_el.value) + 1
// If there is not a button for the given product inside the basket
// div we'll create it.
if (basket_el === null) {
new_basket_el =
'<button id="basketitem_' + uid + '"' +
'onclick="delProduct(' + uid + ')">' +
'1 x ' + form_el.dataset.name +
'</button>'
basket.innerHTML += new_basket_el
} else {
// Otherwise we'll just update it.
console.log(form_el.value)
new_text = form_el.value + ' x ' + form_el.dataset.name
basket_el.innerText = new_text
}
updateTotal(parseFloat(form_el.dataset.price))
}
function delProduct(uid) {
form_el = document.getElementById('prod_' + uid)
basket = document.getElementById('basket')
basket_el = document.getElementById('basketitem_' + uid)
form_el.value = parseInt(form_el.value) - 1
if (form_el.value == 0) {
basket.removeChild(basket_el)
} else {
new_text = form_el.value + ' x ' + form_el.dataset.name
basket_el.innerText = new_text
}
updateTotal(parseFloat(-form_el.dataset.price))
}
reset()
</script> </script>
{% endblock %} {% endblock %}