When I create a sales Invoice from scheduler, its status is showing as draft. But I am submitting it from scheduler
how can solve it
The Sales Invoice has been submitted, but the status is still showing as ‘Draft’.
( Using scheduler )
def create_sales_invoice_3daysafter_submission_of_sales_order():
try:
# Log the start of the process
frappe.log_error(“Sales Invoice Process”, f"Started on {frappe.utils.getdate()}")
# Calculate the date three days ago
date_three_days_ago = frappe.utils.add_to_date(frappe.utils.getdate(), days=-3)
frappe.log_error("Debugging Date", str(date_three_days_ago))
# Fetch Sales Orders matching the criteria
sales_orders = frappe.db.get_list('Sales Order',
filters={
'per_billed': ['!=', 100],
'custom_submit_date': date_three_days_ago,
'status': ['!=', 'Cancelled'],
},
fields=['name', 'customer', 'custom_participant', 'custom_participant_name_', 'custom_contact_for_invoice', 'custom_email_for_invoice']
)
frappe.log_error("Fetched Sales Orders", str(sales_orders))
# Process each Sales Order
for so_data in sales_orders:
try:
so = frappe.get_doc('Sales Order', so_data['name'])
# Create a new Sales Invoice
invoice = frappe.new_doc('Sales Invoice')
invoice.customer = so.customer
invoice.due_date = frappe.utils.add_to_date(frappe.utils.getdate(), days=7)
invoice.custom_email_for_invoice = so.custom_email_for_invoice
invoice.custom_contact_for_invoice = so.custom_contact_for_invoice
# Insert and submit the invoice
invoice.submit()
frappe.db.commit()
frappe.log_error("Invoice Created", f"Sales Invoice {invoice.name} created for Sales Order {so.name}")
except Exception as e:
frappe.log_error("Error Creating Invoice", f"Sales Order {so_data['name']} failed: {str(e)}")
continue
except Exception as e:
frappe.log_error("Script Execution Error", str(e))
The invoice is created and submitted, but the status still shows as “Draft.”
1
…
@Govind_Gupta then it’s submitted . can you see GL entries when you click view ledger ?
do you have a custom sales invoice list js ?
No.
…