ERPNext makes many decisions based on our setup and master records. I want to offer an alternative way. So ERPNext can make better decisions.
I will provide three scenearios. All of them will have the same solution.
First sceneraio is when ERPNext deciding which pricing rate should apply for transactions. We have price lists, item prices, and very large pricing rule doctype. And also, taxes and charges templates modifiy the price if tax is included or not.
And we still need to create client scripts to modify the rate sometimes based on the situation.
My suggestion is creating a Server Script, with a new type like “Pricing Script”. If this script exists, ERPNext should not perform any calculation. The script should return the final rate.
We can make this solution broader. For instance, Brazil and Turkish accounting systems have different variations. We can have “Accounting Script” for that. So correct accounts can be affected for each transaction.
Putaway Rules are great. But in some conditions it requires a little bit push. So there can be “Putaway Script” type.
This is different from hooks because hooks add our customizations to source. It doesn’t alter or stop it. My suggestion is ERPNext should not do anything, if a proper script is exist. But this is only triggered when ERPNext is deciding. IE getting the rate, finding the correct accounts to affect, etc.
It may seem an aligned approach with monkey patching of the controller methods. But I sometimes need to modify the source of the ERPNext which I really hate.
My idea came from CanIAS ERP. I see a custom script panel in their Account page. So, each of their account record have an attached script.
Loge Tiger ERP system has a “Account Linking” page. So we can define each transaction with great detail (A bit like Pricing Rule) and we are connecting it to an account. So when saving a transction, it search for possible matches and made proper decision. There can be 100 of connections.
I believe that ERPNext has only a Company Page for that setup.
So, what do you think about “Deciding Scripts” in ERPNext?