1. balage
  2. RO CSVI
  3. Thursday, 07 February 2019
  4.  Subscribe via email
Hi,

I want to import products that have a fixed amount of discount. For that i found the product_discount and product_discount_id fields to use.
I'm already using the product_discount_id field to make fix no calculation rule to the products that don't have any discounts. I have also figured out that if both fields are present, the product_discount field will only be used if product_discount>0 else product_discount_id is used. It imports the discounts with one caveat. The calculation rule is being created as a price modifier before tax. Which is not good for me. Is there a way to change this default behavior so that it creates the rule as price modifier after tax?

There are 1000s of product and much of them have discounts, almost all of them are different and changing daily, so manual managing of rules is not an option.

Thank you for any help you or anyone can give me.
Accepted Answer Pending Moderation
Hello,
"If there is product_tax_id, the whole process of calc rule creation is ignored as with product_tax_id field you are assigning the already created calc rule."
Than there is no point of going forward because it means that no matter what we do here, there is no way that we can update a product and also in the same run add a discount to it with a specific value that will be applied to the cost price after tax.

What i meant here is when you assign a value to product_tax_id field, CSVI will not create any new rule because the value here is the id of calc rule already created for product_tax field.

you have a product with price_with_tax of 1154.9 (blue), and tax of 20%. We gave in the product_discount field a discount of 120 (green). So it is listed on the detail page as a discount. And it has been created by the importer as DBTax. But because this 120 is DBTax the end price is: 1010.9 (red). Which is not a 120 discount but a 144! This is due to the DBTax. If it was a DATax (and it would be created as DATax, or it could use the pre-created rule 120 rule as DATax) it would be good. It would calculate correctly and it would be displayed correctly on the page. In this case the customer is misinformed because he doesn't get 120 discount but 144, which is not good. The 120 here is represented as price without tax and the customer really doesn't care what the numbers are without taxes because in every case he is paying the with tax price.

Did i missed something or is there another option? Maybe some weird field that we need to put in to force the rule creation to go DATax.

Maybe a different set of fields?

Thank you for your explanation. It helped us to find the issue that even when the calc_kind is set, the rule is always created as DBTax. Please load the attached file and run the import again. You can try your import with these fields price_with_tax, product_tax_id, product_discount, calc_kind. Let me know if it solves your issue.

patch_vm_2019_02_13.zip
Attachments (1)
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 1
Accepted Answer Pending Moderation
Hello,
I'm already using the product_discount_id field to make fix no calculation rule to the products that don't have any discounts. I have also figured out that if both fields are present, the product_discount field will only be used if product_discount>0 else product_discount_id is used.

Thats correct.

The calculation rule is being created as a price modifier before tax. Which is not good for me. Is there a way to change this default behavior so that it creates the rule as price modifier after tax?

Just want to confirm on this, are you saying calculation rule has been applied to the price before tax and not on price after tax? Can you also post your import debug log and sample of your import file to check?
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 2
Accepted Answer Pending Moderation
The import debug log you can find here:
com_csvi.log.111.zip

I was importing this csv:
products.csv

after import, this rule was created:
tax_rule_admin.png

As you can see it has created the rule as DBTax and i need DATax. That is the only thing that would be good to change.
We need the after tax modifier because the customers doesn't really care what the prices are before tax applied, because they have to pay incl. Tax anyway.
Technically it would work with before tax as well but then it would create all sorts of problems with the rule names being any kind of float numbers and such.

I also tried to do a separate csv in which i pre-created the rules and imported them before the products themselves. I used this csv:
products_calc.csv
But it doesn't work either. Because although the calc.csv creates the rules perfectly, when the product is imported with the desired product_discount, the importer doesn't find the pre-created rule and creates a new one with DBTax.

the import of the calc and the products csv this debug was created:
com_csvi.log.115.zip
after you can see this in the admin:
tax_rule_admin2.png
which shows that during import it didn't find the rule and therefore created a new one.
Attachments (6)
  1. more than a month ago
  2. RO CSVI
  3. # 3
Accepted Answer Pending Moderation
Hello,
As you can see it has created the rule as DBTax and i need DATax. That is the only thing that would be good to change.
We need the after tax modifier because the customers doesn't really care what the prices are before tax applied, because they have to pay incl. Tax anyway.
Technically it would work with before tax as well but then it would create all sorts of problems with the rule names being any kind of float numbers and such.

The DBTax is the default name given for the calculation rule if you don't have the calc_kind field set in your import file. Since that field is missing CSVI is creating a calculation rule with default name. Can you add this field and try import again?

But it doesn't work either. Because although the calc.csv creates the rules perfectly, when the product is imported with the desired product_discount, the importer doesn't find the pre-created rule and creates a new one with DBTax.

If you want to assign a calculation rule which has been already created, you need to use product_tax_id field in import file. CSVI cannot find the calculation rule by product_discount field value.
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 4
Accepted Answer Pending Moderation
H, Thank you for the suggestions.

I tried it out. I added the calc_kind field. The only thing it did, that it created the product_tax value as a normal rule with the set calc_kind. Which is not good. Because in this case the product didn't had any taxes assigned. This means that the calc_kind field somehow only works with taxes and not discounts. So i tried to remove the product_tax from the equation. For that i used the product_tax_id field. I can use this field because i know the value of this field and this is a constant value which never changes.
import log after all of the above modification:
com_csvi.log.122.zip
used this csv:
products.csv
The created rule:
pic01.png

The created rule is still DBTax which says to me that the calc_kind field is only considered if product_tax field is present. If there is only product_tax_id, it is ignored.
Attachments (3)
  1. more than a month ago
  2. RO CSVI
  3. # 5
