def run_accounts(current_date): if can_make("Sales Invoice"): from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice report = "Ordered Items to be Billed" for so in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Sales Invoice")]: si = frappe.get_doc(make_sales_invoice(so)) si.posting_date = current_date si.fiscal_year = cstr(current_date.year) for d in si.get("items"): if not d.income_account: d.income_account = "Sales - {}".format(settings.company_abbr) si.insert() si.submit() frappe.db.commit() if can_make("Purchase Invoice"): from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice report = "Received Items to be Billed" for pr in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Purchase Invoice")]: pi = frappe.get_doc(make_purchase_invoice(pr)) pi.posting_date = current_date pi.fiscal_year = cstr(current_date.year) pi.bill_no = random_string(6) pi.insert() pi.submit() frappe.db.commit() from erpnext.accounts.doctype.journal_entry.journal_entry import get_payment_entry_against_invoice if can_make("Payment Received"): report = "Accounts Receivable" for si in list(set([r[3] for r in query_report.run(report, {"report_date": current_date })["result"] if r[2]=="Sales Invoice"]))[:how_many("Payment Received")]: jv = frappe.get_doc(get_payment_entry_against_invoice("Sales Invoice", si)) jv.posting_date = current_date jv.cheque_no = random_string(6) jv.cheque_date = current_date jv.insert() jv.submit() frappe.db.commit() if can_make("Payment Made"): report = "Accounts Payable" for pi in list(set([r[3] for r in query_report.run(report, {"report_date": current_date })["result"] if r[2]=="Purchase Invoice"]))[:how_many("Payment Made")]: jv = frappe.get_doc(get_payment_entry_against_invoice("Purchase Invoice", pi)) jv.posting_date = current_date jv.cheque_no = random_string(6) jv.cheque_date = current_date jv.insert() jv.submit() frappe.db.commit()
def run_accounts(current_date): if can_make("Sales Invoice"): from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice report = "Ordered Items to be Billed" for so in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Sales Invoice")]: si = frappe.get_doc(make_sales_invoice(so)) si.posting_date = current_date for d in si.get("items"): if not d.income_account: d.income_account = "Sales - {}".format(settings.company_abbr) si.insert() si.submit() frappe.db.commit() if can_make("Purchase Invoice"): from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice report = "Received Items to be Billed" for pr in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Purchase Invoice")]: pi = frappe.get_doc(make_purchase_invoice(pr)) pi.posting_date = current_date pi.bill_no = random_string(6) pi.insert() pi.submit() frappe.db.commit() from erpnext.accounts.doctype.journal_entry.journal_entry import get_payment_entry_against_invoice if can_make("Payment Received"): report = "Accounts Receivable" for si in list(set([r[3] for r in query_report.run(report, {"report_date": current_date })["result"] if r[2]=="Sales Invoice"]))[:how_many("Payment Received")]: jv = frappe.get_doc(get_payment_entry_against_invoice("Sales Invoice", si)) jv.posting_date = current_date jv.cheque_no = random_string(6) jv.cheque_date = current_date jv.insert() jv.submit() frappe.db.commit() if can_make("Payment Made"): report = "Accounts Payable" for pi in list(set([r[3] for r in query_report.run(report, {"report_date": current_date })["result"] if r[2]=="Purchase Invoice"]))[:how_many("Payment Made")]: jv = frappe.get_doc(get_payment_entry_against_invoice("Purchase Invoice", pi)) jv.posting_date = current_date jv.cheque_no = random_string(6) jv.cheque_date = current_date jv.insert() jv.submit() frappe.db.commit()
def create_journal_entry(self): """create entry""" payment_details = { "amount": self.amount, "journal_entry": True, "bank_account": self.payment_account } frappe.flags.ignore_account_permission = True if self.reference_doctype == "Sales Order": jv = get_payment_entry_against_order(self.reference_doctype, self.reference_name,\ amount=self.amount, journal_entry=True, bank_account=self.payment_account) if self.reference_doctype == "Sales Invoice": jv = get_payment_entry_against_invoice(self.reference_doctype, self.reference_name,\ amount=self.amount, journal_entry=True, bank_account=self.payment_account) jv.update({"voucher_type": "Journal Entry", "posting_date": nowdate()}) jv.insert(ignore_permissions=True) jv.submit() #set status as paid for Payment Request frappe.db.set_value(self.doctype, self.name, "status", "Paid") return jv
def make_payment_entries(ref_doctype, report): outstanding_invoices = frappe.get_all( ref_doctype, fields=["name"], filters={ "company": erpnext.get_default_company(), "outstanding_amount": (">", 0.0) }, ) # make Payment Entry for inv in outstanding_invoices[:random.randint(1, 2)]: pe = get_payment_entry(ref_doctype, inv.name) pe.posting_date = frappe.flags.current_date pe.reference_no = random_string(6) pe.reference_date = frappe.flags.current_date pe.insert() pe.submit() frappe.db.commit() outstanding_invoices.remove(inv) # make payment via JV for inv in outstanding_invoices[:1]: jv = frappe.get_doc( get_payment_entry_against_invoice(ref_doctype, inv.name)) jv.posting_date = frappe.flags.current_date jv.cheque_no = random_string(6) jv.cheque_date = frappe.flags.current_date jv.insert() jv.submit() frappe.db.commit()
def test_make_payment_before_loan_period(self): #it has problem inv = create_sales_invoice(item_code="_Test Item Home Desktop 100", rate=700) inv_disc = create_invoice_discounting( [inv.name], accounts_receivable_credit=self.ar_credit, accounts_receivable_discounted=self.ar_discounted, accounts_receivable_unpaid=self.ar_unpaid, short_term_loan=self.short_term_loan, bank_charges_account=self.bank_charges_account, bank_account=self.bank_account) je = inv_disc.create_disbursement_entry() inv_disc.reload() je.posting_date = nowdate() je.submit() je_on_payment = frappe.get_doc( get_payment_entry_against_invoice("Sales Invoice", inv.name)) je_on_payment.posting_date = nowdate() je_on_payment.cheque_no = "126981" je_on_payment.cheque_date = nowdate() je_on_payment.save() je_on_payment.submit() self.assertEqual(je_on_payment.accounts[0].account, self.ar_discounted) self.assertEqual(je_on_payment.accounts[0].credit_in_account_currency, flt(inv.outstanding_amount)) self.assertEqual(je_on_payment.accounts[1].account, self.bank_account) self.assertEqual(je_on_payment.accounts[1].debit_in_account_currency, flt(inv.outstanding_amount)) inv.reload() self.assertEqual(inv.outstanding_amount, 0)
def make_payment_entries(ref_doctype, 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 ])) # make Payment Entry for inv in outstanding_invoices[:random.randint(1, 2)]: pe = get_payment_entry(ref_doctype, inv) pe.posting_date = frappe.flags.current_date pe.reference_no = random_string(6) pe.reference_date = frappe.flags.current_date pe.insert() pe.submit() frappe.db.commit() outstanding_invoices.remove(inv) # make payment via JV for inv in outstanding_invoices[:1]: jv = frappe.get_doc(get_payment_entry_against_invoice( ref_doctype, inv)) jv.posting_date = frappe.flags.current_date jv.cheque_no = random_string(6) jv.cheque_date = frappe.flags.current_date jv.insert() jv.submit() frappe.db.commit()
def test_on_close_after_loan_period_after_inv_payment(self): inv = create_sales_invoice(rate=600) inv_disc = create_invoice_discounting( [inv.name], accounts_receivable_credit=self.ar_credit, accounts_receivable_discounted=self.ar_discounted, accounts_receivable_unpaid=self.ar_unpaid, short_term_loan=self.short_term_loan, bank_charges_account=self.bank_charges_account, bank_account=self.bank_account, start=nowdate(), period=60) je1 = inv_disc.create_disbursement_entry() je1.posting_date = nowdate() je1.submit() je_on_payment = frappe.get_doc( get_payment_entry_against_invoice("Sales Invoice", inv.name)) je_on_payment.posting_date = nowdate() je_on_payment.cheque_no = "126981" je_on_payment.cheque_date = nowdate() je_on_payment.save() je_on_payment.submit() je2 = inv_disc.close_loan() self.assertEqual(je2.accounts[0].account, self.short_term_loan) self.assertEqual(je2.accounts[0].debit_in_account_currency, flt(inv_disc.total_amount)) self.assertEqual(je2.accounts[1].account, self.bank_account) self.assertEqual(je2.accounts[1].credit_in_account_currency, flt(inv_disc.total_amount))
def create_journal_entry(self): """create entry""" payment_details = { "amount": self.amount, "journal_entry": True, "bank_account": self.payment_account } frappe.flags.ignore_account_permission = True if self.reference_doctype == "Sales Order": jv = get_payment_entry_against_order(self.reference_doctype, self.reference_name,\ amount=self.amount, journal_entry=True, bank_account=self.payment_account) if self.reference_doctype == "Sales Invoice": jv = get_payment_entry_against_invoice(self.reference_doctype, self.reference_name,\ amount=self.amount, journal_entry=True, bank_account=self.payment_account) jv.update({ "voucher_type": "Journal Entry", "posting_date": nowdate() }) jv.insert(ignore_permissions=True) jv.submit() #set status as paid for Payment Request frappe.db.set_value(self.doctype, self.name, "status", "Paid") return jv
def create_journal_entry_against_pi(made_payment): Transaction_date = made_payment['TxnDate'] Supplier_Ref = made_payment['VendorRef'] CurrencyRef = made_payment['CurrencyRef'] Deposit_To_AccountRef = made_payment.get('CheckPayment') Amount = made_payment.get( 'Line' )[0]['Amount'] if made_payment['Line'] else made_payment['TotalAmt'] Type = made_payment['PayType'] reference_quickbooks_PI_id = made_payment.get( 'Line')[0]['LinkedTxn'][0]['TxnId'] if made_payment['Line'] else '' Bill_Payment_Id = made_payment['Id'] reference_qb_bank_account_id = made_payment.get('CheckPayment').get( 'BankAccountRef').get('value') if made_payment.get( 'CheckPayment') else None qb_journal_entry_id = '' if Bill_Payment_Id: qb_journal_entry_id = "PI" + Bill_Payment_Id purchase_invoice_name = frappe.db.get_value( "Purchase Invoice", {"quickbooks_purchase_invoice_id": reference_quickbooks_PI_id}, "name") qb_account_name = frappe.db.get_value( "Account", {"quickbooks_account_id": reference_qb_bank_account_id}, "name") try: if not frappe.db.get_value( "Journal Entry", {"quickbooks_journal_entry_id": qb_journal_entry_id}, "name"): if Type == "Check" and purchase_invoice_name: pi_je = get_payment_entry_against_invoice( "Purchase Invoice", purchase_invoice_name, amount=None, debit_in_account_currency=None, journal_entry=False, bank_account=qb_account_name) pi_je = frappe.get_doc(pi_je) pi_je.quickbooks_journal_entry_id = qb_journal_entry_id pi_je.naming_series = "PI-JV-Quickbooks-" pi_je.cheque_no = "Check no" pi_je.cheque_date = Transaction_date pi_je.posting_date = Transaction_date pi_je.save() pi_je.submit() frappe.db.commit() else: raise _("No Purchase Invoice present") except Exception, e: if e.args[0] and e.args[0].startswith("402"): raise e else: make_quickbooks_log(title=e.message, status="Error", method="create_journal_entry_against_pi", message=frappe.get_traceback(), request_data=made_payment, exception=True)
def create_journal_entry_against_si(recived_payment): item = [] for i in recived_payment['Line'][0]['LineEx']['any']: item.append(i.get('value')) LineEx = item Payment_Id = recived_payment['Id'] TotalAmt = recived_payment['TotalAmt'] Transaction_date = recived_payment['TxnDate'] Amount = recived_payment['Line'][0]['Amount'] Customer_reference = recived_payment['CustomerRef'] Type = recived_payment['Line'][0]['LinkedTxn'][0]['TxnType'] reference_qb_bank_account_id = recived_payment['DepositToAccountRef'][ 'value'] if recived_payment.get('DepositToAccountRef') else None reference_quickbooks_invoce_id = recived_payment['Line'][0]['LinkedTxn'][ 0]['TxnId'] qb_journal_entry_id = '' if Payment_Id: qb_journal_entry_id = "SI" + Payment_Id sales_invoice_name = frappe.db.get_value( "Sales Invoice", {"quickbooks_invoce_id": reference_quickbooks_invoce_id}, "name") qb_account_name = frappe.db.get_value( "Account", {"quickbooks_account_id": reference_qb_bank_account_id}, "name") try: if not frappe.db.get_value( "Journal Entry", {"quickbooks_journal_entry_id": qb_journal_entry_id}, "name"): if Type == "Invoice" and sales_invoice_name: si_je = get_payment_entry_against_invoice( "Sales Invoice", sales_invoice_name, amount=None, debit_in_account_currency=None, journal_entry=False, bank_account=qb_account_name) si_je = frappe.get_doc(si_je) si_je.quickbooks_journal_entry_id = qb_journal_entry_id si_je.naming_series = "SI-JV-Quickbooks-" si_je.cheque_no = "check no" si_je.cheque_date = Transaction_date si_je.posting_date = Transaction_date si_je.save() si_je.submit() frappe.db.commit() else: raise _("No Sales Invoice present ") except Exception, e: if e.args[0] and e.args[0].startswith("402"): raise e else: make_quickbooks_log(title=e.message, status="Error", method="create_journal_entry_against_si", message=frappe.get_traceback(), request_data=recived_payment, exception=True)
def create_journal_entry(self): """create entry""" frappe.flags.ignore_account_permission = True ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name) party_account = get_party_account("Customer", ref_doc.get("customer"), ref_doc.company) party_account_currency = get_account_currency(party_account) debit_in_account_currency = 0.0 if party_account_currency == ref_doc.company_currency: amount = flt( flt(self.grand_total) * flt(ref_doc.conversion_rate, ref_doc.precision("conversion_rate")), ref_doc.precision("base_grand_total"), ) if self.currency != ref_doc.company_currency: debit_in_account_currency = self.grand_total else: amount = debit_in_account_currency = self.grand_total if self.reference_doctype == "Sales Order": jv = get_payment_entry_against_order( self.reference_doctype, self.reference_name, amount=amount, debit_in_account_currency=debit_in_account_currency, journal_entry=True, bank_account=self.payment_account, ) if self.reference_doctype == "Sales Invoice": jv = get_payment_entry_against_invoice( self.reference_doctype, self.reference_name, amount=amount, debit_in_account_currency=debit_in_account_currency, journal_entry=True, bank_account=self.payment_account, ) jv.update({"voucher_type": "Journal Entry", "posting_date": nowdate()}) jv.insert(ignore_permissions=True) jv.submit() # set status as paid for Payment Request frappe.db.set_value(self.doctype, self.name, "status", "Paid") return jv
def create_journal_entry(self): """create entry""" frappe.flags.ignore_account_permission = True ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name) party_account = get_party_account("Customer", ref_doc.get("customer"), ref_doc.company) party_account_currency = get_account_currency(party_account) debit_in_account_currency = 0.0 if party_account_currency == ref_doc.company_currency: amount = flt(flt(self.grand_total) * \ flt(ref_doc.conversion_rate, ref_doc.precision("conversion_rate")), \ ref_doc.precision("base_grand_total")) if self.currency != ref_doc.company_currency: debit_in_account_currency = self.grand_total else: amount = debit_in_account_currency = self.grand_total if self.reference_doctype == "Sales Order": jv = get_payment_entry_against_order( self.reference_doctype, self.reference_name, amount=amount, debit_in_account_currency=debit_in_account_currency, journal_entry=True, bank_account=self.payment_account) if self.reference_doctype == "Sales Invoice": jv = get_payment_entry_against_invoice( self.reference_doctype, self.reference_name, amount=amount, debit_in_account_currency=debit_in_account_currency, journal_entry=True, bank_account=self.payment_account) jv.update({"voucher_type": "Journal Entry", "posting_date": nowdate()}) jv.insert(ignore_permissions=True) jv.submit() #set status as paid for Payment Request frappe.db.set_value(self.doctype, self.name, "status", "Paid") return jv
def create_journal_entry_against_si(recived_payment): item = [] for i in recived_payment['Line'][0]['LineEx']['any']: item.append(i.get('value')) LineEx = item Payment_Id = recived_payment['Id'] TotalAmt = recived_payment['TotalAmt'] Transaction_date=recived_payment['TxnDate'] Amount = recived_payment['Line'][0]['Amount'] Customer_reference = recived_payment['CustomerRef'] Type = recived_payment['Line'][0]['LinkedTxn'][0]['TxnType'] reference_qb_bank_account_id = recived_payment['DepositToAccountRef']['value'] if recived_payment.get('DepositToAccountRef') else None reference_quickbooks_invoce_id = recived_payment['Line'][0]['LinkedTxn'][0]['TxnId'] qb_journal_entry_id = '' if Payment_Id: qb_journal_entry_id = "SI" + Payment_Id sales_invoice_name = frappe.db.get_value("Sales Invoice", {"quickbooks_invoce_id": reference_quickbooks_invoce_id}, "name") qb_account_name = frappe.db.get_value("Account", {"quickbooks_account_id": reference_qb_bank_account_id}, "name") try: if not frappe.db.get_value("Journal Entry", {"quickbooks_journal_entry_id": qb_journal_entry_id}, "name"): if Type == "Invoice" and sales_invoice_name: si_je = get_payment_entry_against_invoice("Sales Invoice", sales_invoice_name, amount=None, debit_in_account_currency=None, journal_entry=False, bank_account=qb_account_name) si_je = frappe.get_doc(si_je) si_je.quickbooks_journal_entry_id = qb_journal_entry_id si_je.naming_series = "SI-JV-Quickbooks-" si_je.cheque_no ="check no" si_je.cheque_date =Transaction_date si_je.posting_date = Transaction_date si_je.save() si_je.submit() frappe.db.commit() else: raise _("No Sales Invoice present ") except Exception, e: if e.args[0] and e.args[0].startswith("402"): raise e else: make_quickbooks_log(title=e.message, status="Error", method="create_journal_entry_against_si", message=frappe.get_traceback(), request_data=recived_payment, exception=True)
def create_journal_entry_against_pi(made_payment): Transaction_date = made_payment['TxnDate'] Supplier_Ref = made_payment['VendorRef'] CurrencyRef = made_payment['CurrencyRef'] Deposit_To_AccountRef = made_payment.get('CheckPayment') Amount = made_payment.get('Line')[0]['Amount'] if made_payment['Line'] else made_payment['TotalAmt'] Type = made_payment['PayType'] reference_quickbooks_PI_id = made_payment.get('Line')[0]['LinkedTxn'][0]['TxnId'] if made_payment['Line'] else '' Bill_Payment_Id = made_payment['Id'] reference_qb_bank_account_id = made_payment.get('CheckPayment').get('BankAccountRef').get('value') if made_payment.get('CheckPayment') else None qb_journal_entry_id = '' if Bill_Payment_Id: qb_journal_entry_id = "PI" + Bill_Payment_Id purchase_invoice_name = frappe.db.get_value("Purchase Invoice", {"quickbooks_purchase_invoice_id": reference_quickbooks_PI_id}, "name") qb_account_name = frappe.db.get_value("Account", {"quickbooks_account_id": reference_qb_bank_account_id}, "name") try: if not frappe.db.get_value("Journal Entry", {"quickbooks_journal_entry_id": qb_journal_entry_id}, "name"): if Type == "Check" and purchase_invoice_name: pi_je = get_payment_entry_against_invoice("Purchase Invoice", purchase_invoice_name, amount=None, debit_in_account_currency=None, journal_entry=False, bank_account=qb_account_name) pi_je = frappe.get_doc(pi_je) pi_je.quickbooks_journal_entry_id = qb_journal_entry_id pi_je.naming_series = "PI-JV-Quickbooks-" pi_je.cheque_no ="Check no" pi_je.cheque_date =Transaction_date pi_je.posting_date = Transaction_date pi_je.save() pi_je.submit() frappe.db.commit() else: raise _("No Purchase Invoice present") except Exception, e: if e.args[0] and e.args[0].startswith("402"): raise e else: make_quickbooks_log(title=e.message, status="Error", method="create_journal_entry_against_pi", message=frappe.get_traceback(), request_data=made_payment, exception=True)
def reorder_stock(item_code): mr = make_material_request(item_code) po = make_purchase_order(mr.name) po.supplier = random.choice(SUPPLIERS) po.transaction_date = frappe.flags.current_date po.insert() po.submit() pr = make_purchase_receipt(po.name) pr.set_posting_time = True pr.posting_date = frappe.flags.current_date pr.insert() pr.submit() pi = make_purchase_invoice(pr.name) pi.set_posting_time = True pi.posting_date = frappe.flags.current_date pi.insert() pi.submit() pe = frappe.new_doc("Journal Entry") pe.update(get_payment_entry_against_invoice("Purchase Invoice", pi.name)) pe.posting_date = frappe.flags.current_date pe.voucher_type = "Cash Entry" pe.insert() pe.submit()
def make_payment_entries(ref_doctype, 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])) # make Payment Entry for inv in outstanding_invoices[:random.randint(1, 2)]: pe = get_payment_entry(ref_doctype, inv) pe.posting_date = frappe.flags.current_date pe.reference_no = random_string(6) pe.reference_date = frappe.flags.current_date pe.insert() pe.submit() frappe.db.commit() outstanding_invoices.remove(inv) # make payment via JV for inv in outstanding_invoices[:1]: jv = frappe.get_doc(get_payment_entry_against_invoice(ref_doctype, inv)) jv.posting_date = frappe.flags.current_date jv.cheque_no = random_string(6) jv.cheque_date = frappe.flags.current_date jv.insert() jv.submit() frappe.db.commit()
def work(): frappe.set_user(frappe.db.get_global('demo_accounts_user')) if random.random() < 0.5: from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice report = "Ordered Items to be Billed" for so in list( set([ r[0] for r in query_report.run(report)["result"] if r[0] != "Total" ]))[:random.randint(1, 5)]: si = frappe.get_doc(make_sales_invoice(so)) si.posting_date = frappe.flags.current_date for d in si.get("items"): if not d.income_account: d.income_account = "Sales - {}".format( frappe.db.get_value('Company', si.company, 'abbr')) si.insert() si.submit() frappe.db.commit() if random.random() < 0.5: from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice report = "Received Items to be Billed" for pr in list( set([ r[0] for r in query_report.run(report)["result"] if r[0] != "Total" ]))[:random.randint(1, 5)]: pi = frappe.get_doc(make_purchase_invoice(pr)) pi.posting_date = frappe.flags.current_date pi.bill_no = random_string(6) pi.insert() pi.submit() frappe.db.commit() from erpnext.accounts.doctype.journal_entry.journal_entry import get_payment_entry_against_invoice if random.random() < 0.5: report = "Accounts Receivable" for si in list( set([ r[3] for r in query_report.run( report, {"report_date": frappe.flags.current_date}) ["result"] if r[2] == "Sales Invoice" ]))[:random.randint(1, 5)]: jv = frappe.get_doc( get_payment_entry_against_invoice("Sales Invoice", si)) jv.posting_date = frappe.flags.current_date jv.cheque_no = random_string(6) jv.cheque_date = frappe.flags.current_date jv.insert() jv.submit() frappe.db.commit() if random.random() < 0.5: report = "Accounts Payable" for pi in list( set([ r[3] for r in query_report.run( report, {"report_date": frappe.flags.current_date}) ["result"] if r[2] == "Purchase Invoice" ]))[:random.randint(1, 5)]: jv = frappe.get_doc( get_payment_entry_against_invoice("Purchase Invoice", pi)) jv.posting_date = frappe.flags.current_date jv.cheque_no = random_string(6) jv.cheque_date = frappe.flags.current_date jv.insert() jv.submit() frappe.db.commit()