fix(demo): make demo work again
definitely not a maga rebranding. * import erpnext and set default company for accounts * replace job card start/end date with job card time log * create a doc for lost_reason * pass opportunity/quotation lost_reason as a list of dicts * fix company in stock reconciliation Signed-off-by: Chinmay Pai <chinmaydpai@gmail.com>
This commit is contained in:
parent
fa626bd3ab
commit
b503896594
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import erpnext
|
||||||
import frappe
|
import frappe
|
||||||
import random
|
import random
|
||||||
from frappe.utils import random_string
|
from frappe.utils import random_string
|
||||||
@ -72,8 +73,10 @@ def work():
|
|||||||
make_pos_invoice()
|
make_pos_invoice()
|
||||||
|
|
||||||
def make_payment_entries(ref_doctype, report):
|
def make_payment_entries(ref_doctype, report):
|
||||||
outstanding_invoices = list(set([r[3] for r in query_report.run(report,
|
outstanding_invoices = list(set([r[3] for r in query_report.run(report, {
|
||||||
{"report_date": frappe.flags.current_date })["result"] if r[2]==ref_doctype]))
|
"report_date": frappe.flags.current_date,
|
||||||
|
"company": erpnext.get_default_company()
|
||||||
|
})["result"] if r[2]==ref_doctype]))
|
||||||
|
|
||||||
# make Payment Entry
|
# make Payment Entry
|
||||||
for inv in outstanding_invoices[:random.randint(1, 2)]:
|
for inv in outstanding_invoices[:random.randint(1, 2)]:
|
||||||
|
@ -102,10 +102,18 @@ def submit_job_cards():
|
|||||||
|
|
||||||
for operation in work_order.operations:
|
for operation in work_order.operations:
|
||||||
job = job_map[operation.operation]
|
job = job_map[operation.operation]
|
||||||
job.actual_start_date = start_date
|
job_time_log = frappe.new_doc("Job Card Time Log")
|
||||||
|
job_time_log.from_time = start_date
|
||||||
minutes = operation.get("time_in_mins")
|
minutes = operation.get("time_in_mins")
|
||||||
random_minutes = random.randint(int(minutes/2), minutes)
|
job_time_log.time_in_mins = random.randint(int(minutes/2), minutes)
|
||||||
job.actual_end_date = job.actual_start_date + timedelta(minutes=random_minutes)
|
job_time_log.to_time = job_time_log.from_time + \
|
||||||
start_date = job.actual_end_date
|
timedelta(minutes=job_time_log.time_in_mins)
|
||||||
job.save()
|
job_time_log.parent = job.name
|
||||||
|
job_time_log.parenttype = 'Job Card'
|
||||||
|
job_time_log.parentfield = 'time_logs'
|
||||||
|
job_time_log.completed_qty = work_order.qty
|
||||||
|
job_time_log.save(ignore_permissions=True)
|
||||||
|
job.time_logs.append(job_time_log)
|
||||||
|
job.save(ignore_permissions=True)
|
||||||
job.submit()
|
job.submit()
|
||||||
|
start_date = job_time_log.to_time
|
||||||
|
@ -21,17 +21,26 @@ def work(domain="Manufacturing"):
|
|||||||
if random.random() < 0.5:
|
if random.random() < 0.5:
|
||||||
make_quotation(domain)
|
make_quotation(domain)
|
||||||
|
|
||||||
|
try:
|
||||||
|
lost_reason = frappe.get_doc({
|
||||||
|
"doctype": "Opportunity Lost Reason",
|
||||||
|
"lost_reason": "Did not ask"
|
||||||
|
})
|
||||||
|
lost_reason.save(ignore_permissions=True)
|
||||||
|
except frappe.exceptions.DuplicateEntryError:
|
||||||
|
pass
|
||||||
|
|
||||||
# lost quotations / inquiries
|
# lost quotations / inquiries
|
||||||
if random.random() < 0.3:
|
if random.random() < 0.3:
|
||||||
for i in range(random.randint(1,3)):
|
for i in range(random.randint(1,3)):
|
||||||
quotation = get_random('Quotation', doc=True)
|
quotation = get_random('Quotation', doc=True)
|
||||||
if quotation and quotation.status == 'Submitted':
|
if quotation and quotation.status == 'Submitted':
|
||||||
quotation.declare_order_lost('Did not ask')
|
quotation.declare_order_lost([{'lost_reason': 'Did not ask'}])
|
||||||
|
|
||||||
for i in range(random.randint(1,3)):
|
for i in range(random.randint(1,3)):
|
||||||
opportunity = get_random('Opportunity', doc=True)
|
opportunity = get_random('Opportunity', doc=True)
|
||||||
if opportunity and opportunity.status in ('Open', 'Replied'):
|
if opportunity and opportunity.status in ('Open', 'Replied'):
|
||||||
opportunity.declare_enquiry_lost('Did not ask')
|
opportunity.declare_enquiry_lost([{'lost_reason': 'Did not ask'}])
|
||||||
|
|
||||||
for i in range(random.randint(1,3)):
|
for i in range(random.randint(1,3)):
|
||||||
if random.random() < 0.6:
|
if random.random() < 0.6:
|
||||||
|
@ -73,13 +73,13 @@ def make_stock_reconciliation():
|
|||||||
stock_reco = frappe.new_doc("Stock Reconciliation")
|
stock_reco = frappe.new_doc("Stock Reconciliation")
|
||||||
stock_reco.posting_date = frappe.flags.current_date
|
stock_reco.posting_date = frappe.flags.current_date
|
||||||
stock_reco.company = erpnext.get_default_company()
|
stock_reco.company = erpnext.get_default_company()
|
||||||
stock_reco.get_items_for("Stores - WP")
|
stock_reco.get_items_for("Stores - WPL")
|
||||||
if stock_reco.items:
|
if stock_reco.items:
|
||||||
for item in stock_reco.items:
|
for item in stock_reco.items:
|
||||||
if item.qty:
|
if item.qty:
|
||||||
item.qty = item.qty - round(random.randint(1, item.qty))
|
item.qty = item.qty - round(random.randint(1, item.qty))
|
||||||
try:
|
try:
|
||||||
stock_reco.insert()
|
stock_reco.insert(ignore_permissions=True)
|
||||||
stock_reco.submit()
|
stock_reco.submit()
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
except OpeningEntryAccountError:
|
except OpeningEntryAccountError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user