As there are different credit management requirements, it is good to add support for extendability to credit management. Currently credit management is hard coded in model class which some time make to override entire class to support custom requirements. I am proposing below design. 1. Create interface ICreditManager with method CheckCredit. This method take DocAction as argument to differentiate whether it called from PrepareIt or CompleteIt.
2. Creating interface ICreditManagerFactory with method getCreditManager accepting PO as arguments. This how credit manager factory can use any parameters of PO to decide which ICreditManager instance should be returned. Factory class can decide to use just table name or table name and isSoTrx or document type to decide ICreditManager implementors
3. Implement credit manager for MInout, Order, Invoice and Payments which perform credit check as well as update credits related parameter.
Reference thread: https://mattermost.idempiere.org/idempiere/pl/tamrfhkngbd1jmq7zuscb81fah
As there are different credit management requirements, it is good to add support for extendability to credit management. Currently credit management is hard coded in model class which some time make to override entire class to support custom requirements.
I am proposing below design.
1. Create interface ICreditManager with method CheckCredit. This method take DocAction as argument to differentiate whether it called from PrepareIt or CompleteIt.
2. Creating interface ICreditManagerFactory with method getCreditManager accepting PO as arguments. This how credit manager factory can use any parameters of PO to decide which ICreditManager instance should be returned. Factory class can decide to use just table name or table name and isSoTrx or document type to decide ICreditManager implementors
3. Implement credit manager for MInout, Order, Invoice and Payments which perform credit check as well as update credits related parameter.