Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
commit
705fed3df9
@ -17,7 +17,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.utils import add_days, add_months, cint, cstr, month_name
|
from webnotes.utils import add_days, add_months, cint, cstr
|
||||||
from webnotes.model import db_exists
|
from webnotes.model import db_exists
|
||||||
from webnotes.model.wrapper import copy_doclist
|
from webnotes.model.wrapper import copy_doclist
|
||||||
|
|
||||||
|
0
controllers/__init__.py
Normal file
0
controllers/__init__.py
Normal file
@ -72,6 +72,7 @@ class TaxController(TransactionController):
|
|||||||
self.calculate_taxes()
|
self.calculate_taxes()
|
||||||
self.calculate_totals()
|
self.calculate_totals()
|
||||||
self.set_amount_in_words()
|
self.set_amount_in_words()
|
||||||
|
self.cleanup()
|
||||||
|
|
||||||
def calculate_item_values(self):
|
def calculate_item_values(self):
|
||||||
def _set_base(item, print_field, base_field):
|
def _set_base(item, print_field, base_field):
|
||||||
@ -104,12 +105,12 @@ class TaxController(TransactionController):
|
|||||||
|
|
||||||
item.fields[self.fmap.print_amount] = \
|
item.fields[self.fmap.print_amount] = \
|
||||||
flt(item.fields.get(self.fmap.print_rate) * \
|
flt(item.fields.get(self.fmap.print_rate) * \
|
||||||
item.fields.get(self.fmap.qty),
|
item.fields.get("qty"),
|
||||||
self.precision.item[self.fmap.print_amount])
|
self.precision.item[self.fmap.print_amount])
|
||||||
|
|
||||||
_set_base(item, self.fmap.print_ref_rate, self.fmap.ref_rate)
|
_set_base(item, self.fmap.print_ref_rate, self.fmap.ref_rate)
|
||||||
_set_base(item, self.fmap.print_rate, self.fmap.rate)
|
_set_base(item, self.fmap.print_rate, self.fmap.rate)
|
||||||
_set_base(item, self.fmap.print_amount, self.fmap.amount)
|
_set_base(item, self.fmap.print_amount, "amount")
|
||||||
|
|
||||||
def initialize_taxes(self):
|
def initialize_taxes(self):
|
||||||
for tax in self.tax_doclist:
|
for tax in self.tax_doclist:
|
||||||
@ -431,3 +432,14 @@ class TaxController(TransactionController):
|
|||||||
return flt(item_tax_map.get(tax.account_head), self.precision.tax.rate)
|
return flt(item_tax_map.get(tax.account_head), self.precision.tax.rate)
|
||||||
else:
|
else:
|
||||||
return tax.rate
|
return tax.rate
|
||||||
|
|
||||||
|
def cleanup(self):
|
||||||
|
for f in ["taxes_and_charges_total_print", "rounded_total_in_words_print",
|
||||||
|
"rounded_total_print", "rounded_total_in_words"]:
|
||||||
|
del self.doc.fields[self.fmap.get(f) or f]
|
||||||
|
|
||||||
|
for f in ["grand_total_print_for_current_item", "tax_amount_print",
|
||||||
|
"grand_total_for_current_item", "tax_amount_for_current_item",
|
||||||
|
"total_print"]:
|
||||||
|
for doc in self.doclist.get({"parentfield": self.fmap.taxes_and_charges}):
|
||||||
|
del doc.fields[self.fmap.get(f) or f]
|
||||||
|
@ -21,8 +21,6 @@ from webnotes import _, DictObj
|
|||||||
from webnotes.utils import cint
|
from webnotes.utils import cint
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import stock.utils
|
|
||||||
|
|
||||||
from webnotes.model.controller import DocListController
|
from webnotes.model.controller import DocListController
|
||||||
|
|
||||||
class TransactionController(DocListController):
|
class TransactionController(DocListController):
|
||||||
|
@ -15,10 +15,14 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
cur_frm.cscript.onload = function(doc, cdt, cdn){
|
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn){
|
||||||
cur_frm.call_server('get_transactions', '', cur_frm.cscript.update_selects);
|
cur_frm.call({
|
||||||
|
method: 'get_transactions',
|
||||||
cur_frm.cscript.select_doc_for_series(doc);
|
callback: function(r) {
|
||||||
|
cur_frm.cscript.update_selects(r);
|
||||||
|
cur_frm.cscript.select_doc_for_series(doc, cdt, cdn);
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.update_selects = function(r) {
|
cur_frm.cscript.update_selects = function(r) {
|
||||||
@ -47,7 +51,7 @@ cur_frm.cscript.update = function() {
|
|||||||
cur_frm.call_server('update_series', '', cur_frm.cscript.update_selects)
|
cur_frm.call_server('update_series', '', cur_frm.cscript.update_selects)
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.prefix = function(doc) {
|
cur_frm.cscript.prefix = function(doc, dt, dn) {
|
||||||
cur_frm.call_server('get_current', '', function(r) {
|
cur_frm.call_server('get_current', '', function(r) {
|
||||||
refresh_field('current_value');
|
refresh_field('current_value');
|
||||||
})
|
})
|
||||||
|
@ -97,24 +97,24 @@ base_purchase_receipt = [
|
|||||||
"doctype": "Purchase Receipt Item",
|
"doctype": "Purchase Receipt Item",
|
||||||
"item_code": "Home Desktop 100",
|
"item_code": "Home Desktop 100",
|
||||||
"qty": 10, "received_qty": 10, "rejected_qty": 0, "purchase_rate": 50,
|
"qty": 10, "received_qty": 10, "rejected_qty": 0, "purchase_rate": 50,
|
||||||
"amount": 500, "warehouse": "Default Warehouse", "valuation_tax_amount": 250,
|
"amount": 500, "warehouse": "Default Warehouse",
|
||||||
"parentfield": "purchase_receipt_details",
|
"parentfield": "purchase_receipt_details",
|
||||||
"conversion_factor": 1, "uom": "Nos", "stock_uom": "Nos"
|
"conversion_factor": 1, "uom": "Nos", "stock_uom": "Nos"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "Purchase Taxes and Charges", "charge_type": "Actual",
|
"doctype": "Purchase Taxes and Charges", "charge_type": "Actual",
|
||||||
"account_head": "Shipping Charges - %s" % abbr, "purchase_rate": 100, "tax_amount": 100,
|
"account_head": "Shipping Charges - %s" % abbr, "rate": 100, "tax_amount": 100,
|
||||||
"category": "Valuation and Total", "parentfield": "purchase_tax_details",
|
"category": "Valuation and Total", "parentfield": "purchase_tax_details",
|
||||||
"cost_center": "Default Cost Center - %s" % abbr
|
"cost_center": "Default Cost Center - %s" % abbr
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "Purchase Taxes and Charges", "charge_type": "Actual",
|
"doctype": "Purchase Taxes and Charges", "charge_type": "Actual",
|
||||||
"account_head": "VAT - Test - %s" % abbr, "purchase_rate": 120, "tax_amount": 120,
|
"account_head": "VAT - Test - %s" % abbr, "rate": 120, "tax_amount": 120,
|
||||||
"category": "Total", "parentfield": "purchase_tax_details"
|
"category": "Total", "parentfield": "purchase_tax_details"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "Purchase Taxes and Charges", "charge_type": "Actual",
|
"doctype": "Purchase Taxes and Charges", "charge_type": "Actual",
|
||||||
"account_head": "Customs Duty - %s" % abbr, "purchase_rate": 150, "tax_amount": 150,
|
"account_head": "Customs Duty - %s" % abbr, "rate": 150, "tax_amount": 150,
|
||||||
"category": "Valuation", "parentfield": "purchase_tax_details",
|
"category": "Valuation", "parentfield": "purchase_tax_details",
|
||||||
"cost_center": "Default Cost Center - %s" % abbr
|
"cost_center": "Default Cost Center - %s" % abbr
|
||||||
}
|
}
|
||||||
@ -158,7 +158,6 @@ class TestPurchaseReceipt(unittest.TestCase):
|
|||||||
load_data()
|
load_data()
|
||||||
webnotes.conn.set_value("Global Defaults", None, "automatic_inventory_accounting", 1)
|
webnotes.conn.set_value("Global Defaults", None, "automatic_inventory_accounting", 1)
|
||||||
|
|
||||||
|
|
||||||
def test_purchase_receipt(self):
|
def test_purchase_receipt(self):
|
||||||
# warehouse does not have stock in hand specified
|
# warehouse does not have stock in hand specified
|
||||||
self.run_purchase_receipt_test(base_purchase_receipt,
|
self.run_purchase_receipt_test(base_purchase_receipt,
|
||||||
@ -169,6 +168,14 @@ class TestPurchaseReceipt(unittest.TestCase):
|
|||||||
credit_account, stock_value):
|
credit_account, stock_value):
|
||||||
from webnotes.model.doclist import DocList
|
from webnotes.model.doclist import DocList
|
||||||
dl = webnotes.insert(DocList(purchase_receipt))
|
dl = webnotes.insert(DocList(purchase_receipt))
|
||||||
|
|
||||||
|
from controllers.tax_controller import TaxController
|
||||||
|
tax_controller = TaxController(dl.doc, dl.doclist)
|
||||||
|
tax_controller.item_table_field = "purchase_receipt_details"
|
||||||
|
tax_controller.calculate_taxes_and_totals()
|
||||||
|
dl.doc = tax_controller.doc
|
||||||
|
dl.doclist = tax_controller.doclist
|
||||||
|
|
||||||
dl.submit()
|
dl.submit()
|
||||||
dl.load_from_db()
|
dl.load_from_db()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user