Navigate to the Frappe Bench directory using the terminal.
Run the following command to create a new app
bench new-app <app_name>
# Within custom app directory, locate the custom_app folder.(qoala/crud_events.py)
# Created a new Python file for custom function, e.g., crud_events.py
# Defined custom function within this file e.g., generate_batch_wise_sales_invoice
# This function will create and submit the Batch-wise sales invoices from a third party App with a unique identifier.
# If any of the invoice failed while submitting. All of the invoices group by unique identifier will revert back to Draft State
NB: Based on the frappe frame work design we cannot revert back to sumitted invoice without cancel & Amend. So here if any of the invoices from the same batch failed.
it will automatically cancel and amend to draft states. But after cancelling the documentb it will create a new series from the reference series.
for eg., if the invoice is cancelled with the series 001. then if we amended from 001 it will create new series like 001-1.
so we will not lost any series. As per tax law this series can be accepted.
2) Custom field addition in the ERPNext invoice doctype.
# Added custom fields for unique identifier, is_rolled_back, custom_default_price_list
# Added custom field via Customize Form Doctype. Exported those fields to Qoala App
# So if we install this app to any erpnext instance no need to create these fields again it will sync when we migrate the app.
3) Cron job script.
# I used Scheduler Events for running tasks periodically in the background using the scheduler_events hook.
# It will check the custom functions that added in the path in hooks under scheduler_events every one hour.
# Here the custom function cancel_sales_invoices check for is_rolled_back Draft invoices and it will delete.
4) Error handling and logging code.
# Have included the exceptional handling in all root functions.
# Based on the framework if we trying to logging to frappe with token/user credentials it will check by itself. there is an inbuilt code for that. you can check the below reference https://frappeframework.com/docs/user/en/api/rest
By following these steps, you have successfully added a custom app and function within ERPNext, allowing for tailored functionalities to meet specific business requirements.
# Added custom fields for unique identifier, is_rolled_back, custom_default_price_list
# Added custom field via Customize Form Doctype. Exported those fields to Qoala App
# So if we install this app to any erpnext instance no need to create these fields again it will sync when we migrate the app.
3) Cron job script.
# I used Scheduler Events for running tasks periodically in the background using the scheduler_events hook.
# It will check the custom functions that added in the path in hooks under scheduler_events every one hour.
# Here the custom function cancel_sales_invoices check for is_rolled_back Draft invoices and it will delete.
4) Error handling and logging code.
# Have included the exceptional handling in all root functions.
# Based on the framework if we trying to logging to frappe with token/user credentials it will check by itself. there is an inbuilt code for that. you can check the below reference https://frappeframework.com/docs/user/en/api/rest
MIT