Bug discount and total price PrestaShop - prestashop-1.6

I have a PrestaShop 1.6.1.1 connected with an ERP.
Recently, we have a customer with a specific group (with -5% discount) on all products. At his last order, discount did not work ...
So, I did lot of tests. I duplicate his account then did order process and discounts works perfectly. Sometimes, when I go on product-list, discounts not showing, if I press F5 (refresh), they appear ...
Is there anyone know where is the problem?
Cache problem?
If yes, how to resolve it?
Another problem, sometimes, there are price difference of 0,01€ between PrestShop and ERP or when I check order email, and when I make the sum of product prices, not the same than total.
For example, prestashop will show 237,67€ instead of 237,66€
Screenshot of price difference here
My configuration of prestashop :
• Round mode : Round up away from zero, when it is half way there (recommended)
• Round type : Round on the total
• Number of decimals. : 2
Thanks for your replies !

To work regularly on ERP / Prestashop laissezons, the worries of reductions can come:
- the cover
- a refreshment in the courtyard
- a hook that triggers a call in WS without conclusive answers
For the worry of rounding, this may come from the truncation method between PS and the ERP example:
Net price: 198.058333
Price includes VAT: 236.67 (incl. 20% tax)
Calculation: Price excl. VAT * 1.2 = Price incl. VAT
But with truncation at the time of import:
Price excluding VAT: 198.058333 becomes 198.05 exc. VAT
Therefore Price Tax incl.: 237.66 (VAT 20%)
Calculation: Price excl. VAT * 1.2 = Price incl. VAT
Regards

Related

How to find balance stock cost of SKU based on received date?

Above is an example of data in Google Sheets. The green table is to keep track my purchases and the red table is to show the inventory summary.
I am stuck at creating a formula to calculate the Balance Stock Cost.
The Balance Stock Cost should only sum up the cost of unsold quantity from latest received date.
For example, for SKU A, the stock balance is 31 units. The purchases of SKU A sorted by received date will become like this...
Since the stock balance is 31, the formula should sum up the purchases on 10-Jan (5 units x 6), 7-Jan (25 units x 4) and 5-Jan (1 unit x 5.5) which brings the total to 135.5.
Please help me to come up a formula to calculate the Balance Stock Cost based on above requirements. Thanks.
You can try:
=MAP(A18:A,D18:D,LAMBDA(ax,dx,IF(ax="",,SUM(QUERY(SORT(ARRAYFORMULA(split(flatten(A2:A15&"|"&B2:B15&"|"&D2:D15&"|"&MAP(C2:C15,LAMBDA(cx,TRANSPOSE(SEQUENCE(cx,1,1,0))))),"|",0,0)),1,1,2,0),"Select Col3 Where Col4 is NOT NULL AND Col1='"&ax&"' LIMIT "&dx)))))

Zero Currency (Euro) defined field tested for 0 not recognised as 0

I have a table of invoices with Invoice Amount HT, TVA, and Invoice Amount TTC all defined as Currency, Euro, decimal place auto. I assumed that being defined as Currency, Euro, there could only be 2dp. However, although all these amounts are displayed in the table as 2dp, if I click on the field it shows in some cases as more than 2dp. So, for example, looking at the table datasheet view, I have an invoice with Amount HT of €550.32, TVA of €110.06 and Amount TTC of €660.38 which all looks fine. But if I select these fields I notice that the TVA field shows as 110.064 and the Amount TTC shows as 660.384. When a payment is received it is added to the Amount Paid field (also defined as Currency Euro), and the Balance field (also defined as Currency Euro) is calculated as Amount TTC - Amount Paid. If the Balance is 0, I set the Completed Date to the date of the payment. The problem is that with this case it didn't recognise the Balance as 0 because it treated it as 0.004. This causes the case to be omitted from my Completed Sales Report. When TVA is to be added, it is calculated as Amount HT*0.2 (the TVA Rate). It is this calculation that is creating the problem.
Is there a way of avoiding this please?

