> For the complete documentation index, see [llms.txt](https://docs.vames-store.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vames-store.com/assets/vms_cityhall/guides/business-taxes-integration.md).

# Business Taxes Integration

***

{% hint style="danger" %}

## Read carefully!

If you want to implement the tax system from **VMS City Hall** into your external resource (e.g., esx\_policejob), **you will also need VMS Boss Menu** to allow players to pay and view their current paid or unpaid taxes.

\
**Without the mentioned resource, the full potential of the tax system cannot be utilized!**
{% endhint %}

{% hint style="info" %}
**The following tax integration example is based on the publicly available resource `esx_taxijob`.**

After reviewing and carefully reading this guide, you'll understand how to implement the tax system into other resources as well.

Please note that implementation is only possible in open-source resources - **it's not possible to introduce functional company taxation in escrow-protected scripts**.\
In such cases, we recommend contacting the author of the resource and requesting compatibility with our system.
{% endhint %}

Source Code: [**https://github.com/esx-framework/esx\_taxijob**](https://github.com/esx-framework/esx_taxijob/blob/main/server/main.lua#L12-L45)

{% code title="esx\_taxijob" %}

```lua
RegisterNetEvent('esx_taxijob:success', function()
    local xPlayer = ESX.GetPlayerFromId(source)
    local timeNow = os.clock()
    
    if xPlayer.job.name ~= 'taxi' then
        print(('[^3WARNING^7] Player ^5%s^7 attempted to ^5esx_taxijob:success^7 (cheating)'):format(source))
        return
    end

    if not lastPlayerSuccess[source] or timeNow - lastPlayerSuccess[source] > 5 then
        lastPlayerSuccess[source] = timeNow

        local total = math.random(Config.NPCJobEarnings.min, Config.NPCJobEarnings.max)

        if xPlayer.job.grade >= 3 then
            total = total * 2
        end


        -- VMS City Hall & VMS Boss Menu - Business Taxes Integration --
        -- VMS City Hall & VMS Boss Menu - Business Taxes Integration --
        
        local society = exports['vms_bossmenu']:getSociety('taxi')
        if society then -- We check whether the "taxi" company is registered.
            -- If the company is registered, we continue to work with the company and taxes
            local playerMoney = ESX.Math.Round(total / 100 * 30)
            local societyMoney = ESX.Math.Round(total / 100 * 70)
            
            xPlayer.addMoney(playerMoney, "Taxi Fair")
            
            exports['vms_bossmenu']:addMoney('taxi', societyMoney, function()
                -- After adding money for the company, we add tax:
                exports['vms_cityhall']:addCompanyCustomTaxAmount(
                    'taxi', -- Job Name
                    total, -- Total amount
                    8 -- For example, 8% of the amount of total amount is additional tax
                )
            end)
            
            xPlayer.showNotification(TranslateCap('comp_earned', societyMoney, playerMoney))
        else
            xPlayer.addMoney(total, "Taxi Fair")
            xPlayer.showNotification(TranslateCap('have_earned', total))
        end
        
        -- VMS City Hall & VMS Boss Menu - Business Taxes Integration --
        -- VMS City Hall & VMS Boss Menu - Business Taxes Integration --
    end
end)
```

{% endcode %}
