def invoice_appointment(appointment_doc): if not appointment_doc.name: return False sales_invoice = frappe.new_doc("Sales Invoice") sales_invoice.customer = frappe.get_value("Patient", appointment_doc.patient, "customer") sales_invoice.appointment = appointment_doc.name sales_invoice.due_date = getdate() sales_invoice.is_pos = True sales_invoice.company = appointment_doc.company sales_invoice.debit_to = get_receivable_account(appointment_doc.company) item_line = sales_invoice.append("items") service_item, practitioner_charge = service_item_and_practitioner_charge(appointment_doc) item_line.item_code = service_item item_line.description = "Consulting Charges: " + appointment_doc.practitioner item_line.income_account = get_income_account(appointment_doc.practitioner, appointment_doc.company) item_line.rate = practitioner_charge item_line.amount = practitioner_charge item_line.qty = 1 item_line.reference_dt = "Patient Appointment" item_line.reference_dn = appointment_doc.name payments_line = sales_invoice.append("payments") payments_line.mode_of_payment = appointment_doc.mode_of_payment payments_line.amount = appointment_doc.paid_amount sales_invoice.set_missing_values(for_validate = True) sales_invoice.save(ignore_permissions=True) sales_invoice.submit() frappe.msgprint(_("Sales Invoice {0} created as paid".format(sales_invoice.name)), alert=True)
def invoice_appointment(appointment_doc): if not appointment_doc.name: return False sales_invoice = frappe.new_doc("Sales Invoice") sales_invoice.customer = frappe.get_value("Patient", appointment_doc.patient, "customer") sales_invoice.appointment = appointment_doc.name sales_invoice.due_date = getdate() sales_invoice.is_pos = True sales_invoice.company = appointment_doc.company sales_invoice.debit_to = get_receivable_account(appointment_doc.company) item_line = sales_invoice.append("items") service_item, practitioner_charge = service_item_and_practitioner_charge(appointment_doc) item_line.item_code = service_item item_line.description = "Consulting Charges: " + appointment_doc.practitioner item_line.income_account = get_income_account(appointment_doc.practitioner, appointment_doc.company) item_line.rate = practitioner_charge item_line.amount = practitioner_charge item_line.qty = 1 item_line.reference_dt = "Patient Appointment" item_line.reference_dn = appointment_doc.name payments_line = sales_invoice.append("payments") payments_line.mode_of_payment = appointment_doc.mode_of_payment payments_line.amount = appointment_doc.paid_amount sales_invoice.set_missing_values(for_validate = True) sales_invoice.save(ignore_permissions=True) sales_invoice.submit() frappe.msgprint(_("Sales Invoice {0} created as paid".format(sales_invoice.name)), alert=True)