How to sum amount for each group of account number using BI publisher add in words

I have summary pay app, and it has multiple cost codes and I need to sum up the amount charged for each account code
see example:
Cost code1 123-458-111
Line 1 2000
Line 2 1000
Cost code2 222-123-222
Line 3 3000
Cost code3 123-458-121
Line 4 1500
Line 5 2500
I need to print the result as follow
Cost code1 123-458-111 3000
Cost code2 222-123-222 3000
Cost code3 123-458-121 4000
I have tried this code but it does not give me the correct result, it just looks to the first line.
*for-each BI_ITEM_1 BITEMID_1 <?sum (UGENTTLCMPTODATECA_1[.!=''] )?> end*
BI_Item_1 = account number name.
BI_ItemID_1 = account actual number.
UGENTTLCMPTODATECA_1 = total completed to date (the amount charged to the account number )
For each is for the data set and its grouped by BI_Item_1
Any suggestion? Your help is much appreciated.
I understand pictures make it easier to visualize but I'm not allowed to upload picture to the post yet! which is weird.

InfluxDB: Starting cumulative_sum() from zero / aggregate grouping required for cumulative_sum and non_negative_difference

Using InfluxDB, I'm trying produce an output that shows cumulative rainfall for a time period, that starts from zero.
The rainfall sensor outputs a cumulative rainfall amount, but resets to zero on power-failure, restart etc.
My first query component uses non_negative_difference() to show the increments.
select
non_negative_difference(rain) as nnd
FROM
weather
WHERE
$time_query
.... yields an increment per raw data point, for example:
2018-06-01T14:21:00.926Z 0
2018-06-01T14:22:02.959Z 0.30000000000000426
2018-06-01T14:23:04.992Z 0.3999999999999986
2018-06-01T14:24:07.024Z 0.10000000000000142
2018-06-01T14:25:09.059Z 0.19999999999999574
2018-06-01T14:26:11.094Z 0
2018-06-01T14:27:13.127Z 0.10000000000000142
2018-06-01T14:28:15.158Z 0.20000000000000284
2018-06-01T14:29:20.027Z 0.09999999999999432
2018-06-01T14:30:22.476Z 0.10000000000000142
2018-06-01T14:30:53.918Z 0.6000000000000014
2018-06-01T14:31:55.968Z 0.5
2018-06-01T14:32:58.007Z 0.5
2018-06-01T14:34:00.046Z 0.20000000000000284
2018-06-01T14:35:02.075Z 0.3999999999999986
2018-06-01T14:36:04.102Z 0.3999999999999986
2018-06-01T14:37:06.136Z 0.20000000000000284
2018-06-01T14:38:08.201Z 0
So far so good.
I'm now trying to stitch these readings back to cumulative total, starting from zero for the intended period.
I can use cumulative_sum() for this, for example:
SELECT
cumulative_sum(nnd)
FROM
(SELECT
non_negative_difference(rain) as nnd
FROM
weather
WHERE
$time_query )
which yields:
2018-06-01T14:21:00.926Z 0
2018-06-01T14:22:02.959Z 0.30000000000000426
2018-06-01T14:23:04.992Z 0.7000000000000028
2018-06-01T14:24:07.024Z 0.8000000000000043
2018-06-01T14:25:09.059Z 1
2018-06-01T14:26:11.094Z 1
2018-06-01T14:27:13.127Z 1.1000000000000014
2018-06-01T14:28:15.158Z 1.3000000000000043
2018-06-01T14:29:20.027Z 1.3999999999999986
2018-06-01T14:30:22.476Z 1.5
2018-06-01T14:30:53.918Z 2.1000000000000014
2018-06-01T14:31:55.968Z 2.6000000000000014
2018-06-01T14:32:58.007Z 3.1000000000000014
2018-06-01T14:34:00.046Z 3.3000000000000043
2018-06-01T14:35:02.075Z 3.700000000000003
2018-06-01T14:36:04.102Z 4.100000000000001
2018-06-01T14:37:06.136Z 4.300000000000004
2018-06-01T14:38:08.201Z 4.300000000000004
Looking good!
Now I'd like to group it up into more distinct time buckets, for nice graphing.
Let's try....
SELECT
cumulative_sum(max(nnd))
FROM (SELECT
non_negative_difference(rain) as nnd
FROM
weather
WHERE
$time_query)
GROUP BY
time(5m)
and I get an error: ERR: aggregate function required inside the call to non_negative_difference
But I cannot find a reasonable way of adding aggregates and groupings to non_negative_difference() that do not affect the accuracy of the differencing function itself.
The only thing I've been able to do is a dummy aggregate SUM() over time groups that are smaller than the sensor period. But this isn't robust enough for my liking - (and i'm still not sure it is 100% correct)
Is it correct that I must have both queries as aggregate queries?
I was trying to do this very thing for my weather station. Instead of having the weather station calculate the cumulative value I wanted Grafana to do it. The solution that worked for me is the advanced syntax Yuri Lachin mentions in his comments.
With InfluxDB you can use CUMULATIVE_SUM(), but the basic syntax doesn't allow you to group by time (only by tag). The "advanced syntax", however, allows you to to have a time series by nesting an aggregate function like MEAN() or SUM().
Here's the function I am using in Grafana to get a cumulative rainfall total for a selected time period:
SELECT CUMULATIVE_SUM(MEAN("rainfall")) FROM "weather" WHERE $timeFilter GROUP BY time(1h) fill(0).
The GROUP BY is, of course, flexible. I was interested in hourly rainfall so I grouped by 1h. You can group by the time period you find most interesting.
Using this query the rainfall will start from zero for period you select in Grafana. In the Seattle area we had measurable rain (I know, shocker) on 8/6/2020 and 8/8/2020. If I set my date range to include both dates the graph shows just under .2mm total rainfall:
If I switch my graph to 8/8 and 8/9 the total is just under 1mm:
Note: I was also interested in seeing the individual bucket tips so included those as bars on the second Y-axis.
For more detail see: https://docs.influxdata.com/influxdb/v1.8/query_language/functions/#advanced-syntax-7

Prestashop 1.6 Product Showing wrong price combination when using specific price discount

How to repeat:
install prestashop 1.6.1.4
create a product JEANS - Wholesale price 53.87, Retail price 74.82 (Allow orders When out of stock, No Tax)
add specific price discount of 28% to JEANS
add product combinations - in my case I want the client to choose a size and a color: Size - 29W x 30L, Color - Bleach Fade and Size - 29W x 30L, Color - Buff, both with a Wholesale price: 29.9, and Impact on price - Decrease 33.29
result:
when I go to product page, if I choose the first combination
Size - 29W x 30L, Color - Bleach Fade I get the price 29.9, which is what I expect.
BUT when I choose the second option
Size - 29W x 30L, Color - Buff I get price $53.87 instead of the 29.9 I expected.
NOTE: when I add the product to the cart then it calculate the correct price (29.9) for both combination - thus this bug is only in the product display
How can I fix this?
I assume this is a bug in the code so any code fix will be welcome.
Background:
I'm upgrading my site from PrestaShop™ 1.4.5.1 to 1.6.1.4, I have a complicated site with a lot of proprietary code, however this scenario is not reproducible in the 1.4.5.1, i.e. repeating the same steps result with a correct price (29.9) in the second product.
Note: this is a minimized version of the bug, in a real product I have more combinations, some with the real '74.82' price.
Apply this fix to correct the problem:
https://github.com/PrestaShop/PrestaShop/commit/56fe9925c2703ba07d13b6ba56a92494d38ba45e
replace the file in this fix with your prestashop installation
Note: if you are not using the default theme than copy the new tpl to your theme folder.

Resources