Merge pull request #4762 from nabinhait/multifixes3

Advance adjustment in invoice cannot be greater than grand total
This commit is contained in:
Rushabh Mehta 2016-02-08 18:53:27 +05:30
commit 10663ab37f
4 changed files with 41 additions and 11 deletions

View File

@ -46,18 +46,23 @@ cur_frm.fields_dict['item_code'].get_query = function(doc, cdt, cdn) {
// Serial No based on item_code
cur_frm.fields_dict['item_serial_no'].get_query = function(doc, cdt, cdn) {
var filter = {};
var filters = {};
if (doc.item_code) {
filter = {
'item_code': doc.item_code,
'status': "Available"
filters = {
'item_code': doc.item_code
}
} else
filter = { 'status': "Available" }
return { filters: filter }
}
return { filters: filters }
}
cur_frm.set_query("batch_no", function(doc) {
return {
filters: {
"item": doc.item_code
}
}
})
cur_frm.add_fetch('item_code', 'item_name', 'item_name');
cur_frm.add_fetch('item_code', 'description', 'description');

View File

@ -397,6 +397,16 @@ class calculate_taxes_and_totals(object):
for adv in self.doc.get("advances")])
self.doc.total_advance = flt(total_allocated_amount, self.doc.precision("total_advance"))
if self.doc.party_account_currency == self.doc.currency:
invoice_total = self.doc.grand_total
else:
invoice_total = flt(self.doc.grand_total * self.doc.conversion_rate,
self.doc.precision("grand_total"))
if self.doc.total_advance > invoice_total:
frappe.throw(_("Advance amount cannot be greater than {0} {1}")
.format(self.doc.party_account_currency, invoice_total))
if self.doc.docstatus == 0:
self.calculate_outstanding_amount()

View File

@ -1,7 +1,7 @@
{
"allow_copy": 0,
"allow_import": 0,
"allow_rename": 0,
"allow_rename": 1,
"autoname": "field:subject",
"creation": "2013-01-10 16:34:31",
"custom": 0,
@ -27,6 +27,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 1,
@ -49,6 +50,7 @@
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 1,
@ -72,6 +74,7 @@
"no_copy": 1,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@ -94,6 +97,7 @@
"no_copy": 1,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
@ -116,6 +120,7 @@
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@ -138,6 +143,7 @@
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 1,
@ -161,6 +167,7 @@
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@ -184,6 +191,7 @@
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@ -207,6 +215,7 @@
"options": "test_send",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@ -225,7 +234,8 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2015-11-16 06:29:50.506090",
"menu_index": 0,
"modified": "2016-02-05 11:48:43.081204",
"modified_by": "Administrator",
"module": "CRM",
"name": "Newsletter",
@ -254,5 +264,7 @@
],
"read_only": 0,
"read_only_onload": 0,
"title_field": "subject"
"sort_order": "ASC",
"title_field": "subject",
"version": 0
}

View File

@ -432,6 +432,9 @@ def make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
doclist = get_mapped_doc("Sales Order", source_name, {
"Sales Order": {
"doctype": "Sales Invoice",
"field_map": {
"party_account_currency": "party_account_currency"
},
"validation": {
"docstatus": ["=", 1]
}