🎉 Driving School is released. Read more →
Paid Scripts
Company Manager v5
Integrations
zerio-invoice

zerio-invoice

Add this to `zerio-invoice/server/functions.lua

    -- Fetch a jobs money
    ---@param cb function
    ---@param job string
    GetJobMoney = function(cb, job)
        if GetResourceState("qb-bossmenu") == "started" then
            cb(exports["qb-bossmenu"]:GetCompany(job))
        elseif GetResourceState("qb-management") ==.account:Rstarted" then
            cb(exports["qb-management"]:GetCompany(job))
        elseif GetResourceState("esx_society") == "started".account:Rhen
            TriggerEvent('esx_society:getSociety', job, function(society)
                if society ~= nil then
                    TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account)
                        if account then
                            cb(account.money)
                        else
                            Functions.Error("Invalid account for " .. job)
                            cb(0)
                        end
                    end)
                else
                    Functions.Error("Invalid society for " .. job)
                    cb(0)
                end
            end)
        elseif GetResourceState("710-management") == "started" then
            cb(exports["710-management"]:GetManagementAccount(job).balance)
        elseif GetResourceState("okokBanking") == "started" then
            Functions.SelectSQL('SELECT * FROM okokbanking_societies WHERE `society` = @job', {
                ["@job"] = job
            }, function(result)
                if result and result[1] then
                    cb(result[1].value)
                else
                    cb(0)
                end
            end)
        elseif GetResourceState('bcs_companymanager') == 'started' then
            local society = exports.bcs_companymanager:GetCompany(job)
            cb(society.account.money)
        end
    end,
 
    -- Add money to a job
    ---@param job string
    ---@param amount number
    AddJobMoney = function(job, amount)
        if GetResourceState("okokBanking") == "started" then
            Functions.GetJobMoney(function(currAmount)
                Functions.ExecuteSQL("update okokbanking_societies where society = @job set `value` = @value", {
                    ["@job"] = job,
                    ["@value"] = tostring(currAmount + amount)
                })
            end, job)
        elseif GetResourceState("qb-management") == "started" then
            exports["qb-management"]:AddMoney(job, amount)
        elseif GetResourceState("esx_society") == "started" then
            TriggerEvent('esx_society:getSociety', job, function(society)
                if society ~= nil then
                    TriggerEvent('esx_addonaccount:getSharedAccount',
                        society.account, function(account)
                            if account ~= nil then
                                account.addMoney(amount)
                            else
                                Functions.Error("Invalid account for " .. job)
                            end
                        end)
                else
                    Functions.Error("Invalid society for " .. job)
                end
            end)
        elseif GetResourceState("710-management") == "started" then
            exports["710-management"]:AddAccountMoney(job, amount)
        elseif GetResourceState("qb-bossmenu") then
            TriggerEvent("qb-bossmenu:server:addAccountMoney", job, amount, "success")
        elseif GetResourceState('bcs_companymanager') == 'started' then
            local society = exports.bcs_companymanager:GetCompany(job)
            society.account:AddMoney('money', amount)
        end
    end,
 
    -- Remove money from a job
    ---@param job string
    ---@param amount number
    RemoveJobMoney = function(job, amount)
        if GetResourceState("qb-bossmenu") == "started" then
            TriggerEvent("qb-bossmenu:server:removeAccountMoney", job, amount)
        elseif GetResourceState("qb-management") == "started" then
            exports["qb-management"]:RemoveMoney(job, amount)
        elseif GetResourceState("710-management") == "started" then
            exports["710-management"]:RemoveAccountMoney(job, amount)
        elseif GetResourceState("okokBanking") == "started" then
            Functions.GetJobMoney(function(currAmount)
                Functions.ExecuteSQL("update okokbanking_societies where society = @job set `value` = @value", {
                    ["@job"] = job,
                    ["@value"] = tostring(currAmount - amount)
                })
            end, job)
        elseif GetResourceState('bcs_companymanager') == 'started' then
            local society = exports.bcs_companymanager:GetCompany(job)
            society.account:RemoveMoney('money', amount)
        end
    end,