Fixed again
This commit is contained in:
@ -9,6 +9,7 @@ from brewman.models.voucher import Voucher, VoucherType, Batch, Inventory, Journ
|
|||||||
|
|
||||||
__author__ = 'tanshu'
|
__author__ = 'tanshu'
|
||||||
|
|
||||||
|
|
||||||
def purchase_return_create_voucher(json, user):
|
def purchase_return_create_voucher(json, user):
|
||||||
dt = datetime.datetime.strptime(json['Date'], '%d-%b-%Y')
|
dt = datetime.datetime.strptime(json['Date'], '%d-%b-%Y')
|
||||||
voucher = Voucher(date=dt, narration=json['Narration'], user_id=user.id, type=VoucherType.by_name(json['Type']))
|
voucher = Voucher(date=dt, narration=json['Narration'], user_id=user.id, type=VoucherType.by_name(json['Type']))
|
||||||
@ -50,7 +51,7 @@ def purchase_return_create_journals(inventories, ledgerID):
|
|||||||
ledger = Product.by_id(item.product_id).ledger
|
ledger = Product.by_id(item.product_id).ledger
|
||||||
amount += round(item.amount, 2)
|
amount += round(item.amount, 2)
|
||||||
if ledger.id in journals:
|
if ledger.id in journals:
|
||||||
journals[ledger.id].amount += amount
|
journals[ledger.id].amount += round(item.amount, 2)
|
||||||
else:
|
else:
|
||||||
journals[ledger.id] = Journal(debit=-1, cost_center_id=ledger.costcenter_id, ledger_id=ledger.id,
|
journals[ledger.id] = Journal(debit=-1, cost_center_id=ledger.costcenter_id, ledger_id=ledger.id,
|
||||||
amount=item.amount)
|
amount=item.amount)
|
||||||
@ -88,7 +89,7 @@ def purchase_return_update_inventory(voucher, newInventories, date):
|
|||||||
if quantity == 0:
|
if quantity == 0:
|
||||||
raise ValidationError("Quantity of {0} cannot be zero".format(item.product.name))
|
raise ValidationError("Quantity of {0} cannot be zero".format(item.product.name))
|
||||||
if quantity - item.quantity > item.batch.quantity_remaining:
|
if quantity - item.quantity > item.batch.quantity_remaining:
|
||||||
raise ValidationError("Maximum quantity available for {0} is {1}".format( item.product.full_name,
|
raise ValidationError("Maximum quantity available for {0} is {1}".format(item.product.full_name,
|
||||||
item.quantity + item.batch.quantity_remaining))
|
item.quantity + item.batch.quantity_remaining))
|
||||||
item.batch.quantity_remaining -= (quantity - item.quantity)
|
item.batch.quantity_remaining -= (quantity - item.quantity)
|
||||||
item.quantity = quantity
|
item.quantity = quantity
|
||||||
|
|||||||
Reference in New Issue
Block a user