Billed amount in SO and DN based on export amount and patch for it
diff --git a/erpnext/patches/august_2012/repost_billed_amt.py b/erpnext/patches/august_2012/repost_billed_amt.py
new file mode 100644
index 0000000..e6b463c
--- /dev/null
+++ b/erpnext/patches/august_2012/repost_billed_amt.py
@@ -0,0 +1,9 @@
+def execute():
+ import webnotes
+ from webnotes.model.code import get_obj
+ from selling.doctype.sales_common.sales_common import StatusUpdater
+
+ invoices = webnotes.conn.sql("select name from `tabSales Invoice` where docstatus = 1")
+ for inv in invoices:
+ inv_obj = get_obj('Sales Invoice', inv[0], with_children=1)
+ StatusUpdater(inv_obj, 1).update_all_qty()
\ No newline at end of file
diff --git a/erpnext/selling/doctype/sales_common/sales_common.py b/erpnext/selling/doctype/sales_common/sales_common.py
index 57724ac..b3d9f40 100644
--- a/erpnext/selling/doctype/sales_common/sales_common.py
+++ b/erpnext/selling/doctype/sales_common/sales_common.py
@@ -689,14 +689,14 @@
self.validate_qty({
'source_dt' :'Sales Invoice Item',
'compare_field' :'billed_amt',
- 'compare_ref_field' :'amount',
+ 'compare_ref_field' :'export_amount',
'target_dt' :'Sales Order Item',
'join_field' :'so_detail'
})
self.validate_qty({
'source_dt' :'Sales Invoice Item',
'compare_field' :'billed_amt',
- 'compare_ref_field' :'amount',
+ 'compare_ref_field' :'export_amount',
'target_dt' :'Delivery Note Item',
'join_field' :'dn_detail'
}, no_tolerance =1)
@@ -808,9 +808,9 @@
'target_dt' :'Sales Order Item',
'target_parent_dt' :'Sales Order',
'target_parent_field' :'per_billed',
- 'target_ref_field' :'amount',
+ 'target_ref_field' :'export_amount',
'source_dt' :'Sales Invoice Item',
- 'source_field' :'amount',
+ 'source_field' :'export_amount',
'join_field' :'so_detail',
'percent_join_field' :'sales_order',
'status_field' :'billing_status',
@@ -822,9 +822,9 @@
'target_dt' :'Delivery Note Item',
'target_parent_dt' :'Delivery Note',
'target_parent_field' :'per_billed',
- 'target_ref_field' :'amount',
+ 'target_ref_field' :'export_amount',
'source_dt' :'Sales Invoice Item',
- 'source_field' :'amount',
+ 'source_field' :'export_amount',
'join_field' :'dn_detail',
'percent_join_field' :'delivery_note',
'status_field' :'billing_status',