Accepted Answer Pending Moderation
Hello,
I tried it out. I added the calc_kind field. The only thing it did, that it created the product_tax value as a normal rule with the set calc_kind. Which is not good. Because in this case the product didn't had any taxes assigned.

When there is product_tax field a calc rule is created using this field and when there is product_discount field a rule will be created using product_discount. As per the import debug log you have product_discount field and so a new calc rule for discount has been created. I don't see any new rule created for product_tax in the debug log.

This means that the calc_kind field somehow only works with taxes and not discounts.

VirtueMart stores only the base price and does not store prices with discount or with tax. With import of product_discount field a new calc rule is created and assigned to product_discount_id and is stored for a price. VirtueMart will apply the discount using the stored product_discount_id. Do you see the discount applied for prices on frontend or not?

So i tried to remove the product_tax from the equation. For that i used the product_tax_id field. I can use this field because i know the value of this field and this is a constant value which never changes.
import log after all of the above modification:

Yes when you use product_tax_id field, CSVI will load the calc rule and calculates the base price using product_tax_id and price_with_tax field.
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 6
Accepted Answer Pending Moderation
Hi,

The log and the csv was after i tested that it doesn't work when i only add the calc_kind to the mix. I didn't include that import because it was meaningless and just messed the import up more than it should have. But if you like i can recreate it and post it...
This was the last try of the import where i changed product_tax to product_tax_id and left the product_discount and calc_kind fields. I assumed that in this case the discount rule is created using the the calc_kind value but it doesn't. The product_tax_id is assigned perfectly but because there is no product_tax field this time the calc_kind field is ignored completely, which means that it is only considered by a tax calculation rule creation.
  1. more than a month ago
  2. RO CSVI
  3. # 7
Accepted Answer Pending Moderation
Hello,
The log and the csv was after i tested that it doesn't work when i only add the calc_kind to the mix. I didn't include that import because it was meaningless and just messed the import up more than it should have. But if you like i can recreate it and post it...

Please post the import file used with explanation to the issue. I will try to reproduce the error in my local site.

This was the last try of the import where i changed product_tax to product_tax_id and left the product_discount and calc_kind fields. I assumed that in this case the discount rule is created using the the calc_kind value but it doesn't.

I guess there was already a calc rule with name DBTax and calc_value as 120, the last debug log says that this calc rule has been updated.

The product_tax_id is assigned perfectly but because there is no product_tax field this time the calc_kind field is ignored completely, which means that it is only considered by a tax calculation rule creation.

Thats correct. If there is product_tax_id, the whole process of calc rule creation is ignored as with product_tax_id field you are assigning the already created calc rule.
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 8
Accepted Answer Pending Moderation
Hi,

if this is true what you wrote:
"If there is product_tax_id, the whole process of calc rule creation is ignored as with product_tax_id field you are assigning the already created calc rule."
Than there is no point of going forward because it means that no matter what we do here, there is no way that we can update a product and also in the same run add a discount to it with a specific value that will be applied to the cost price after tax.

I can only see two options remaining here:
1. pre-create rules and use product_discount_id.
2. use the default rule creation method with product_discount (because here the default calc_kind can't be changed) and use DBTax.

The first one is not really an automation method because the prices of the products change, 1000/day. Each of them has different discounts and to manually create the csv-s adding each pre-created discount_id-s is not even a solution to this.

The second one could be good, but here we have the problem of weird discounts and also there is no option (as far as i know) to display the concrete discount on the product detail page as with Tax. This is what i mean:
pic.png
you have a product with price_with_tax of 1154.9 (blue), and tax of 20%. We gave in the product_discount field a discount of 120 (green). So it is listed on the detail page as a discount. And it has been created by the importer as DBTax. But because this 120 is DBTax the end price is: 1010.9 (red). Which is not a 120 discount but a 144! This is due to the DBTax. If it was a DATax (and it would be created as DATax, or it could use the pre-created rule 120 rule as DATax) it would be good. It would calculate correctly and it would be displayed correctly on the page. In this case the customer is misinformed because he doesn't get 120 discount but 144, which is not good. The 120 here is represented as price without tax and the customer really doesn't care what the numbers are without taxes because in every case he is paying the with tax price.

Did i missed something or is there another option? Maybe some weird field that we need to put in to force the rule creation to go DATax.

Maybe a different set of fields?
So far it didn't work:
price_with_tax, product_tax, product_discount, product_discount_id -> result: tax added, discount created as DBTax
price_with_tax, product_tax, product_discount, product_discount_id, calc_kind -> result: no tax added, normal rule created with tax value as DBTax and added as normal calc rule
price_with_tax, product_tax_id, product_discount, product_discount_id, calc_kind -> result: tax added, discount_created as DBTax although calc_kind was as DATax.
Attachments (1)
  1. more than a month ago
  2. RO CSVI
  3. # 9
Accepted Answer Pending Moderation
Hi,

Super. It works perfectly. Just what i wanted.
Just to summarize, i use now these fields:
price_with_tax, product_tax_id, product_discount, product_discount_id, calc_kind.
With this set of fields, the product tax is correctly set. If product_discount=0 then product_discount_id is used to set apply no rule function. If product_discount>0 then rule created with the value of product_discount and type of the calc_kind field. If a rule with that value already exists than it is assigned correctly. Now the values are showing correctly on the site:
picc.png

Thank you very much for the help.

Kind regards
Balage
Attachments (1)
  1. more than a month ago
  2. RO CSVI
  3. # 10
Accepted Answer Pending Moderation
Hello Balage,
Glad to know that your issue is solved. Please leave us a review on Joomla Extension Directory.
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 11
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!