Fix: Fixed errors in purchase / purchase return / issue vouchers due to setting columns non-nullable
This commit is contained in:
parent
64c1820867
commit
cd3cfa4861
@ -25,8 +25,8 @@ def issue_create_voucher(json, user):
|
||||
for item in json['Inventories']:
|
||||
issue_create_inventory(voucher, item, batch_consumed)
|
||||
for item in issue_create_journals(voucher.inventories, source, destination):
|
||||
DBSession.add(item)
|
||||
voucher.journals.append(item)
|
||||
DBSession.add(item)
|
||||
journals_valid(voucher)
|
||||
inventory_valid(voucher)
|
||||
return voucher
|
||||
@ -51,8 +51,8 @@ def issue_create_inventory(voucher, item, batch_consumed):
|
||||
|
||||
item = Inventory(id=inventory_id, product_id=batch.product.id, quantity=quantity, rate=batch.rate, tax=batch.tax,
|
||||
discount=batch.discount, batch=batch)
|
||||
DBSession.add(item)
|
||||
voucher.inventories.append(item)
|
||||
DBSession.add(item)
|
||||
|
||||
|
||||
def issue_create_journals(inventories, source, destination):
|
||||
|
@ -18,8 +18,8 @@ def purchase_create_voucher(json, user):
|
||||
for item in json['Inventories']:
|
||||
purchase_create_inventory(voucher, item, dt)
|
||||
for item in purchase_create_journals(voucher.inventories, json['Journals'][0]['Ledger']['LedgerID']):
|
||||
DBSession.add(item)
|
||||
voucher.journals.append(item)
|
||||
DBSession.add(item)
|
||||
journals_valid(voucher)
|
||||
inventory_valid(voucher)
|
||||
return voucher
|
||||
@ -42,8 +42,8 @@ def purchase_create_inventory(voucher, item, date):
|
||||
inventory = Inventory(id=inventory_id, product_id=product.id, batch=batch, quantity=quantity, rate=rate, tax=tax,
|
||||
discount=discount)
|
||||
product.price = rate
|
||||
DBSession.add(inventory)
|
||||
voucher.inventories.append(inventory)
|
||||
DBSession.add(inventory)
|
||||
|
||||
|
||||
|
||||
@ -138,8 +138,8 @@ def purchase_update_inventory(voucher, newInventories):
|
||||
DBSession.add(batch)
|
||||
inventory.batch_id = batch.id
|
||||
product.price = rate
|
||||
DBSession.add(inventory)
|
||||
voucher.inventories.append(inventory)
|
||||
DBSession.add(inventory)
|
||||
|
||||
|
||||
def purchase_update_journals(voucher, journals):
|
||||
@ -169,7 +169,7 @@ def purchase_update_journals(voucher, journals):
|
||||
voucher.journals.remove(item)
|
||||
for item in journals.values():
|
||||
item.amount = round(item.amount, 2)
|
||||
DBSession.add(item)
|
||||
voucher.journals.append(item)
|
||||
DBSession.add(item)
|
||||
|
||||
|
||||
|
@ -18,8 +18,8 @@ def purchase_return_create_voucher(json, user):
|
||||
for item in json['Inventories']:
|
||||
purchase_return_create_inventory(voucher, item)
|
||||
for item in purchase_return_create_journals(voucher.inventories, json['Journals'][0]['Ledger']['LedgerID']):
|
||||
DBSession.add(item)
|
||||
voucher.journals.append(item)
|
||||
DBSession.add(item)
|
||||
journals_valid(voucher)
|
||||
inventory_valid(voucher)
|
||||
return voucher
|
||||
@ -39,8 +39,8 @@ def purchase_return_create_inventory(voucher, item):
|
||||
|
||||
item = Inventory(id=inventory_id, product_id=batch.product.id, quantity=quantity, rate=batch.rate, tax=batch.tax,
|
||||
discount=batch.discount, batch=batch)
|
||||
DBSession.add(item)
|
||||
voucher.inventories.append(item)
|
||||
DBSession.add(item)
|
||||
|
||||
|
||||
def purchase_return_create_journals(inventories, ledgerID):
|
||||
@ -97,8 +97,8 @@ def purchase_return_update_inventory(voucher, newInventories, date):
|
||||
break
|
||||
if not found:
|
||||
item.batch.quantity_remaining += item.quantity
|
||||
DBSession.delete(item)
|
||||
voucher.inventories.remove(item)
|
||||
DBSession.delete(item)
|
||||
for i in newInventories:
|
||||
purchase_return_create_inventory(voucher, i)
|
||||
|
||||
@ -130,7 +130,7 @@ def purchase_return_update_journals(voucher, journals):
|
||||
voucher.journals.remove(item)
|
||||
for item in journals.values():
|
||||
item.amount = item.amount
|
||||
DBSession.add(item)
|
||||
voucher.journals.append(item)
|
||||
DBSession.add(item)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user