Demo data for Payment Entry
This commit is contained in:
parent
89d0b1b9a5
commit
26cad30372
@ -8,11 +8,13 @@ import frappe
|
|||||||
import random
|
import random
|
||||||
from frappe.utils import random_string
|
from frappe.utils import random_string
|
||||||
from frappe.desk import query_report
|
from frappe.desk import query_report
|
||||||
|
from erpnext.accounts.doctype.journal_entry.journal_entry import get_payment_entry_against_invoice
|
||||||
|
from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry
|
||||||
|
|
||||||
def work():
|
def work():
|
||||||
frappe.set_user(frappe.db.get_global('demo_accounts_user'))
|
frappe.set_user(frappe.db.get_global('demo_accounts_user'))
|
||||||
|
|
||||||
if random.random() < 0.5:
|
if random.random() <= 0.6:
|
||||||
from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice
|
from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice
|
||||||
report = "Ordered Items to be Billed"
|
report = "Ordered Items to be Billed"
|
||||||
for so in list(set([r[0] for r in query_report.run(report)["result"]
|
for so in list(set([r[0] for r in query_report.run(report)["result"]
|
||||||
@ -26,7 +28,7 @@ def work():
|
|||||||
si.submit()
|
si.submit()
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
if random.random() < 0.5:
|
if random.random() <= 0.6:
|
||||||
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
|
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
|
||||||
report = "Received Items to be Billed"
|
report = "Received Items to be Billed"
|
||||||
for pr in list(set([r[0] for r in query_report.run(report)["result"]
|
for pr in list(set([r[0] for r in query_report.run(report)["result"]
|
||||||
@ -38,30 +40,33 @@ def work():
|
|||||||
pi.submit()
|
pi.submit()
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
from erpnext.accounts.doctype.journal_entry.journal_entry import get_payment_entry_against_invoice
|
if random.random() <= 0.5:
|
||||||
|
make_payment_entries("Sales Invoice", "Accounts Receivable")
|
||||||
|
|
||||||
if random.random() < 0.5:
|
if random.random() <= 0.5:
|
||||||
report = "Accounts Receivable"
|
make_payment_entries("Purchase Invoice", "Accounts Payable")
|
||||||
for si in list(set([r[3] for r in query_report.run(report,
|
|
||||||
{"report_date": frappe.flags.current_date })["result"]
|
def make_payment_entries(ref_doctype, report):
|
||||||
if r[2]=="Sales Invoice"]))[:random.randint(1, 5)]:
|
outstanding_invoices = list(set([r[3] for r in query_report.run(report,
|
||||||
jv = frappe.get_doc(get_payment_entry_against_invoice("Sales Invoice", si))
|
{"report_date": frappe.flags.current_date })["result"] if r[2]==ref_doctype]))
|
||||||
|
|
||||||
|
# make payment via JV
|
||||||
|
for inv in outstanding_invoices[:random.randint(1, 2)]:
|
||||||
|
jv = frappe.get_doc(get_payment_entry_against_invoice(ref_doctype, inv))
|
||||||
jv.posting_date = frappe.flags.current_date
|
jv.posting_date = frappe.flags.current_date
|
||||||
jv.cheque_no = random_string(6)
|
jv.cheque_no = random_string(6)
|
||||||
jv.cheque_date = frappe.flags.current_date
|
jv.cheque_date = frappe.flags.current_date
|
||||||
jv.insert()
|
jv.insert()
|
||||||
jv.submit()
|
jv.submit()
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
outstanding_invoices.remove(inv)
|
||||||
|
|
||||||
if random.random() < 0.5:
|
# make Payment Entry
|
||||||
report = "Accounts Payable"
|
for inv in outstanding_invoices[:random.randint(1, 3)]:
|
||||||
for pi in list(set([r[3] for r in query_report.run(report,
|
pe = get_payment_entry(ref_doctype, inv)
|
||||||
{"report_date": frappe.flags.current_date })["result"]
|
pe.posting_date = frappe.flags.current_date
|
||||||
if r[2]=="Purchase Invoice"]))[:random.randint(1, 5)]:
|
pe.reference_no = random_string(6)
|
||||||
jv = frappe.get_doc(get_payment_entry_against_invoice("Purchase Invoice", pi))
|
pe.reference_date = frappe.flags.current_date
|
||||||
jv.posting_date = frappe.flags.current_date
|
pe.insert()
|
||||||
jv.cheque_no = random_string(6)
|
pe.submit()
|
||||||
jv.cheque_date = frappe.flags.current_date
|
|
||||||
jv.insert()
|
|
||||||
jv.submit()
|
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
@ -45,7 +45,7 @@ def make_opportunity():
|
|||||||
|
|
||||||
add_random_children(b, "items", rows=4, randomize = {
|
add_random_children(b, "items", rows=4, randomize = {
|
||||||
"qty": (1, 5),
|
"qty": (1, 5),
|
||||||
"item_code": ("Item", {"has_variants": "0"})
|
"item_code": ("Item", {"has_variants": "0", "is_fixed_asset": 0})
|
||||||
}, unique="item_code")
|
}, unique="item_code")
|
||||||
|
|
||||||
b.insert()
|
b.insert()
|
||||||
@ -88,7 +88,7 @@ def make_quotation():
|
|||||||
|
|
||||||
add_random_children(qtn, "items", rows=3, randomize = {
|
add_random_children(qtn, "items", rows=3, randomize = {
|
||||||
"qty": (1, 5),
|
"qty": (1, 5),
|
||||||
"item_code": ("Item", {"has_variants": "0"})
|
"item_code": ("Item", {"has_variants": "0", "is_fixed_asset": 0})
|
||||||
}, unique="item_code")
|
}, unique="item_code")
|
||||||
|
|
||||||
qtn.insert()
|
qtn.insert()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user