Skip to content

Commit

Permalink
merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasbpro committed Jul 4, 2021
2 parents b0669f4 + a41560f commit 96b6621
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 94 deletions.
77 changes: 0 additions & 77 deletions app.py

This file was deleted.

Binary file removed data.db
Binary file not shown.
2 changes: 2 additions & 0 deletions resources/customers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ def put(self, id):
for key in data.keys():
if key=='name' and data['name']:
customer.name = data['name']

if key=='email' and data['email']:
customer.email = data['email']

if key=='birth_date' and data['birth_date']:
customer.birth_date = data['birth_date']

Expand Down
9 changes: 6 additions & 3 deletions resources/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ def put(self, id):
# in case it exists, updates it
if order:
for key in data.keys():
if key=='status_fabrication':

if key=='status_fabrication' and data['status_fabrication']:
order.status_fabrication = data['status_fabrication']
if key=='status_payment':

if key=='status_payment' and data['status_payment']:
order.status_payment = data['status_payment']
if key=='product_id':

if key=='product_id' and data['product_id']:
order.product_id = data['product_id']

# tries to insert in database
Expand Down
18 changes: 12 additions & 6 deletions resources/raw_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,23 @@ def put(self, id):
# in case it exists, updates it
if raw_material:
for key in data.keys():
if key=='package_price':

if key=='package_price' and data['package_price']:
raw_material.package_price = data['package_price']
if key=='package_amt':

if key=='package_amt' and data['package_amt']:
raw_material.package_amt = data['package_amt']
if key=='unit_material':

if key=='unit_material' and data['unit_material']:
raw_material.unit_material = data['unit_material']
if key=='stock_amt':

if key=='stock_amt' and data['stock_amt']:
raw_material.stock_amt = data['stock_amt']
if key=='sell_by_date':

if key=='sell_by_date' and data['sell_by_date']:
raw_material.sell_by_date = data['sell_by_date']
if key=='supplier_name':

if key=='supplier_name' and data['supplier_name']:
raw_material.supplier_name = data['supplier_name']

raw_material.last_update = datetime.now().strftime("%d/%m/%Y %H:%M")
Expand Down
22 changes: 14 additions & 8 deletions resources/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,27 @@ def put(self, id):

# checks if item exists in database
recipe = RecipeModel.find_by_id(id)

# in case it exists, updates it
# in case it exists, updates each of the recipe's parameters
if recipe:
for key in data.keys():
if key=='description':

if key=='description' and data['description']:
recipe.description = data['description']
if key=='labor_cost':

if key=='labor_cost' and data['labor_cost']:
recipe.labor_cost = data['labor_cost']
if key=='supply_cost':

if key=='supply_cost' and data['supply_cost']:
recipe.supply_cost = data['supply_cost']
if key=='productivity':

if key=='productivity' and data['productivity']:
recipe.productivity = data['productivity']
if key=='sell_by_date':

if key=='sell_by_date' and data['sell_by_date']:
recipe.sell_by_date = data['sell_by_date']
if key=='materials':

if key=='materials' and data['materials']:
recipe.materials.clear()
materialsDict = data['materials'][0]
for key in materialsDict.keys():
Expand Down

0 comments on commit 96b6621

Please sign in to comment.