Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Priya 2013-10-17 12:45:39 +05:30
commit 2dd558e500
8 changed files with 22 additions and 27 deletions

View File

@ -359,6 +359,7 @@ class DocType(BuyingController):
# item gl entries # item gl entries
stock_item_and_auto_accounting_for_stock = False stock_item_and_auto_accounting_for_stock = False
stock_items = self.get_stock_items() stock_items = self.get_stock_items()
rounding_diff = 0.0
for item in self.doclist.get({"parentfield": "entries"}): for item in self.doclist.get({"parentfield": "entries"}):
if auto_accounting_for_stock and item.item_code in stock_items: if auto_accounting_for_stock and item.item_code in stock_items:
if flt(item.valuation_rate): if flt(item.valuation_rate):
@ -367,9 +368,13 @@ class DocType(BuyingController):
# expense will be booked in sales invoice # expense will be booked in sales invoice
stock_item_and_auto_accounting_for_stock = True stock_item_and_auto_accounting_for_stock = True
valuation_amt = (flt(item.amount, self.precision("amount", item)) + valuation_amt = flt(flt(item.valuation_rate) * flt(item.qty) * \
flt(item.conversion_factor), self.precision("valuation_rate", item))
rounding_diff += (flt(item.amount, self.precision("amount", item)) +
flt(item.item_tax_amount, self.precision("item_tax_amount", item)) + flt(item.item_tax_amount, self.precision("item_tax_amount", item)) +
flt(item.rm_supp_cost, self.precision("rm_supp_cost", item))) flt(item.rm_supp_cost, self.precision("rm_supp_cost", item)) -
valuation_amt)
gl_entries.append( gl_entries.append(
self.get_gl_dict({ self.get_gl_dict({
@ -398,6 +403,12 @@ class DocType(BuyingController):
expenses_included_in_valuation = \ expenses_included_in_valuation = \
self.get_company_default("expenses_included_in_valuation") self.get_company_default("expenses_included_in_valuation")
if rounding_diff:
import operator
cost_center_with_max_value = max(valuation_tax.iteritems(),
key=operator.itemgetter(1))[0]
valuation_tax[cost_center_with_max_value] -= flt(rounding_diff)
for cost_center, amount in valuation_tax.items(): for cost_center, amount in valuation_tax.items():
gl_entries.append( gl_entries.append(
self.get_gl_dict({ self.get_gl_dict({

View File

@ -52,7 +52,6 @@ class DocType(SellingController):
sales_com_obj = get_obj('Sales Common') sales_com_obj = get_obj('Sales Common')
sales_com_obj.check_stop_sales_order(self) sales_com_obj.check_stop_sales_order(self)
sales_com_obj.check_active_sales_items(self) sales_com_obj.check_active_sales_items(self)
sales_com_obj.check_conversion_rate(self)
sales_com_obj.validate_max_discount(self, 'entries') sales_com_obj.validate_max_discount(self, 'entries')
self.validate_customer_account() self.validate_customer_account()
self.validate_debit_acc() self.validate_debit_acc()

View File

@ -332,9 +332,11 @@ def exec_in_shell(cmd):
stdout.seek(0) stdout.seek(0)
out = stdout.read() out = stdout.read()
if out: out = out.decode('utf-8')
stderr.seek(0) stderr.seek(0)
err = stderr.read() err = stderr.read()
if err: err = err.decode('utf-8')
if err and any((kw in err.lower() for kw in ["traceback", "error", "exception"])): if err and any((kw in err.lower() for kw in ["traceback", "error", "exception"])):
print out print out
@ -345,4 +347,4 @@ def exec_in_shell(cmd):
return out return out
if __name__ == "__main__": if __name__ == "__main__":
install() install()

View File

@ -26,7 +26,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
me.frm.set_value(fieldname, value); me.frm.set_value(fieldname, value);
}); });
} }
if(this.other_fname) { if(this.other_fname) {
this[this.other_fname + "_remove"] = this.calculate_taxes_and_totals; this[this.other_fname + "_remove"] = this.calculate_taxes_and_totals;
} }
@ -175,8 +175,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
this.frm.doc.plc_conversion_rate !== this.frm.doc.conversion_rate) { this.frm.doc.plc_conversion_rate !== this.frm.doc.conversion_rate) {
this.frm.set_value("plc_conversion_rate", this.frm.doc.conversion_rate); this.frm.set_value("plc_conversion_rate", this.frm.doc.conversion_rate);
} }
if(flt(this.frm.doc.conversion_rate)>0.0) this.calculate_taxes_and_totals();
this.calculate_taxes_and_totals();
}, },
get_price_list_currency: function(buying_or_selling) { get_price_list_currency: function(buying_or_selling) {
@ -226,7 +225,8 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
plc_conversion_rate: function() { plc_conversion_rate: function() {
if(this.frm.doc.price_list_currency === this.get_company_currency()) { if(this.frm.doc.price_list_currency === this.get_company_currency()) {
this.frm.set_value("plc_conversion_rate", 1.0); this.frm.set_value("plc_conversion_rate", 1.0);
} else if(this.frm.doc.price_list_currency === this.frm.doc.currency) { }
if(this.frm.doc.price_list_currency === this.frm.doc.currency) {
this.frm.set_value("conversion_rate", this.frm.doc.plc_conversion_rate); this.frm.set_value("conversion_rate", this.frm.doc.plc_conversion_rate);
this.calculate_taxes_and_totals(); this.calculate_taxes_and_totals();
} }

View File

@ -111,8 +111,6 @@ class DocType(SellingController):
sales_com_obj = get_obj('Sales Common') sales_com_obj = get_obj('Sales Common')
sales_com_obj.check_active_sales_items(self) sales_com_obj.check_active_sales_items(self)
sales_com_obj.validate_max_discount(self,'quotation_details') sales_com_obj.validate_max_discount(self,'quotation_details')
sales_com_obj.check_conversion_rate(self)
def on_update(self): def on_update(self):
# Set Quotation Status # Set Quotation Status

View File

@ -74,21 +74,6 @@ class DocType(TransactionBase):
msgprint("You cannot give more than " + cstr(discount[0]['max_discount']) + " % discount on Item Code : "+cstr(d.item_code)) msgprint("You cannot give more than " + cstr(discount[0]['max_discount']) + " % discount on Item Code : "+cstr(d.item_code))
raise Exception raise Exception
# Check Conversion Rate (i.e. it will not allow conversion rate to be 1 for Currency other than default currency set in Global Defaults)
# ===========================================================================
def check_conversion_rate(self, obj):
default_currency = get_company_currency(obj.doc.company)
if not default_currency:
msgprint('Message: Please enter default currency in Company Master')
raise Exception
if (obj.doc.currency == default_currency and flt(obj.doc.conversion_rate) != 1.00) or not obj.doc.conversion_rate or (obj.doc.currency != default_currency and flt(obj.doc.conversion_rate) == 1.00):
msgprint("Please Enter Appropriate Conversion Rate for Customer's Currency to Base Currency (%s --> %s)" % (obj.doc.currency, default_currency), raise_exception = 1)
if (obj.doc.price_list_currency == default_currency and flt(obj.doc.plc_conversion_rate) != 1.00) or not obj.doc.plc_conversion_rate or (obj.doc.price_list_currency != default_currency and flt(obj.doc.plc_conversion_rate) == 1.00):
msgprint("Please Enter Appropriate Conversion Rate for Price List Currency to Base Currency (%s --> %s)" % (obj.doc.price_list_currency, default_currency), raise_exception = 1)
# Get Tax rate if account type is TAX # Get Tax rate if account type is TAX
# ========================================================================= # =========================================================================
def get_rate(self, arg): def get_rate(self, arg):

View File

@ -130,7 +130,7 @@ class DocType(SellingController):
self.validate_warehouse() self.validate_warehouse()
sales_com_obj = get_obj(dt = 'Sales Common') sales_com_obj = get_obj(dt = 'Sales Common')
sales_com_obj.check_active_sales_items(self) sales_com_obj.check_active_sales_items(self)
sales_com_obj.check_conversion_rate(self)
sales_com_obj.validate_max_discount(self,'sales_order_details') sales_com_obj.validate_max_discount(self,'sales_order_details')
self.doclist = sales_com_obj.make_packing_list(self,'sales_order_details') self.doclist = sales_com_obj.make_packing_list(self,'sales_order_details')

View File

@ -95,7 +95,7 @@ class DocType(SellingController):
self.validate_uom_is_integer("stock_uom", "qty") self.validate_uom_is_integer("stock_uom", "qty")
sales_com_obj.validate_max_discount(self, 'delivery_note_details') sales_com_obj.validate_max_discount(self, 'delivery_note_details')
sales_com_obj.check_conversion_rate(self)
# Set actual qty for each item in selected warehouse # Set actual qty for each item in selected warehouse
self.update_current_stock() self.update_current_stock()