[demo] [minor] simulate quotation
This commit is contained in:
parent
0983cb75d5
commit
7c2a2e24a2
@ -17,6 +17,8 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
pr.submit()
|
pr.submit()
|
||||||
|
|
||||||
def test_over_billing_against_dn(self):
|
def test_over_billing_against_dn(self):
|
||||||
|
self._insert_purchase_receipt()
|
||||||
|
|
||||||
from stock.doctype.delivery_note.delivery_note import make_sales_invoice
|
from stock.doctype.delivery_note.delivery_note import make_sales_invoice
|
||||||
|
|
||||||
dn = webnotes.bean(copy=test_records[0]).insert()
|
dn = webnotes.bean(copy=test_records[0]).insert()
|
||||||
@ -31,8 +33,8 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
self.assertEquals(len(si), len(dn.doclist))
|
self.assertEquals(len(si), len(dn.doclist))
|
||||||
|
|
||||||
# modify export_amount
|
# modify export_amount
|
||||||
si[1].export_rate = 200
|
si[1].ref_rate = 200
|
||||||
self.assertRaises(webnotes.ValidationError, webnotes.bean(si).submit)
|
self.assertRaises(webnotes.ValidationError, webnotes.bean(si).insert)
|
||||||
|
|
||||||
|
|
||||||
def test_delivery_note_no_gl_entry(self):
|
def test_delivery_note_no_gl_entry(self):
|
||||||
|
23
utilities/demo_docs/Fiscal_Year.csv
Normal file
23
utilities/demo_docs/Fiscal_Year.csv
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
Data Import Template,,,,
|
||||||
|
Table:,Fiscal Year,,,
|
||||||
|
,,,,
|
||||||
|
,,,,
|
||||||
|
Notes:,,,,
|
||||||
|
Please do not change the template headings.,,,,
|
||||||
|
First data column must be blank.,,,,
|
||||||
|
"If you are uploading new records, leave the ""name"" (ID) column blank.",,,,
|
||||||
|
"If you are uploading new records, ""Naming Series"" becomes mandatory, if present.",,,,
|
||||||
|
Only mandatory fields are necessary for new records. You can delete non-mandatory columns if you wish.,,,,
|
||||||
|
"For updating, you can update only selective columns.",,,,
|
||||||
|
You can only upload upto 5000 records in one go. (may be less in some cases),,,,
|
||||||
|
,,,,
|
||||||
|
DocType:,Fiscal Year,,,
|
||||||
|
Column Labels:,ID,Year Name,Year Start Date,Year Closed
|
||||||
|
Column Name:,name,year,year_start_date,is_fiscal_year_closed
|
||||||
|
Mandatory:,Yes,Yes,Yes,No
|
||||||
|
Type:,Data (text),Data,Date,Select
|
||||||
|
Info:,,,,"One of: No, Yes"
|
||||||
|
Start entering data below this line,,,,
|
||||||
|
,,2009,01-Jan-2009,No
|
||||||
|
,,2010,01-Jan-2010,No
|
||||||
|
,,2011,01-Jan-2011,No
|
|
@ -32,3 +32,19 @@ Start entering data below this line,,,,,
|
|||||||
,Stand,Standard Buying,Buying,40,USD
|
,Stand,Standard Buying,Buying,40,USD
|
||||||
,Upper Bearing Plate,Standard Buying,Buying,50,USD
|
,Upper Bearing Plate,Standard Buying,Buying,50,USD
|
||||||
,Wing Sheet,Standard Buying,Buying,22,USD
|
,Wing Sheet,Standard Buying,Buying,22,USD
|
||||||
|
,Wind Turbine,Standard Selling,Selling,300,USD
|
||||||
|
,Wind Mill A Series,Standard Selling,Selling,340,USD
|
||||||
|
,Wind MIll C Series,Standard Selling,Selling,400,USD
|
||||||
|
,Base Bearing Plate,Standard Selling,Selling,21,USD
|
||||||
|
,Base Plate,Standard Selling,Selling,28,USD
|
||||||
|
,Bearing Block,Standard Selling,Selling,14,USD
|
||||||
|
,Bearing Collar,Standard Selling,Selling,28,USD
|
||||||
|
,Bearing Pipe,Standard Selling,Selling,21,USD
|
||||||
|
,Blade Rib,Standard Selling,Selling,14,USD
|
||||||
|
,Disc Collars,Standard Selling,Selling,103.6,USD
|
||||||
|
,External Disc,Standard Selling,Selling,63,USD
|
||||||
|
,Internal Disc,Standard Selling,Selling,46.2,USD
|
||||||
|
,Shaft,Standard Selling,Selling,42,USD
|
||||||
|
,Stand,Standard Selling,Selling,56,USD
|
||||||
|
,Upper Bearing Plate,Standard Selling,Selling,70,USD
|
||||||
|
,Wing Sheet,Standard Selling,Selling,30.8,USD
|
|
@ -1,14 +1,30 @@
|
|||||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
import webnotes, os
|
import webnotes, os, datetime
|
||||||
|
import webnotes.utils
|
||||||
|
import random
|
||||||
|
|
||||||
webnotes.session = webnotes._dict({"user":"Administrator"})
|
webnotes.session = webnotes._dict({"user":"Administrator"})
|
||||||
from core.page.data_import_tool.data_import_tool import upload
|
from core.page.data_import_tool.data_import_tool import upload
|
||||||
|
|
||||||
|
start_date = '2010-01-01'
|
||||||
|
runs_for = 100
|
||||||
|
prob = {
|
||||||
|
"Quotation": 0.5
|
||||||
|
}
|
||||||
|
|
||||||
def make():
|
def make():
|
||||||
webnotes.connect()
|
webnotes.connect()
|
||||||
webnotes.print_messages = True
|
webnotes.print_messages = True
|
||||||
webnotes.mute_emails = True
|
webnotes.mute_emails = True
|
||||||
|
|
||||||
|
# setup()
|
||||||
|
# simulate()
|
||||||
|
make_quotation("2010-01-01")
|
||||||
|
webnotes.conn.commit()
|
||||||
|
|
||||||
|
def setup():
|
||||||
install()
|
install()
|
||||||
complete_setup()
|
complete_setup()
|
||||||
make_items()
|
make_items()
|
||||||
@ -18,6 +34,81 @@ def make():
|
|||||||
# make_opening_stock()
|
# make_opening_stock()
|
||||||
# make_opening_accounts()
|
# make_opening_accounts()
|
||||||
|
|
||||||
|
def simulate():
|
||||||
|
current_date = None
|
||||||
|
for i in xrange(runs_for):
|
||||||
|
if not current_date:
|
||||||
|
current_date = webnotes.utils.getdate(start_date)
|
||||||
|
else:
|
||||||
|
current_date = webnotes.utils.add_days(current_date, 1)
|
||||||
|
|
||||||
|
if current_date.weekday() in (5, 6):
|
||||||
|
continue
|
||||||
|
|
||||||
|
run_sales(current_date)
|
||||||
|
|
||||||
|
webnotes.conn.commit()
|
||||||
|
|
||||||
|
|
||||||
|
def run_sales(current_date):
|
||||||
|
if random.random() < prob["Quotation"]:
|
||||||
|
make_quotation(current_date)
|
||||||
|
|
||||||
|
def make_quotation(current_date):
|
||||||
|
b = webnotes.bean([{
|
||||||
|
"creation": current_date,
|
||||||
|
"doctype": "Quotation",
|
||||||
|
"quotation_to": "Customer",
|
||||||
|
"customer": get_random("Customer"),
|
||||||
|
"order_type": "Sales",
|
||||||
|
"price_list_name": "Standard Selling",
|
||||||
|
"transaction_date": current_date,
|
||||||
|
"fiscal_year": "2010"
|
||||||
|
}])
|
||||||
|
|
||||||
|
add_random_children(b, {
|
||||||
|
"doctype": "Quotation Item",
|
||||||
|
"parentfield": "quotation_details",
|
||||||
|
}, rows=3, randomize = {
|
||||||
|
"qty": (1, 5),
|
||||||
|
"item_code": ("Item", {"is_sales_item": "Yes"})
|
||||||
|
}, unique="item_code")
|
||||||
|
|
||||||
|
b.insert()
|
||||||
|
print b.doc.name
|
||||||
|
|
||||||
|
def add_random_children(bean, template, rows, randomize, unique=None):
|
||||||
|
for i in xrange(random.randrange(1, rows)):
|
||||||
|
d = template.copy()
|
||||||
|
for key, val in randomize.items():
|
||||||
|
if isinstance(val[0], basestring):
|
||||||
|
d[key] = get_random(*val)
|
||||||
|
else:
|
||||||
|
d[key] = random.randrange(*val)
|
||||||
|
|
||||||
|
if unique:
|
||||||
|
if not bean.doclist.get({"doctype": d["doctype"], unique:d[unique]}):
|
||||||
|
bean.doclist.append(d)
|
||||||
|
else:
|
||||||
|
bean.doclist.append(d)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def get_random(doctype, filters=None):
|
||||||
|
condition = []
|
||||||
|
if filters:
|
||||||
|
for key, val in filters.items():
|
||||||
|
condition.append("%s='%s'" % (key, val))
|
||||||
|
if condition:
|
||||||
|
condition = " where " + " and ".join(condition)
|
||||||
|
else:
|
||||||
|
condition = ""
|
||||||
|
|
||||||
|
out = webnotes.conn.sql("""select name from `tab%s` %s
|
||||||
|
order by RAND() limit 0,1""" % (doctype, condition))[0][0]
|
||||||
|
|
||||||
|
return out
|
||||||
|
|
||||||
def install():
|
def install():
|
||||||
print "Creating Fresh Database..."
|
print "Creating Fresh Database..."
|
||||||
from webnotes.install_lib.install import Installer
|
from webnotes.install_lib.install import Installer
|
||||||
@ -38,6 +129,11 @@ def complete_setup():
|
|||||||
"country": "United States"
|
"country": "United States"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
print "Importing Fiscal Years..."
|
||||||
|
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Fiscal_Year.csv")
|
||||||
|
upload()
|
||||||
|
|
||||||
|
|
||||||
def make_items():
|
def make_items():
|
||||||
print "Importing Items..."
|
print "Importing Items..."
|
||||||
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Item.csv")
|
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Item.csv")
|
||||||
@ -75,7 +171,7 @@ def make_users_and_employees():
|
|||||||
upload()
|
upload()
|
||||||
|
|
||||||
print "Importing Salary Structure..."
|
print "Importing Salary Structure..."
|
||||||
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Salary Structure.csv")
|
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", "Salary_Structure.csv")
|
||||||
upload()
|
upload()
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user