overflow validation fixed

This commit is contained in:
nabinhait 2014-07-09 17:36:38 +05:30
parent 16658c14fe
commit d5fb5d91e9
7 changed files with 20 additions and 10 deletions

View File

@ -30,6 +30,7 @@ class PurchaseInvoice(BuyingController):
'target_ref_field': 'amount',
'source_field': 'amount',
'percent_join_field': 'purchase_order',
'overflow_type': 'billing'
}]
def validate(self):

View File

@ -36,7 +36,8 @@ class SalesInvoice(SellingController):
'join_field': 'so_detail',
'percent_join_field': 'sales_order',
'status_field': 'billing_status',
'keyword': 'Billed'
'keyword': 'Billed',
'overflow_type': 'billing'
}]
def validate(self):
@ -134,7 +135,8 @@ class SalesInvoice(SellingController):
'keyword':'Delivered',
'second_source_dt': 'Delivery Note Item',
'second_source_field': 'qty',
'second_join_field': 'prevdoc_detail_docname'
'second_join_field': 'prevdoc_detail_docname',
'overflow_type': 'delivery'
})
def on_update_after_submit(self):

View File

@ -24,6 +24,7 @@ class PurchaseOrder(BuyingController):
'target_ref_field': 'qty',
'source_field': 'qty',
'percent_join_field': 'prevdoc_docname',
'overflow_type': 'order'
}]
def validate(self):

View File

@ -132,11 +132,12 @@ class StatusUpdater(Document):
if not item[args['target_ref_field']]:
msgprint(_("Note: System will not check over-delivery and over-booking for Item {0} as quantity or amount is 0").format(item.item_code))
elif args.get('no_tolerance'):
item['reduce_by'] = item[args['target_field']] - \
item[args['target_ref_field']]
item['reduce_by'] = item[args['target_field']] - item[args['target_ref_field']]
if item['reduce_by'] > .01:
msgprint(_("Allowance for over-delivery / over-billing crossed for Item {0}").format(item.item_code))
throw(_("{0} must be less than or equal to {1}").format(_(item.target_ref_field), item[args["target_ref_field"]]))
msgprint(_("Allowance for over-{0} crossed for Item {1}")
.format(args["overflow_type"], item.item_code))
throw(_("{0} must be reduced by {1} or you should increase overflow tolerance")
.format(_(item.target_ref_field.title()), item["reduce_by"]))
else:
self.check_overflow_with_tolerance(item, args)
@ -156,8 +157,10 @@ class StatusUpdater(Document):
item['max_allowed'] = flt(item[args['target_ref_field']] * (100+tolerance)/100)
item['reduce_by'] = item[args['target_field']] - item['max_allowed']
msgprint(_("Allowance for over-delivery / over-billing crossed for Item {0}.").format(item["item_code"]))
throw(_("{0} must be less than or equal to {1}").format(item["target_ref_field"].title(), item["max_allowed"]))
msgprint(_("Allowance for over-{0} crossed for Item {1}.")
.format(args["overflow_type"], item["item_code"]))
throw(_("{0} must be reduced by {1} or you should increase overflow tolerance")
.format(_(item["target_ref_field"].title()), item["reduce_by"]))
def update_qty(self, change_modified=True):
"""

View File

@ -28,7 +28,8 @@ class InstallationNote(TransactionBase):
'source_field': 'qty',
'percent_join_field': 'prevdoc_docname',
'status_field': 'installation_status',
'keyword': 'Installed'
'keyword': 'Installed',
'overflow_type': 'installation'
}]
def validate(self):

View File

@ -29,7 +29,8 @@ class DeliveryNote(SellingController):
'source_field': 'qty',
'percent_join_field': 'against_sales_order',
'status_field': 'delivery_status',
'keyword': 'Delivered'
'keyword': 'Delivered',
'overflow_type': 'delivery'
}]
def onload(self):

View File

@ -27,6 +27,7 @@ class PurchaseReceipt(BuyingController):
'target_ref_field': 'qty',
'source_field': 'qty',
'percent_join_field': 'prevdoc_docname',
'overflow_type': 'receipt'
}]
def onload(self):