[demo] [minor] simulate quotation
diff --git a/controllers/accounts_controller.py b/controllers/accounts_controller.py
index 42e9995..3676510 100644
--- a/controllers/accounts_controller.py
+++ b/controllers/accounts_controller.py
@@ -388,7 +388,7 @@
total_billed_amt = flt(flt(already_billed) + flt(item.fields[based_on]),
self.precision(based_on, item))
-
+
if max_allowed_amt and total_billed_amt - max_allowed_amt > 0.02:
webnotes.msgprint(_("Row ")+ cstr(item.idx) + ": " + cstr(item.item_code) +
_(" will be over-billed against mentioned ") + cstr(ref_dt) +
diff --git a/selling/utils.py b/selling/utils.py
index 2d4fcc4..858312a 100644
--- a/selling/utils.py
+++ b/selling/utils.py
@@ -59,7 +59,7 @@
if args.price_list_name and args.price_list_currency:
out.update(_get_price_list_rate(args, item_bean, meta))
-
+
out.update(_get_item_discount(out.item_group, args.customer))
if out.get(warehouse_fieldname):
@@ -70,7 +70,7 @@
if cint(args.is_pos):
pos_settings = get_pos_settings(args.company)
out.update(apply_pos_settings(pos_settings, out))
-
+
return out
def _get_item_code(barcode):
@@ -132,7 +132,7 @@
"price_list_name": args.price_list_name,
"ref_currency": args.price_list_currency,
"buying_or_selling": "Selling"})
-
+
if not base_ref_rate:
return {}
diff --git a/stock/doctype/delivery_note/test_delivery_note.py b/stock/doctype/delivery_note/test_delivery_note.py
index 641a564..505cad3 100644
--- a/stock/doctype/delivery_note/test_delivery_note.py
+++ b/stock/doctype/delivery_note/test_delivery_note.py
@@ -17,6 +17,8 @@
pr.submit()
def test_over_billing_against_dn(self):
+ self._insert_purchase_receipt()
+
from stock.doctype.delivery_note.delivery_note import make_sales_invoice
dn = webnotes.bean(copy=test_records[0]).insert()
@@ -31,8 +33,8 @@
self.assertEquals(len(si), len(dn.doclist))
# modify export_amount
- si[1].export_rate = 200
- self.assertRaises(webnotes.ValidationError, webnotes.bean(si).submit)
+ si[1].ref_rate = 200
+ self.assertRaises(webnotes.ValidationError, webnotes.bean(si).insert)
def test_delivery_note_no_gl_entry(self):
diff --git a/utilities/demo_docs/Fiscal_Year.csv b/utilities/demo_docs/Fiscal_Year.csv
new file mode 100644
index 0000000..09e8252
--- /dev/null
+++ b/utilities/demo_docs/Fiscal_Year.csv
@@ -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
\ No newline at end of file
diff --git a/utilities/demo_docs/Item_Price.csv b/utilities/demo_docs/Item_Price.csv
index f0f657e..b181fb8 100644
--- a/utilities/demo_docs/Item_Price.csv
+++ b/utilities/demo_docs/Item_Price.csv
@@ -31,4 +31,20 @@
,Shaft,Standard Buying,Buying,30,USD
,Stand,Standard Buying,Buying,40,USD
,Upper Bearing Plate,Standard Buying,Buying,50,USD
-,Wing Sheet,Standard Buying,Buying,22,USD
\ No newline at end of file
+,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
\ No newline at end of file
diff --git a/utilities/make_demo.py b/utilities/make_demo.py
index 951aded..61a971b 100644
--- a/utilities/make_demo.py
+++ b/utilities/make_demo.py
@@ -1,14 +1,30 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# 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"})
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():
webnotes.connect()
webnotes.print_messages = True
webnotes.mute_emails = True
+
+ # setup()
+ # simulate()
+ make_quotation("2010-01-01")
+ webnotes.conn.commit()
+
+def setup():
install()
complete_setup()
make_items()
@@ -17,6 +33,81 @@
# make_bom()
# make_opening_stock()
# 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():
print "Creating Fresh Database..."
@@ -37,6 +128,11 @@
"timezone": "America/New York",
"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():
print "Importing Items..."
@@ -75,7 +171,7 @@
upload()
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()
if __name__=="__main__":