mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-04 22:18:27 +00:00
moved directory structure
This commit is contained in:
1
sandbox/__init__.py
Normal file
1
sandbox/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
72
sandbox/test_leave.py
Normal file
72
sandbox/test_leave.py
Normal file
@@ -0,0 +1,72 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import unittest
|
||||
|
||||
import webnotes
|
||||
import webnotes.profile
|
||||
webnotes.user = webnotes.profile.Profile()
|
||||
|
||||
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes.utils import cstr, flt
|
||||
from webnotes.model.doclist import getlist
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
from sandbox.testdata import leaves
|
||||
#----------------------------------------------------------
|
||||
|
||||
|
||||
class TestStockEntry(unittest.TestCase):
|
||||
#===========================================================================
|
||||
def setUp(self):
|
||||
webnotes.conn.begin()
|
||||
leaves.emp.save(new = 1, make_autoname = 0)
|
||||
|
||||
def test_leave_bal(self):
|
||||
leaves.l_all.save(1)
|
||||
leaves.l_app1.save(1)
|
||||
leaves.l_app2.save(1)
|
||||
|
||||
la1 = get_obj('Leave Application', leaves.l_app1.name, with_children=1)
|
||||
la1.validate()
|
||||
la1.doc.docstatus = 1
|
||||
la1.doc.save()
|
||||
|
||||
self.assertTrue(la1.doc.total_leave_days == 2)
|
||||
|
||||
la1.doc.half_day = 1
|
||||
la1.validate()
|
||||
la1.doc.save()
|
||||
|
||||
self.assertTrue(la1.doc.total_leave_days == .5)
|
||||
|
||||
print "Test case for leave applied no of days"
|
||||
|
||||
|
||||
la2 = get_obj('Leave Application', leaves.l_app2.name, with_children=1)
|
||||
la2.validate()
|
||||
bal = la2.get_leave_balance()
|
||||
self.assertTrue(bal, 18)
|
||||
print "Test case for leave balance"
|
||||
|
||||
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
webnotes.conn.rollback()
|
||||
493
sandbox/test_stock_entry.py
Normal file
493
sandbox/test_stock_entry.py
Normal file
@@ -0,0 +1,493 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import unittest
|
||||
|
||||
import webnotes
|
||||
import webnotes.profile
|
||||
webnotes.user = webnotes.profile.Profile()
|
||||
|
||||
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes.utils import cstr, flt
|
||||
from webnotes.model.doclist import getlist
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
from sandbox.testdata.masters import *
|
||||
from sandbox.testdata import stock_entry
|
||||
#----------------------------------------------------------
|
||||
|
||||
|
||||
class TestStockEntry(unittest.TestCase):
|
||||
#===========================================================================
|
||||
def assertDoc(self, lst):
|
||||
"""assert all values"""
|
||||
for d in lst:
|
||||
cl, vl = [], []
|
||||
for k in d.keys():
|
||||
if k!='doctype':
|
||||
cl.append('%s=%s' % (k, '%s'))
|
||||
vl.append(d[k])
|
||||
|
||||
self.assertTrue(sql("select name from `tab%s` where %s limit 1" % (d['doctype'], ' and '.join(cl)), vl))
|
||||
|
||||
#===========================================================================
|
||||
def assertCount(self, lst):
|
||||
"""assert all values"""
|
||||
for d in lst:
|
||||
cl, vl = [], []
|
||||
for k in d[0].keys():
|
||||
if k!='doctype':
|
||||
cl.append('%s=%s' % (k, '%s'))
|
||||
vl.append(d[0][k])
|
||||
|
||||
self.assertTrue(sql("select count(name) from `tab%s` where %s limit 1" % (d[0]['doctype'], ' and '.join(cl)), vl)[0][0] == d[1])
|
||||
|
||||
#===========================================================================
|
||||
def setUp(self):
|
||||
print "====================================="
|
||||
webnotes.conn.begin()
|
||||
create_master_records()
|
||||
print 'Master Data Created'
|
||||
|
||||
#===========================================================================
|
||||
# Purpose: Material Receipt
|
||||
#===========================================================================
|
||||
def test_mr_onsubmit(self):
|
||||
print "Test Case: Material Receipt submission"
|
||||
self.save_stock_entry('Material Receipt')
|
||||
|
||||
mr = get_obj('Stock Entry', stock_entry.mr[0].name, with_children=1)
|
||||
self.submit_stock_entry(mr)
|
||||
|
||||
# stock ledger entry
|
||||
print "Checking stock ledger entry........."
|
||||
self.assertDoc(self.get_expected_sle('mr_submit'))
|
||||
|
||||
# bin qty
|
||||
print "Checking Bin qty........."
|
||||
self.assertDoc([{'doctype':'Bin', 'actual_qty':10, 'item_code':'it', 'warehouse':'wh1'}])
|
||||
|
||||
# serial no
|
||||
self.assertCount([[{'doctype': 'Serial No', 'item_code': 'it', 'warehouse': 'wh1', 'status': 'In Store', 'docstatus': 0}, 10]])
|
||||
|
||||
|
||||
#===========================================================================
|
||||
def test_mr_oncancel(self):
|
||||
print "Test Case: Material Receipt Cancellation"
|
||||
self.save_stock_entry('Material Receipt')
|
||||
|
||||
mr = get_obj('Stock Entry', stock_entry.mr[0].name, with_children=1)
|
||||
self.cancel_stock_entry(mr)
|
||||
|
||||
# stock ledger entry
|
||||
print "Checking stock ledger entry........."
|
||||
self.assertDoc(self.get_expected_sle('mr_cancel'))
|
||||
|
||||
# bin qty
|
||||
print "Checking Bin qty........."
|
||||
self.assertDoc([{'doctype':'Bin', 'actual_qty':0, 'item_code':'it', 'warehouse':'wh1'}])
|
||||
|
||||
# serial no
|
||||
self.assertCount([[{'doctype': 'Serial No', 'item_code': 'it', 'warehouse': '', 'status': 'Not in Use', 'docstatus': 2}, 10]])
|
||||
|
||||
#===========================================================================
|
||||
# Purpose: Material Transafer
|
||||
#===========================================================================
|
||||
def test_mtn_onsubmit(self):
|
||||
print "Test Case: Material Transfer Note submission"
|
||||
|
||||
self.save_stock_entry('Material Receipt')
|
||||
mr = get_obj('Stock Entry', stock_entry.mr[0].name, with_children=1)
|
||||
mr = self.submit_stock_entry(mr)
|
||||
|
||||
self.save_stock_entry('Material Transfer')
|
||||
mtn = get_obj('Stock Entry', stock_entry.mtn[0].name, with_children=1)
|
||||
mtn = self.submit_stock_entry(mtn)
|
||||
|
||||
# stock ledger entry
|
||||
print "Checking stock ledger entry........."
|
||||
self.assertDoc(self.get_expected_sle('mtn_submit'))
|
||||
|
||||
# bin qty
|
||||
print "Checking Bin qty........."
|
||||
self.assertDoc([
|
||||
{'doctype':'Bin', 'actual_qty':5, 'item_code':'it', 'warehouse':'wh1'},
|
||||
{'doctype':'Bin', 'actual_qty':5, 'item_code':'it', 'warehouse':'wh2'}
|
||||
])
|
||||
|
||||
# serial no
|
||||
self.assertCount([
|
||||
[{'doctype': 'Serial No', 'item_code': 'it', 'warehouse': 'wh1', 'status': 'In Store', 'docstatus': 0}, 5],
|
||||
[{'doctype': 'Serial No', 'item_code': 'it', 'warehouse': 'wh2', 'status': 'In Store', 'docstatus': 0}, 5]
|
||||
])
|
||||
|
||||
#===========================================================================
|
||||
def test_mtn_oncancel(self):
|
||||
print "Test Case: Material Transfer Note Cancellation"
|
||||
|
||||
self.save_stock_entry('Material Receipt')
|
||||
mr = get_obj('Stock Entry', stock_entry.mr[0].name, with_children=1)
|
||||
mr = self.submit_stock_entry(mr)
|
||||
|
||||
self.save_stock_entry('Material Transfer')
|
||||
mtn = get_obj('Stock Entry', stock_entry.mtn[0].name, with_children=1)
|
||||
self.cancel_stock_entry(mtn)
|
||||
|
||||
# stock ledger entry
|
||||
print "Checking stock ledger entry........."
|
||||
self.assertDoc(self.get_expected_sle('mtn_cancel'))
|
||||
|
||||
# bin qty
|
||||
print "Checking Bin qty........."
|
||||
self.assertDoc([
|
||||
{'doctype':'Bin', 'actual_qty':10, 'item_code':'it', 'warehouse':'wh1'},
|
||||
{'doctype':'Bin', 'actual_qty':0, 'item_code':'it', 'warehouse':'wh2'}
|
||||
])
|
||||
|
||||
# serial no
|
||||
self.assertCount([[{'doctype': 'Serial No', 'item_code': 'it', 'warehouse': 'wh1', 'status': 'In Store', 'docstatus': 0}, 10]])
|
||||
|
||||
#===========================================================================
|
||||
# Purpose: Material Issue
|
||||
#===========================================================================
|
||||
def test_mi_onsubmit(self):
|
||||
print "Test Case: Material Issue submission"
|
||||
|
||||
self.save_stock_entry('Material Receipt')
|
||||
mr = get_obj('Stock Entry', stock_entry.mr[0].name, with_children=1)
|
||||
mr = self.submit_stock_entry(mr)
|
||||
|
||||
self.save_stock_entry('Material Issue')
|
||||
mi = get_obj('Stock Entry', stock_entry.mi[0].name, with_children=1)
|
||||
mi = self.submit_stock_entry(mi)
|
||||
|
||||
# stock ledger entry
|
||||
print "Checking stock ledger entry........."
|
||||
self.assertDoc(self.get_expected_sle('mi_submit'))
|
||||
|
||||
# bin qty
|
||||
print "Checking Bin qty........."
|
||||
self.assertDoc([
|
||||
{'doctype':'Bin', 'actual_qty':6, 'item_code':'it', 'warehouse':'wh1'}
|
||||
])
|
||||
|
||||
# serial no
|
||||
self.assertCount([
|
||||
[{'doctype': 'Serial No', 'item_code': 'it', 'warehouse': 'wh1', 'status': 'In Store', 'docstatus': 0}, 6]
|
||||
])
|
||||
|
||||
#===========================================================================
|
||||
def test_mi_oncancel(self):
|
||||
print "Test Case: Material Issue Cancellation"
|
||||
|
||||
self.save_stock_entry('Material Receipt')
|
||||
mr = get_obj('Stock Entry', stock_entry.mr[0].name, with_children=1)
|
||||
mr = self.submit_stock_entry(mr)
|
||||
|
||||
self.save_stock_entry('Material Issue')
|
||||
mi = get_obj('Stock Entry', stock_entry.mi[0].name, with_children=1)
|
||||
self.cancel_stock_entry(mi)
|
||||
|
||||
# stock ledger entry
|
||||
print "Checking stock ledger entry........."
|
||||
self.assertDoc(self.get_expected_sle('mi_cancel'))
|
||||
|
||||
# bin qty
|
||||
print "Checking Bin qty........."
|
||||
self.assertDoc([
|
||||
{'doctype':'Bin', 'actual_qty':10, 'item_code':'it', 'warehouse':'wh1'}
|
||||
])
|
||||
|
||||
# serial no
|
||||
self.assertCount([
|
||||
[{'doctype': 'Serial No', 'item_code': 'it', 'warehouse': 'wh1', 'status': 'In Store', 'docstatus': 0}, 10]
|
||||
])
|
||||
|
||||
#===========================================================================
|
||||
def test_entries_on_same_datetime(self):
|
||||
print "Test Case: Multiple entries on same datetime, cancel first one"
|
||||
|
||||
# submitted 1st MR
|
||||
self.save_stock_entry('Material Receipt')
|
||||
mr = get_obj('Stock Entry', stock_entry.mr[0].name, with_children=1)
|
||||
mr = self.submit_stock_entry(mr)
|
||||
|
||||
# submitted 2nd MR
|
||||
for each in stock_entry.mr1:
|
||||
each.save(1)
|
||||
for t in stock_entry.mr1[1:]:
|
||||
sql("update `tabStock Entry Detail` set parent = '%s' where name = '%s'" % (stock_entry.mr1[0].name, t.name))
|
||||
|
||||
mr1 = get_obj('Stock Entry', stock_entry.mr1[0].name, with_children=1)
|
||||
mr1 = self.submit_stock_entry(mr1)
|
||||
|
||||
|
||||
# submitted MTN
|
||||
self.save_stock_entry('Material Transfer')
|
||||
mtn = get_obj('Stock Entry', stock_entry.mtn[0].name, with_children=1)
|
||||
mtn = self.submit_stock_entry(mtn)
|
||||
|
||||
# cancel prev MR
|
||||
mr.on_cancel()
|
||||
mr.doc.cancel_reason = "testing"
|
||||
mr.doc.docstatus = 2
|
||||
mr.doc.save()
|
||||
|
||||
|
||||
# stock ledger entry
|
||||
print "Checking stock ledger entry........."
|
||||
self.assertDoc(self.get_expected_sle('entries_on_same_datetime'))
|
||||
|
||||
# bin qty
|
||||
print "Checking Bin qty........."
|
||||
self.assertDoc([
|
||||
{'doctype':'Bin', 'actual_qty':0, 'item_code':'it', 'warehouse':'wh1'},
|
||||
{'doctype':'Bin', 'actual_qty':5, 'item_code':'it', 'warehouse':'wh2'}
|
||||
])
|
||||
|
||||
# serial no
|
||||
self.assertCount([
|
||||
[{'doctype': 'Serial No', 'item_code': 'it', 'warehouse': 'wh1', 'status': 'In Store', 'docstatus': 0}, 0],
|
||||
[{'doctype': 'Serial No', 'item_code': 'it', 'warehouse': 'wh2', 'status': 'In Store', 'docstatus': 0}, 5]
|
||||
])
|
||||
|
||||
#===========================================================================
|
||||
def save_stock_entry(self, t):
|
||||
if t == 'Material Receipt':
|
||||
data = stock_entry.mr
|
||||
elif t == 'Material Transfer':
|
||||
data = stock_entry.mtn
|
||||
elif t == 'Material Issue':
|
||||
data = stock_entry.mi
|
||||
|
||||
for each in data:
|
||||
each.save(1)
|
||||
|
||||
for t in data[1:]:
|
||||
sql("update `tabStock Entry Detail` set parent = '%s' where name = '%s'" % (data[0].name, t.name))
|
||||
print "Stock Entry Created"
|
||||
|
||||
|
||||
#===========================================================================
|
||||
def submit_stock_entry(self, ste):
|
||||
ste.validate()
|
||||
ste.on_submit()
|
||||
|
||||
ste.doc.docstatus = 1
|
||||
ste.doc.save()
|
||||
|
||||
print "Stock Entry Submitted"
|
||||
return ste
|
||||
|
||||
#===========================================================================
|
||||
def cancel_stock_entry(self, ste):
|
||||
ste = self.submit_stock_entry(ste)
|
||||
|
||||
ste.on_cancel()
|
||||
|
||||
ste.doc.cancel_reason = "testing"
|
||||
ste.doc.docstatus = 2
|
||||
ste.doc.save()
|
||||
|
||||
print "Stock Entry Cancelled"
|
||||
return ste
|
||||
|
||||
#===========================================================================
|
||||
def tearDown(self):
|
||||
webnotes.conn.rollback()
|
||||
|
||||
|
||||
# Expected Result Set
|
||||
#===================================================================================================
|
||||
def get_expected_sle(self, action):
|
||||
expected_sle = {
|
||||
'mr_submit': [{
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh1',
|
||||
'voucher_type': 'Stock Entry',
|
||||
'voucher_no': stock_entry.mr[0].name,
|
||||
'actual_qty': 10,
|
||||
'bin_aqat': 10,
|
||||
'valuation_rate': 100,
|
||||
'is_cancelled': 'No'
|
||||
}],
|
||||
'mr_cancel': [{
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh1',
|
||||
'voucher_type': 'Stock Entry',
|
||||
'voucher_no': stock_entry.mr[0].name,
|
||||
'actual_qty': 10,
|
||||
'bin_aqat': 10,
|
||||
'valuation_rate': 100,
|
||||
'is_cancelled': 'Yes'
|
||||
},{
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh1',
|
||||
'voucher_type': 'Stock Entry',
|
||||
'voucher_no': stock_entry.mr[0].name,
|
||||
'actual_qty': -10,
|
||||
'ifnull(bin_aqat, 0)': 0,
|
||||
'ifnull(valuation_rate, 0)': 0,
|
||||
"ifnull(is_cancelled, 'No')": 'Yes'
|
||||
}],
|
||||
'mtn_submit': [{
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh1',
|
||||
'voucher_type': 'Stock Entry',
|
||||
'voucher_no': stock_entry.mtn[0].name,
|
||||
'actual_qty': -5,
|
||||
'bin_aqat': 5,
|
||||
'valuation_rate': 100,
|
||||
'is_cancelled': 'No'
|
||||
}, {
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh2',
|
||||
'voucher_type': 'Stock Entry',
|
||||
'voucher_no': stock_entry.mtn[0].name,
|
||||
'actual_qty': 5,
|
||||
'bin_aqat': 5,
|
||||
'valuation_rate': 100,
|
||||
'is_cancelled': 'No'
|
||||
}],
|
||||
'mtn_cancel': [{
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh1',
|
||||
'voucher_type': 'Stock Entry',
|
||||
'voucher_no': stock_entry.mtn[0].name,
|
||||
'actual_qty': -5,
|
||||
'bin_aqat': 5,
|
||||
'is_cancelled': 'Yes'
|
||||
}, {
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh2',
|
||||
'voucher_type': 'Stock Entry',
|
||||
'voucher_no': stock_entry.mtn[0].name,
|
||||
'actual_qty': 5,
|
||||
'bin_aqat': 5,
|
||||
'valuation_rate': 100,
|
||||
'is_cancelled': 'Yes'
|
||||
}, {
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh1',
|
||||
'voucher_type': 'Stock Entry',
|
||||
'voucher_no': stock_entry.mtn[0].name,
|
||||
'actual_qty': 5,
|
||||
'is_cancelled': 'Yes'
|
||||
}, {
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh2',
|
||||
'voucher_type': 'Stock Entry',
|
||||
'voucher_no': stock_entry.mtn[0].name,
|
||||
'actual_qty': -5,
|
||||
'is_cancelled': 'Yes'
|
||||
}],
|
||||
'mi_submit': [{'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh1',
|
||||
'voucher_type': 'Stock Entry',
|
||||
'voucher_no': stock_entry.mi[0].name,
|
||||
'actual_qty': -4,
|
||||
'bin_aqat': 6,
|
||||
'valuation_rate': 100,
|
||||
'is_cancelled': 'No'
|
||||
}],
|
||||
'mi_cancel': [{
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh1',
|
||||
'voucher_type': 'Stock Entry',
|
||||
'voucher_no': stock_entry.mi[0].name,
|
||||
'actual_qty': -4,
|
||||
'bin_aqat': 6,
|
||||
'valuation_rate': 100,
|
||||
'is_cancelled': 'Yes'
|
||||
},{
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh1',
|
||||
'voucher_type': 'Stock Entry',
|
||||
'voucher_no': stock_entry.mi[0].name,
|
||||
'actual_qty': 4,
|
||||
'ifnull(bin_aqat, 0)': 0,
|
||||
'ifnull(valuation_rate, 0)': 0,
|
||||
"ifnull(is_cancelled, 'No')": 'Yes'
|
||||
}],
|
||||
'entries_on_same_datetime': [{
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh1',
|
||||
'voucher_type': 'Stock Entry',
|
||||
'voucher_no': stock_entry.mr[0].name,
|
||||
'actual_qty': 10,
|
||||
'bin_aqat': 10,
|
||||
'valuation_rate': 100,
|
||||
'is_cancelled': 'Yes'
|
||||
}, {
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh1',
|
||||
'voucher_type': 'Stock Entry',
|
||||
'voucher_no': stock_entry.mr[0].name,
|
||||
'actual_qty': -10,
|
||||
'ifnull(bin_aqat, 0)': 0,
|
||||
'ifnull(valuation_rate, 0)': 0,
|
||||
"ifnull(is_cancelled, 'No')": 'Yes'
|
||||
}, {
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh1',
|
||||
'voucher_type': 'Stock Entry',
|
||||
'voucher_no': stock_entry.mr1[0].name,
|
||||
'actual_qty': 5,
|
||||
'bin_aqat': 5,
|
||||
'valuation_rate': 400,
|
||||
'is_cancelled': 'No'
|
||||
}, {
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh1',
|
||||
'voucher_type': 'Stock Entry',
|
||||
'voucher_no': stock_entry.mtn[0].name,
|
||||
'actual_qty': -5,
|
||||
'bin_aqat': 0,
|
||||
'valuation_rate': 400,
|
||||
'is_cancelled': 'No'
|
||||
}, {
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh2',
|
||||
'voucher_type': 'Stock Entry',
|
||||
'voucher_no': stock_entry.mtn[0].name,
|
||||
'actual_qty': 5,
|
||||
'bin_aqat': 5,
|
||||
'valuation_rate': 100,
|
||||
'is_cancelled': 'No'
|
||||
}]
|
||||
}
|
||||
|
||||
return expected_sle[action]
|
||||
111
sandbox/test_stock_reco.py
Normal file
111
sandbox/test_stock_reco.py
Normal file
@@ -0,0 +1,111 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import unittest
|
||||
|
||||
import webnotes
|
||||
import webnotes.profile
|
||||
webnotes.user = webnotes.profile.Profile()
|
||||
|
||||
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes.utils import cstr, flt
|
||||
from webnotes.model.doclist import getlist
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
from sandbox.testdata.masters import *
|
||||
from sandbox.testdata.sle_data import sle, bin
|
||||
from sandbox.testdata.stock_reco import *
|
||||
#----------------------------------------------------------
|
||||
|
||||
|
||||
class TestStockEntry(unittest.TestCase):
|
||||
def assertDoc(self, lst):
|
||||
"""assert all values"""
|
||||
for d in lst:
|
||||
cl, vl = [], []
|
||||
for k in d.keys():
|
||||
if k!='doctype':
|
||||
cl.append('%s=%s' % (k, '%s'))
|
||||
vl.append(d[k])
|
||||
|
||||
self.assertTrue(sql("select name from `tab%s` where %s limit 1" % (d['doctype'], ' and '.join(cl)), vl))
|
||||
|
||||
#===========================================================================
|
||||
def setUp(self):
|
||||
print "====================================="
|
||||
webnotes.conn.begin()
|
||||
create_master_records()
|
||||
print 'Master Data Created'
|
||||
|
||||
for d in sle:
|
||||
d.save(1)
|
||||
print "Existing SLE created"
|
||||
|
||||
bin.save(1)
|
||||
|
||||
sreco.save(1)
|
||||
print "Stock Reco saved"
|
||||
|
||||
#===========================================================================
|
||||
def test_diff_in_both(self):
|
||||
reco = get_obj('Stock Reconciliation', sreco.name)
|
||||
reco.doc.docstatus = 1
|
||||
reco.doc.save()
|
||||
reco.validate()
|
||||
reco.on_submit()
|
||||
print "Stock Reco submitted"
|
||||
|
||||
print "Checking stock ledger entry........."
|
||||
self.assertDoc(self.get_expected_sle('diff_in_both'))
|
||||
|
||||
#===========================================================================
|
||||
def tearDown(self):
|
||||
webnotes.conn.rollback()
|
||||
|
||||
# Expected Result Set
|
||||
#===================================================================================================
|
||||
def get_expected_sle(self, action):
|
||||
expected_sle = {
|
||||
'diff_in_both': [{
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'item_code':'it',
|
||||
'warehouse':'wh1',
|
||||
'voucher_type': 'Stock Reconciliation',
|
||||
'voucher_no': sreco.name,
|
||||
'actual_qty': 15,
|
||||
'bin_aqat': 20,
|
||||
'valuation_rate': 150,
|
||||
#'stock_value': 3000,
|
||||
'is_cancelled': 'No'
|
||||
},{
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'posting_date': '2011-09-10',
|
||||
'posting_time': '15:00',
|
||||
'item_code': 'it',
|
||||
'warehouse': 'wh1',
|
||||
'actual_qty': 20,
|
||||
'incoming_rate': 200,
|
||||
'bin_aqat': 40,
|
||||
'valuation_rate': 175,
|
||||
#'stock_value': 4500,
|
||||
'is_cancelled': 'No'
|
||||
}
|
||||
]
|
||||
}
|
||||
return expected_sle[action]
|
||||
1
sandbox/testdata/__init__.py
vendored
Normal file
1
sandbox/testdata/__init__.py
vendored
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
71
sandbox/testdata/leaves.py
vendored
Normal file
71
sandbox/testdata/leaves.py
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from webnotes.model.doc import Document
|
||||
|
||||
emp = Document(
|
||||
fielddata = {
|
||||
'doctype': 'Employee',
|
||||
'name': 'emp1',
|
||||
'employee_name': 'Nijil',
|
||||
'status': 'Active',
|
||||
'date_of_joining': '2011-01-01'
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
||||
l_all = Document(
|
||||
fielddata = {
|
||||
'doctype' : 'Leave Allocation',
|
||||
'name': 'l_all',
|
||||
'employee' : 'emp1',
|
||||
'leave_type' : 'Casual Leave',
|
||||
'posting_date': '2011-03-01',
|
||||
'fiscal_year': '2011-2012',
|
||||
'total_leaves_allocated': 20,
|
||||
'docstatus': 1
|
||||
}
|
||||
)
|
||||
|
||||
l_app1 = Document(
|
||||
fielddata = {
|
||||
'doctype' : 'Leave Application',
|
||||
'name': 'l_app1',
|
||||
'employee' : 'emp1',
|
||||
'leave_type' : 'Casual Leave',
|
||||
'posting_date': '2011-03-01',
|
||||
'fiscal_year': '2011-2012',
|
||||
'from_date': '2011-08-01',
|
||||
'to_date': '2011-08-02',
|
||||
'total_leave_days': 2
|
||||
}
|
||||
)
|
||||
|
||||
l_app2 = Document(
|
||||
fielddata = {
|
||||
'doctype' : 'Leave Application',
|
||||
'name': 'l_app2',
|
||||
'employee' : 'emp1',
|
||||
'leave_type' : 'Casual Leave',
|
||||
'posting_date': '2011-03-01',
|
||||
'fiscal_year': '2011-2012',
|
||||
'from_date': '2011-08-15',
|
||||
'to_date': '2011-08-17',
|
||||
'total_leave_days': 3
|
||||
}
|
||||
)
|
||||
299
sandbox/testdata/masters.py
vendored
Normal file
299
sandbox/testdata/masters.py
vendored
Normal file
@@ -0,0 +1,299 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
"""
|
||||
All master data in one place, can be created by 1 function call
|
||||
|
||||
"""
|
||||
|
||||
import webnotes
|
||||
from webnotes.model.doc import Document
|
||||
|
||||
|
||||
master_groups = {
|
||||
# Company
|
||||
#----------------------------------
|
||||
'company': Document(
|
||||
fielddata={
|
||||
'doctype':'Company',
|
||||
'abbr': 'co',
|
||||
'company_name' : 'comp',
|
||||
'name': 'comp'
|
||||
}
|
||||
),
|
||||
|
||||
# Customer Group
|
||||
#----------------------------------
|
||||
'customer_group': Document(
|
||||
fielddata={
|
||||
'doctype':'Customer Group',
|
||||
'customer_group_name' : 'cg',
|
||||
'name': 'cg',
|
||||
'is_group': 'No',
|
||||
'parent_customer_group':'',
|
||||
'lft' : 1,
|
||||
'rgt': 2
|
||||
}
|
||||
),
|
||||
|
||||
# Item Group
|
||||
#----------------------------------
|
||||
'item_group': Document(
|
||||
fielddata = {
|
||||
'doctype': 'Item Group',
|
||||
'item_group_name': 'ig',
|
||||
'lft': 1,
|
||||
'rgt': 2,
|
||||
'parent_item_group' : '',
|
||||
'is_group': 'No',
|
||||
'name': 'ig'
|
||||
}
|
||||
),
|
||||
|
||||
# Warehouse Type
|
||||
#-----------------------------
|
||||
'warehouse_type' : Document(
|
||||
fielddata = {
|
||||
'doctype' : 'Warehouse Type',
|
||||
'name': 'normal',
|
||||
'warehouse_type' : 'normal'
|
||||
}
|
||||
),
|
||||
|
||||
# Supplier Type
|
||||
#-----------------------------
|
||||
'supplier_type' : Document(
|
||||
fielddata = {
|
||||
'doctype': 'Supplier Type',
|
||||
'supplier_type': 'stype'
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
|
||||
main_masters = {
|
||||
# Customer
|
||||
#----------------------------------
|
||||
'customer': Document(
|
||||
fielddata={
|
||||
'doctype':'Customer',
|
||||
'docstatus':0,
|
||||
'customer_name' : 'cust',
|
||||
'company' : 'comp',
|
||||
'customer_group' : '',
|
||||
'name': 'cust'
|
||||
}
|
||||
),
|
||||
|
||||
|
||||
# Supplier
|
||||
#----------------------------------
|
||||
'supplier': Document(
|
||||
fielddata = {
|
||||
'doctype': 'Supplier',
|
||||
'supplier_name': 'supp',
|
||||
'name': 'supp',
|
||||
'supplier_type' : 'stype'
|
||||
}
|
||||
),
|
||||
|
||||
# Customer Account
|
||||
#----------------------------------
|
||||
'customer_acc': Document(
|
||||
fielddata={
|
||||
'doctype':'Account',
|
||||
'docstatus':0,
|
||||
'account_name' : 'cust',
|
||||
'debit_or_credit': 'Debit',
|
||||
'company' : 'comp',
|
||||
'lft': 1,
|
||||
'rgt': 2,
|
||||
'group_or_ledger' : 'Ledger',
|
||||
'is_pl_account': 'No',
|
||||
'name' : 'cust - co'
|
||||
}
|
||||
),
|
||||
|
||||
# Customer Account
|
||||
#----------------------------------
|
||||
'supplier_acc': Document(
|
||||
fielddata={
|
||||
'doctype':'Account',
|
||||
'docstatus':0,
|
||||
'account_name' : 'supp',
|
||||
'debit_or_credit': 'Credit',
|
||||
'company' : 'comp',
|
||||
'lft': 5,
|
||||
'rgt': 6,
|
||||
'group_or_ledger' : 'Ledger',
|
||||
'is_pl_account': 'No',
|
||||
'name' : 'supp - co'
|
||||
}
|
||||
),
|
||||
|
||||
# Bank Account
|
||||
#----------------------------------
|
||||
'bank_acc': Document(
|
||||
fielddata={
|
||||
'doctype':'Account',
|
||||
'docstatus':0,
|
||||
'account_name' : 'icici',
|
||||
'parent_account': '',
|
||||
'debit_or_credit': 'Debit',
|
||||
'company' : 'comp',
|
||||
'lft': 3,
|
||||
'rgt': 4,
|
||||
'group_or_ledger' : 'Ledger',
|
||||
'is_pl_account': 'No',
|
||||
'name' : 'icici - co'
|
||||
}
|
||||
),
|
||||
|
||||
# Income Account
|
||||
#----------------------------------
|
||||
'income_acc': Document(
|
||||
fielddata={
|
||||
'doctype':'Account',
|
||||
'docstatus':0,
|
||||
'account_name' : 'income',
|
||||
'debit_or_credit': 'Credit',
|
||||
'company' : 'comp',
|
||||
'lft': 7,
|
||||
'rgt': 8,
|
||||
'group_or_ledger' : 'Ledger',
|
||||
'is_pl_account': 'Yes',
|
||||
'name' : 'income - co'
|
||||
}
|
||||
),
|
||||
|
||||
# Expense Account
|
||||
#----------------------------------
|
||||
'expense_acc': Document(
|
||||
fielddata={
|
||||
'doctype':'Account',
|
||||
'docstatus':0,
|
||||
'account_name' : 'expense',
|
||||
'debit_or_credit': 'Debit',
|
||||
'company' : 'comp',
|
||||
'lft': 9,
|
||||
'rgt': 10,
|
||||
'group_or_ledger' : 'Ledger',
|
||||
'is_pl_account': 'Yes',
|
||||
'name' : 'expense - co'
|
||||
}
|
||||
),
|
||||
|
||||
# Cost Center
|
||||
#----------------------------------
|
||||
'cost_center': Document(
|
||||
fielddata={
|
||||
'doctype':'Cost Center',
|
||||
'docstatus':0,
|
||||
'cost_center_name' : 'cc',
|
||||
'lft': 1,
|
||||
'rgt': 2,
|
||||
'group_or_ledger' : 'Ledger',
|
||||
'name' : 'cc'
|
||||
}
|
||||
),
|
||||
|
||||
# Item
|
||||
#----------------------------------
|
||||
# Stock item / non-serialized
|
||||
|
||||
'item': [
|
||||
Document(
|
||||
fielddata = {
|
||||
'doctype': 'Item',
|
||||
'docstatus': 0,
|
||||
'name': 'it',
|
||||
'item_name': 'it',
|
||||
'item_code': 'it',
|
||||
'item_group': 'ig',
|
||||
'is_stock_item': 'Yes',
|
||||
'has_serial_no': 'Yes',
|
||||
'stock_uom': 'Nos',
|
||||
'is_sales_item': 'Yes',
|
||||
'is_purchase_item': 'Yes',
|
||||
'is_service_item': 'No',
|
||||
'is_sub_contracted_item': 'No',
|
||||
'is_pro_applicable': 'Yes',
|
||||
'is_manufactured_item': 'Yes'
|
||||
}
|
||||
),
|
||||
Document(
|
||||
fielddata = {
|
||||
'doctype': 'Item Price',
|
||||
'parentfield': 'ref_rate_details',
|
||||
'parenttype': 'Item',
|
||||
'parent' : 'it',
|
||||
'price_list_name': 'pl',
|
||||
'ref_currency': 'INR',
|
||||
'ref_rate': 100
|
||||
}
|
||||
),
|
||||
Document(
|
||||
fielddata = {
|
||||
'doctype': 'Item Tax',
|
||||
'parentfield': 'item_tax',
|
||||
'parenttype': 'Item',
|
||||
'parent' : 'it',
|
||||
'tax_type' : 'Tax1',
|
||||
'tax_rate': 10
|
||||
}
|
||||
)
|
||||
],
|
||||
|
||||
# Warehouse
|
||||
#-----------------------------
|
||||
'warehouse': [
|
||||
Document(
|
||||
fielddata = {
|
||||
'doctype': 'Warehouse',
|
||||
'name' : 'wh1',
|
||||
'warehouse_name' : 'wh1',
|
||||
'warehouse_type': 'normal',
|
||||
'company': 'comp'
|
||||
}
|
||||
),
|
||||
Document(
|
||||
fielddata = {
|
||||
'doctype': 'Warehouse',
|
||||
'name' : 'wh2',
|
||||
'warehouse_name' : 'wh2',
|
||||
'warehouse_type': 'normal',
|
||||
'company': 'comp'
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Save all master records
|
||||
#----------------------------------
|
||||
def create_master_records():
|
||||
for m in master_groups.keys():
|
||||
master_groups[m].save(1)
|
||||
|
||||
for m in main_masters.keys():
|
||||
if type(main_masters[m]) == list:
|
||||
for each in main_masters[m]:
|
||||
each.save(1)
|
||||
else:
|
||||
main_masters[m].save(1)
|
||||
102
sandbox/testdata/sle_data.py
vendored
Normal file
102
sandbox/testdata/sle_data.py
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from webnotes.model.doc import Document
|
||||
|
||||
# Existing SLE data
|
||||
#---------------------------
|
||||
|
||||
sle = [
|
||||
Document(
|
||||
fielddata = {
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'name': 'sle1',
|
||||
'posting_date': '2011-09-01',
|
||||
'posting_time': '12:00',
|
||||
'item_code': 'it',
|
||||
'warehouse': 'wh1',
|
||||
'actual_qty': 10,
|
||||
'incoming_rate': 100,
|
||||
'bin_aqat': 10,
|
||||
'valuation_rate': 100,
|
||||
'fcfs_stack': '',
|
||||
'stock_value': 1000,
|
||||
'is_cancelled': 'No'
|
||||
}
|
||||
),
|
||||
Document(
|
||||
fielddata = {
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'name': 'sle2',
|
||||
'posting_date': '2011-09-01',
|
||||
'posting_time': '12:00',
|
||||
'item_code': 'it',
|
||||
'warehouse': 'wh1',
|
||||
'actual_qty': -5,
|
||||
'incoming_rate': 100,
|
||||
'bin_aqat': 5,
|
||||
'valuation_rate': 100,
|
||||
'fcfs_stack': '',
|
||||
'stock_value': 500,
|
||||
'is_cancelled': 'No'
|
||||
}
|
||||
),
|
||||
Document(
|
||||
fielddata = {
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'name': 'sle3',
|
||||
'posting_date': '2011-09-10',
|
||||
'posting_time': '15:00',
|
||||
'item_code': 'it',
|
||||
'warehouse': 'wh1',
|
||||
'actual_qty': 20,
|
||||
'incoming_rate': 200,
|
||||
'bin_aqat': 25,
|
||||
'valuation_rate': 180,
|
||||
'fcfs_stack': '',
|
||||
'stock_value': 4500,
|
||||
'is_cancelled': 'No'
|
||||
}
|
||||
),
|
||||
Document(
|
||||
fielddata = {
|
||||
'doctype': 'Stock Ledger Entry',
|
||||
'name': 'sle4',
|
||||
'posting_date': '2011-09-15',
|
||||
'posting_time': '09:30',
|
||||
'item_code': 'it',
|
||||
'warehouse': 'wh1',
|
||||
'actual_qty': -5,
|
||||
'incoming_rate': 180,
|
||||
'bin_aqat': 20,
|
||||
'valuation_rate': 180,
|
||||
'fcfs_stack': '',
|
||||
'stock_value': 3600,
|
||||
'is_cancelled': 'No'
|
||||
}
|
||||
)
|
||||
]
|
||||
|
||||
bin = Document(
|
||||
fielddata = {
|
||||
'doctype': 'Bin',
|
||||
'name': 'bin01',
|
||||
'item_code': 'it',
|
||||
'warehouse': 'wh1',
|
||||
'actual_qty': 20,
|
||||
}
|
||||
)
|
||||
153
sandbox/testdata/stock_entry.py
vendored
Normal file
153
sandbox/testdata/stock_entry.py
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from webnotes.model.doc import Document
|
||||
|
||||
# Material Receipt
|
||||
#-----------------------
|
||||
|
||||
mr = [
|
||||
Document(
|
||||
fielddata = {
|
||||
'doctype': 'Stock Entry',
|
||||
'posting_date': '2011-09-01',
|
||||
'transfer_date': '2011-09-01',
|
||||
'posting_time': '12:00',
|
||||
'company': 'comp',
|
||||
'fiscal_year' : '2011-2012',
|
||||
'purpose': 'Material Receipt',
|
||||
'name': 'mr'
|
||||
}
|
||||
),
|
||||
Document(
|
||||
fielddata ={
|
||||
'doctype': 'Stock Entry Detail',
|
||||
'parenttype': 'Stock Entry',
|
||||
'parentfield' : 'mtn_details',
|
||||
'parent' : 'mr',
|
||||
'item_code' : 'it',
|
||||
't_warehouse' : 'wh1',
|
||||
'qty' : 10,
|
||||
'transfer_qty' : 10,
|
||||
'incoming_rate': 100,
|
||||
'stock_uom': 'Nos',
|
||||
'conversion_factor': 1,
|
||||
'serial_no': 'srno1, srno2, srno3, srno4, srno5, srno6, srno7, srno8, srno9, srno10'
|
||||
}
|
||||
)
|
||||
]
|
||||
|
||||
mr1 = [
|
||||
Document(
|
||||
fielddata = {
|
||||
'doctype': 'Stock Entry',
|
||||
'posting_date': '2011-09-01',
|
||||
'transfer_date': '2011-09-01',
|
||||
'posting_time': '12:00',
|
||||
'company': 'comp',
|
||||
'fiscal_year' : '2011-2012',
|
||||
'purpose': 'Material Receipt',
|
||||
'name': 'mr1'
|
||||
}
|
||||
),
|
||||
Document(
|
||||
fielddata ={
|
||||
'doctype': 'Stock Entry Detail',
|
||||
'parenttype': 'Stock Entry',
|
||||
'parentfield' : 'mtn_details',
|
||||
'parent' : 'mr1',
|
||||
'item_code' : 'it',
|
||||
't_warehouse' : 'wh1',
|
||||
'qty' : 5,
|
||||
'transfer_qty' : 5,
|
||||
'incoming_rate': 400,
|
||||
'stock_uom': 'Nos',
|
||||
'conversion_factor': 1,
|
||||
'serial_no': 'srno11, srno12, srno13, srno14, srno15'
|
||||
}
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
# Material Transfer
|
||||
#--------------------
|
||||
|
||||
mtn = [
|
||||
Document(
|
||||
fielddata = {
|
||||
'doctype': 'Stock Entry',
|
||||
'posting_date': '2011-09-01',
|
||||
'transfer_date': '2011-09-01',
|
||||
'posting_time': '12:00',
|
||||
'company': 'comp',
|
||||
'fiscal_year' : '2011-2012',
|
||||
'purpose': 'Material Transfer',
|
||||
'name': 'mtn'
|
||||
}
|
||||
),
|
||||
Document(
|
||||
fielddata ={
|
||||
'doctype': 'Stock Entry Detail',
|
||||
'parenttype': 'Stock Entry',
|
||||
'parentfield' : 'mtn_details',
|
||||
'parent' : 'mtn',
|
||||
'item_code' : 'it',
|
||||
's_warehouse' : 'wh1',
|
||||
't_warehouse' : 'wh2',
|
||||
'qty' : 5,
|
||||
'transfer_qty' : 5,
|
||||
'incoming_rate': 100,
|
||||
'stock_uom': 'Nos',
|
||||
'conversion_factor': 1,
|
||||
'serial_no': 'srno1, srno2, srno3, srno4, srno5'
|
||||
}
|
||||
)
|
||||
]
|
||||
|
||||
# Material Issue
|
||||
#--------------------
|
||||
|
||||
mi = [
|
||||
Document(
|
||||
fielddata = {
|
||||
'doctype': 'Stock Entry',
|
||||
'posting_date': '2011-09-01',
|
||||
'transfer_date': '2011-09-01',
|
||||
'posting_time': '14:00',
|
||||
'company': 'comp',
|
||||
'fiscal_year' : '2011-2012',
|
||||
'purpose': 'Material Issue',
|
||||
'name': 'mi'
|
||||
}
|
||||
),
|
||||
Document(
|
||||
fielddata ={
|
||||
'doctype': 'Stock Entry Detail',
|
||||
'parenttype': 'Stock Entry',
|
||||
'parentfield' : 'mtn_details',
|
||||
'parent' : 'mi',
|
||||
'item_code' : 'it',
|
||||
's_warehouse' : 'wh1',
|
||||
'qty' : 4,
|
||||
'transfer_qty' : 4,
|
||||
'incoming_rate': 100,
|
||||
'stock_uom': 'Nos',
|
||||
'conversion_factor': 1,
|
||||
'serial_no': 'srno1, srno2, srno3, srno4'
|
||||
}
|
||||
)
|
||||
]
|
||||
60
sandbox/testdata/stock_reco.py
vendored
Normal file
60
sandbox/testdata/stock_reco.py
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from webnotes.model.doc import Document
|
||||
|
||||
# Stock Reconciliation
|
||||
#---------------------------
|
||||
|
||||
sreco = Document(
|
||||
fielddata = {
|
||||
'doctype': 'Stock Reconciliation',
|
||||
'name': 'sreco',
|
||||
'reconciliation_date': '2011-09-08',
|
||||
'reconciliation_time': '20:00',
|
||||
}
|
||||
)
|
||||
|
||||
# diff in both
|
||||
csv_data1 = [
|
||||
['Item', 'Warehouse', 'Quantity', 'Rate'],
|
||||
['it', 'wh1', 20, 150]
|
||||
]
|
||||
|
||||
# diff in qty, no rate
|
||||
csv_data2 = [
|
||||
['Item', 'Warehouse', 'Quantity'],
|
||||
['it', 'wh1', 20]
|
||||
]
|
||||
|
||||
# diff in rate, no qty
|
||||
csv_data3 = [
|
||||
['Item', 'Warehouse', 'Rate'],
|
||||
['it', 'wh1', 200]
|
||||
]
|
||||
|
||||
# diff in rate, same qty
|
||||
csv_data4 = [
|
||||
['Item', 'Warehouse', 'Quantity', 'Rate'],
|
||||
['it', 'wh1', 5, 200]
|
||||
]
|
||||
|
||||
# no diff
|
||||
csv_data1 = [
|
||||
['Item', 'Warehouse', 'Quantity', 'Rate'],
|
||||
['it', 'wh1', 5, 100]
|
||||
]
|
||||
Reference in New Issue
Block a user