Merge branch 'v7.2.0-beta' into develop
This commit is contained in:
commit
0632ee3da9
@ -4,7 +4,7 @@ from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
import unittest, copy
|
||||
from frappe.utils import nowdate, add_days, flt, nowdate
|
||||
from frappe.utils import nowdate, add_days, flt
|
||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry, get_qty_after_transaction
|
||||
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import unlink_payment_on_cancel_of_invoice
|
||||
from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile
|
||||
@ -162,11 +162,50 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self.assertEquals(si.base_grand_total, 1628)
|
||||
self.assertEquals(si.grand_total, 32.56)
|
||||
|
||||
def test_sales_invoice_with_discount_and_inclusive_tax(self):
|
||||
si = create_sales_invoice(qty=100, rate=50, do_not_save=True)
|
||||
si.append("taxes", {
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": "_Test Account Service Tax - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Service Tax",
|
||||
"rate": 14,
|
||||
'included_in_print_rate': 1
|
||||
})
|
||||
si.insert()
|
||||
|
||||
# with inclusive tax
|
||||
self.assertEquals(si.net_total, 4385.96)
|
||||
self.assertEquals(si.grand_total, 5000)
|
||||
|
||||
si.reload()
|
||||
|
||||
# additional discount
|
||||
si.discount_amount = 100
|
||||
si.apply_discount_on = 'Net Total'
|
||||
|
||||
si.save()
|
||||
|
||||
# with inclusive tax and additional discount
|
||||
self.assertEquals(si.net_total, 4285.96)
|
||||
self.assertEquals(si.grand_total, 4885.99)
|
||||
|
||||
si.reload()
|
||||
|
||||
# additional discount on grand total
|
||||
si.discount_amount = 100
|
||||
si.apply_discount_on = 'Grand Total'
|
||||
|
||||
si.save()
|
||||
|
||||
# with inclusive tax and additional discount
|
||||
self.assertEquals(si.net_total, 4298.24)
|
||||
self.assertEquals(si.grand_total, 4900.00)
|
||||
|
||||
def test_sales_invoice_discount_amount(self):
|
||||
si = frappe.copy_doc(test_records[3])
|
||||
si.discount_amount = 104.95
|
||||
si.append("taxes", {
|
||||
"doctype": "Sales Taxes and Charges",
|
||||
"charge_type": "On Previous Row Amount",
|
||||
"account_head": "_Test Account Service Tax - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
|
@ -366,8 +366,9 @@ class calculate_taxes_and_totals(object):
|
||||
# discount amount rounding loss adjustment if no taxes
|
||||
if (not taxes or self.doc.apply_discount_on == "Net Total") \
|
||||
and i == len(self.doc.get("items")) - 1:
|
||||
discount_amount_loss = flt(self.doc.total - net_total - self.doc.discount_amount,
|
||||
discount_amount_loss = flt(self.doc.net_total - net_total - self.doc.discount_amount,
|
||||
self.doc.precision("net_total"))
|
||||
|
||||
item.net_amount = flt(item.net_amount + discount_amount_loss,
|
||||
item.precision("net_amount"))
|
||||
|
||||
|
@ -1051,6 +1051,67 @@
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 1,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fieldname": "unit_of_measure_conversion",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Units of Measure",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"description": "Will also apply for variants",
|
||||
"fieldname": "uoms",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "UOMs",
|
||||
"length": 0,
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "uom_conversion_details",
|
||||
"oldfieldtype": "Table",
|
||||
"options": "UOM Conversion Detail",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
@ -1356,67 +1417,6 @@
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fieldname": "unit_of_measure_conversion",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Unit of Measure Conversion",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"description": "Will also apply for variants",
|
||||
"fieldname": "uoms",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "UOMs",
|
||||
"length": 0,
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "uom_conversion_details",
|
||||
"oldfieldtype": "Table",
|
||||
"options": "UOM Conversion Detail",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
@ -2683,7 +2683,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 1,
|
||||
"modified": "2016-12-13 02:19:54.507883",
|
||||
"modified": "2016-12-21 16:19:05.997203",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Item",
|
||||
|
@ -431,22 +431,16 @@ frappe.ui.form.on('Stock Entry Detail', {
|
||||
uom: function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if(d.uom && d.item_code){
|
||||
arg = {
|
||||
'item_code':d.item_code,
|
||||
'uom':d.uom,
|
||||
'qty':d.qty
|
||||
};
|
||||
return frappe.call({
|
||||
doc: cur_frm.doc,
|
||||
method: "get_uom_details",
|
||||
args: arg,
|
||||
method: "erpnext.stock.doctype.stock_entry.stock_entry.get_uom_details",
|
||||
args: {
|
||||
item_code: d.item_code,
|
||||
uom: d.uom,
|
||||
qty: d.qty
|
||||
},
|
||||
callback: function(r) {
|
||||
if(r.message) {
|
||||
var d = locals[cdt][cdn];
|
||||
$.each(r.message, function(k, v) {
|
||||
d[k] = v;
|
||||
});
|
||||
refresh_field("items");
|
||||
frappe.model.set_value(cdt, cdn, r.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -496,7 +496,7 @@ class StockEntry(StockController):
|
||||
|
||||
# update uom
|
||||
if args.get("uom") and for_update:
|
||||
ret.update(self.get_uom_details(args))
|
||||
ret.update(get_uom_details(args.get('item_code'), args.get('uom'), args.get('qty')))
|
||||
|
||||
if not ret["expense_account"]:
|
||||
ret["expense_account"] = frappe.db.get_value("Company", self.company, "stock_adjustment_account")
|
||||
@ -509,23 +509,6 @@ class StockEntry(StockController):
|
||||
|
||||
return ret
|
||||
|
||||
def get_uom_details(self, args):
|
||||
"""Returns dict `{"conversion_factor": [value], "transfer_qty": qty * [value]}`
|
||||
|
||||
:param args: dict with `item_code`, `uom` and `qty`"""
|
||||
conversion_factor = get_conversion_factor(args.get("item_code"), args.get("uom")).get("conversion_factor")
|
||||
|
||||
if not conversion_factor:
|
||||
frappe.msgprint(_("UOM coversion factor required for UOM: {0} in Item: {1}")
|
||||
.format(args.get("uom"), args.get("item_code")))
|
||||
ret = {'uom' : ''}
|
||||
else:
|
||||
ret = {
|
||||
'conversion_factor' : flt(conversion_factor),
|
||||
'transfer_qty' : flt(args.get("qty")) * flt(conversion_factor)
|
||||
}
|
||||
return ret
|
||||
|
||||
def get_items(self):
|
||||
self.set('items', [])
|
||||
self.validate_production_order()
|
||||
@ -849,6 +832,24 @@ def get_operating_cost_per_unit(production_order=None, bom_no=None):
|
||||
|
||||
return operating_cost_per_unit
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_uom_details(item_code, uom, qty):
|
||||
"""Returns dict `{"conversion_factor": [value], "transfer_qty": qty * [value]}`
|
||||
|
||||
:param args: dict with `item_code`, `uom` and `qty`"""
|
||||
conversion_factor = get_conversion_factor(item_code, uom).get("conversion_factor")
|
||||
|
||||
if not conversion_factor:
|
||||
frappe.msgprint(_("UOM coversion factor required for UOM: {0} in Item: {1}")
|
||||
.format(uom, item_code))
|
||||
ret = {'uom' : ''}
|
||||
else:
|
||||
ret = {
|
||||
'conversion_factor' : flt(conversion_factor),
|
||||
'transfer_qty' : flt(qty) * flt(conversion_factor)
|
||||
}
|
||||
return ret
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_warehouse_details(args):
|
||||
if isinstance(args, basestring):
|
||||
|
Loading…
x
Reference in New Issue
Block a user