
I am working on a requirement where I have created custom tables to store sales order data (header and lines). A single sales order can be stored multiple times in these custom tables; therefore, the custom sales line table may contain quantities that are less than the corresponding quantities on the standard sales line table.
I need to calculate discounts, line amounts, charges, and taxes based on these partial quantities and then roll up the results to the custom header table. What would be the best approach to calculate discounts, line amounts, charges, and taxes for these quantities?
I have reviewed several options, such as using the SalesTotals class, Tax::calcTaxAmount() for calculating taxes by passing custom quantities and line amounts, and Markup::calcTrans() for calculating charges/markups. However, I am still unsure whether I am missing a simpler or more efficient approach that would ensure there are no calculation differences between my implementation and the OOTB logic, and that the results always match the standard system calculations.
Thank you for you kind response.