Tuesday, October 22, 2013

Magento Correcting the default taxing module for calculating tax based on discounted price

Hello,

Lets assume your client has a requirement of calculating tax based only on the discounted price.

Like,
The price of the item with tax is 100
Discount on this item with tax is 25
The remaining amount with tax is 75

If I consider 14% as tax then the tax should be shown as 9.21 and this is already part of 75. So if I subtract 9.21 from 75 then I will get 65.78, if I calculate 14% of 65.78 then I will get 9.21 to be exact.

In Magento this seems to be difficult to achieve by default configurations as if you enter item price without tax and discount is entered or calculated with tax.

I have checked it is not possible without a custom module.

Unfortunately cannot paste the entire module here but here are few pointers for resolving such issue.

  1. Main change we need to make is in the Quote Taxing module which is responsible for all the configuration based tax calculations, like in my case I was using unit based taxing so we have switch case which needed to be edited. This is the module which will return the actual tax amount so by changing it we are making the core change for recalculating the tax.
  2. Because of the above change we have our grand total all messed up, which needed to be corrected in Quote/address/grand file.
  3. Above 2 file will ensure that the new way of calculating tax has been enforced on frontend, but back end still needed to be changed
  4. The way Magento calculates row totals is, it adds the base price with the tax amount and hence we get row totals, but if the tax is based on the discounted price then adding it to the product price will give an incorrect result, fortunately this happens only at adminhtml template level, so as it being cosmetic change only we need to change the order, invoice view and create templates.
  5. Also we need to change the invoice subtotal calculation file as the final calculations is effected as I explained earlier.
If all the above changes are in place properly then the desired change will be achieved, I have tested and developed this module.

Thanx
Anshumaan Bakshi

Import MySql DB through command prompt on WAMP

Hello,

If we have a very large file to import on WAMP and PHPMyAdmin is dying due to various reasons then you can import the big file using CLI or through Dos

Follow the following steps.
  1. Run cmd command
  2. Assuming you have installed wamp on C: drive.
  3. C:>cd wamp
  4. C:\wamp>cd bin
  5. C:\wamp\bin>cd mysql
  6. C:\wamp\bin\mysql>cd mysql15.5.8
  7. C:\wamp\bin\mysql\mysql15.5.8>cd bin
  8. C:\wamp\bin\mysql\mysql15.5.8\bin>mysql.exe -u root -p dbname < sqlDump.sql
  9. Now we need to have the sqlDump.sql file inside C:\wamp\bin\mysql\mysql15.5.8\bin\ for direct execution of this command.
  10. If everything is fine, then this command will ask for the mysql password for username root and it should start importing the file on the mysql database.

Now what we are doing here is we are moving to WAMP's bin directory to locate the mysql.exe file. This command file is similar to the one we have on Linux and it behave s the same way, so we provide the information like username db and import sql file and it can easily be imported in our db.

Please note: We can also use direct path from any location as soon as we come to cmd like C:\wamp\bin\mysql\mysql15.5.8\bin\mysql.exe -u root dbname < sqlDump.sql
but need to be sure of the path which is hard to locate.

Thanx
Anshumaan Bakshi