[minor] make gl entry through bean and testcases

This commit is contained in:
Nabin Hait
2013-08-23 15:17:36 +05:30
parent a391606a8f
commit aeba24ee81
10 changed files with 69 additions and 27 deletions

View File

@@ -49,6 +49,13 @@ class TestDeliveryNote(unittest.TestCase):
dn.insert()
dn.submit()
stock_value, stock_value_difference = webnotes.conn.get_value("Stock Ledger Entry",
{"voucher_type": "Delivery Note", "voucher_no": dn.doc.name,
"item_code": "_Test Item"}, ["stock_value", "stock_value_difference"])
self.assertEqual(stock_value, 0)
self.assertEqual(stock_value_difference, -375)
gl_entries = webnotes.conn.sql("""select account, debit, credit
from `tabGL Entry` where voucher_type='Delivery Note' and voucher_no=%s
order by account desc""", dn.doc.name, as_dict=1)

View File

@@ -39,6 +39,17 @@ class TestPurchaseReceipt(unittest.TestCase):
pr.insert()
pr.submit()
stock_value, stock_value_difference = webnotes.conn.get_value("Stock Ledger Entry",
{"voucher_type": "Purchase Receipt", "voucher_no": pr.doc.name,
"item_code": "_Test Item", "warehouse": "_Test Warehouse - _TC"},
["stock_value", "stock_value_difference"])
self.assertEqual(stock_value, 375)
self.assertEqual(stock_value_difference, 375)
bin_stock_value = webnotes.conn.get_value("Bin", {"item_code": "_Test Item",
"warehouse": "_Test Warehouse - _TC"}, "stock_value")
self.assertEqual(bin_stock_value, 375)
gl_entries = webnotes.conn.sql("""select account, debit, credit
from `tabGL Entry` where voucher_type='Purchase Receipt' and voucher_no=%s
order by account desc""", pr.doc.name, as_dict=1)

View File

@@ -39,6 +39,9 @@ class DocType(DocListController):
from accounts.utils import validate_fiscal_year
validate_fiscal_year(self.doc.posting_date, self.doc.fiscal_year, self.meta.get_label("posting_date"))
def on_submit(self):
self.validate_serial_no()
#check for item quantity available in stock
def actual_amt_check(self):
if self.doc.batch_no:
@@ -79,10 +82,7 @@ class DocType(DocListController):
msgprint("Warehouse: '%s' does not exist in the system. Please check." % self.doc.fields.get(k), raise_exception = 1)
def validate_item(self):
item_det = webnotes.conn.sql("""select name, has_batch_no, docstatus,
is_stock_item, has_serial_no, serial_no_series
from tabItem where name=%s""",
self.doc.item_code, as_dict=True)[0]
item_det = self.get_item_details()
if item_det.is_stock_item != 'Yes':
webnotes.throw("""Item: "%s" is not a Stock Item.""" % self.doc.item_code)
@@ -96,10 +96,15 @@ class DocType(DocListController):
if not webnotes.conn.sql("""select name from `tabBatch`
where item='%s' and name ='%s' and docstatus != 2""" % (self.doc.item_code, self.doc.batch_no)):
webnotes.throw("'%s' is not a valid Batch Number for Item '%s'" % (self.doc.batch_no, self.doc.item_code))
def get_item_details(self):
return webnotes.conn.sql("""select name, has_batch_no, docstatus,
is_stock_item, has_serial_no, serial_no_series
from tabItem where name=%s""",
self.doc.item_code, as_dict=True)[0]
self.validate_serial_no(item_det)
def validate_serial_no(self, item_det):
def validate_serial_no(self):
item_det = self.get_item_details()
if item_det.has_serial_no=="No":
if self.doc.serial_no:
webnotes.throw(_("Serial Number should be blank for Non Serialized Item" + ": " + self.doc.item),

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-01-29 19:25:42",
"docstatus": 0,
"modified": "2013-08-20 15:02:48",
"modified": "2013-08-23 12:23:18",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -224,6 +224,14 @@
"options": "Company:company:default_currency",
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "stock_value_difference",
"fieldtype": "Currency",
"label": "Stock Value Difference",
"options": "Company:company:default_currency",
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "stock_queue",