frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
21.78k stars 7.31k forks source link

Fixed amount taxes for Sales and Purchase #7044

Closed Tropicalrambler closed 2 years ago

Tropicalrambler commented 7 years ago

The tax table in ERPNext is quite useful. I have been operating with a workaround for a specific situation I have for some time, however I wish to set up a customization, where the Purchase Taxes and Charges table is able to access data outside of it beyond just net_total from the document. Eventually I want to merge it into the develop branch for the next version.

Parent DocTypes

Purchase Invoice

Child DocTypes The child DocTypes that have the desired data fields for this are:

Purchase Invoice Item The Purchase Taxes and Charges table

Description of desired functionality

A Purchase Invoice is created for one item that has a specific taxation scheme. VAT Tax rate: 12% Item = GAS-01 Qty = 5 Rate = $20

The Amount is thus, 5 * $20 = $100

In this situation, this item is levied a tax as a fixed amount per qty of item. This tax can be categorized as a tax expense. Let's call it tax_1_amount. Tax per Qty = $4.5

Thus, Tax per Qty Qty = tax_1_amount $4.5 5 = $22.5

tax_1_amount = $22.5

This is to be deducted from the Amount, which results in: $100 - $22.5 = $77.5 This is the remainder, and this amount is now taxable with our regular 12% VAT, which is already included in the remainder amount:

$77.5 * 12% = $9.3

Item rate without taxes: $77.5 - $9.3 = $68.2

Accounting has to register like this: $68.2 item rate as an Expense in an Expense Account "A" $9.3 VAT tax as Asset in an Asset Account $22.5 Tax_1_amount as Expense in expense account "B"

Net total still has to be $100.

Ideas

So one idea is to enable conditions and formulas in the tax table, same as with Salary Structure. This is an easy way to access hte DocType variables.

Another is to be able to specify the Purchase Invoice Item line number, so one can point to a specific qty, enabling "several" items to be in the invoice, to reflect real- life invoices

Thoughts, questions? Proposal for programming this, I am willing to sponsor!

rmehta commented 7 years ago

@Tropicalrambler this is too complicated to understand, can you simplify and explain what are the changes you want to propose

Edit: screeshots will help!

Tropicalrambler commented 7 years ago

Rushabh, you are right! We have a very complicated Tax system here.

Here's the short version:

In ERPNext, items can be configured to have taxes levied on a percentage basis as per the price of the item.

The above example is for an item whose tax is applied as per the quantity purchased. What I am asking for is to allow for the Item to also have a tax setting per quantity. This goes in the Item itself, not in the Tax Template, because it is item specific.

I also propose above that one can change taxes and charges template to be able to refer to specific lines and formulas, similar to the way that Salary Structure sheet does its calculations.

Here's the example simplified. Variables VAT Tax rate: 12% Item = GAS-01 Tax per 1 UOM = $4.5 Qty purchased = 5 Rate per 1 UOM = $20

If you buy 5 at a rate of $20, your total is $100. The Item Tax is calculated as $4.5 x 5, which equals $22.5 and is entered into the specified account for Item Tax.

From the $100 total, you deduct the $22.5, which results in $77.5. It is on this amount that the vat 12% is levied, $9.3 is entered into specified account for VAT.

The Net value, without the Item Tax and VAT Tax is: $68.2

Tropicalrambler commented 6 years ago

Showing the Code

We have written our own excise tax sub-application within our Electronic Invoice Application, given that it is required to send excise tax data for electronic invoices.

Our main repo is here And I recently found an alternative solution to this problem by @revant . kiratplastics_erpnext

But...

...two problems remain: In our tax system the excise tax is INCLUDED and is based on actual amount per stock UOM. This is a problem for the Sales Taxes and Charges table.

Our application goes through each item in the Items Child Table, finds if excise taxes are present, calcualtes the amount per row, and then adds the specified account for that excise tax for that item to the sales/purchase taxes and charges table. It does so by adding one additional row per account listed, and then if (for example) two items with same account for excise tax are found, it sums the excise tax amount for those two items and changes the tax_amount field to reflect the proper amount. This falls under the type of tax such as "Actual" in the Sales Taxes and Charges Table

The problem is that this tax should not be added to the invoice grand total, since it is already included, and you cannot have an "Actual" type with tax already included.

The solution, which we are testing, involves adding a "Actual Included" category, to the Charge Type (charge_type) field.

Will test and send Pull Request to develop.

harshit-30 commented 2 years ago

You can create a custom app to handle such a scenario