Closed johnM2401 closed 3 years ago
@johnM2401 Thanks John.
Its an SQL issue that as you stated happens on separate invoices being raised with the same product items.
This would have have gotten worse over time as with each new invoice with the same product would have multiplied. i.e. 4 invoices with same product would have multiplied the real result by 4 and so on.
You can retest here on this branch.... https://github.com/ivylabs/suitecrm-analytics/tree/feature-300
@harrisward Pull request ... https://github.com/ivylabs/suitecrm-analytics/pull/304
Hey @fraserward
Looks good to me, Both Reports appear to now show the real "Total Cost" value, when products are used across multiple Line Items & Invoices
Can be merged to master.
Describe the bug When the "Total Cost" is calculated on the Agent Sales report, it appears to be calculating the Total Cost incorrectly, similar to issue #297
As far as I can tell, it appears to be doing this by calculating the Total Price, and applying it to each Product. Effectively Multiplying the Actual Total Cost by the Number of Unique Products.
This appears to only occur when the same products are spread over multiple Invoices.
For example;
I have two invoices.
Invoice 1 has:
A Line Item with: Quantity 1, Cost 5 A 2nd Line Item with: Quantity 5, Cost 1
Total Cost : 10
Invoice 2 has:
A Line Item with: Quantity 1, Cost 5 A 2nd Line Item with: Quantity 5, Cost 1
Total Cost : 10
The Cumulative Cost of the Products used in these Line Items is $20
However, the "Total Cost" value appears to come out as $40, on the Agent Sales Report ($20 * 2 Unique Products)
See Screenshots for an Example
Component What component does this bug relate to?
Solution File AgentSalesReport.prpt
To Reproduce Steps to reproduce the behavior:
Expected behavior The "Total Cost" will show an accurate running number for each Item/Invoice
Screenshots
Note:
Invoice 1:![image](https://user-images.githubusercontent.com/13675281/123416935-16983900-d5af-11eb-913c-484145abdbe0.png)
Invoice 2:![image](https://user-images.githubusercontent.com/13675281/123416949-1ac45680-d5af-11eb-9570-a1df2cd09f3d.png)
Agent Sales Report:![image](https://user-images.githubusercontent.com/13675281/123416980-21eb6480-d5af-11eb-8130-e84be229b9e4.png)
If I then create a third invoice:![image](https://user-images.githubusercontent.com/13675281/123419953-c7540780-d5b2-11eb-9a2c-a96da68f7697.png)
The Agent Sales Report shows as:![image](https://user-images.githubusercontent.com/13675281/123419932-bf946300-d5b2-11eb-9665-93a1456dda9b.png)
Where the Total Cost should actually be $30:![image](https://user-images.githubusercontent.com/13675281/123419983-d2a73300-d5b2-11eb-90cd-d6942e9defb8.png)
Desktop (please complete the following information):
Please let me know if anything needs clarified!