From f8715d76dede6be804fb3fbf834eea9b998b7895 Mon Sep 17 00:00:00 2001 From: Nordi98 Date: Tue, 5 Aug 2025 15:02:32 +0200 Subject: [PATCH] ed --- .../[tools]/nordi_billing/billing_client.lua | 16 ++++++++++++-- .../[tools]/nordi_billing/billing_server.lua | 22 ++++++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/resources/[tools]/nordi_billing/billing_client.lua b/resources/[tools]/nordi_billing/billing_client.lua index 72de33e94..7015e5c19 100644 --- a/resources/[tools]/nordi_billing/billing_client.lua +++ b/resources/[tools]/nordi_billing/billing_client.lua @@ -239,6 +239,7 @@ end -- Function to view received bills function ViewBills() + -- Get all bills from ps-banking local bills = lib.callback.await('ps-banking:server:getBills', false) if not bills or #bills == 0 then @@ -255,13 +256,24 @@ function ViewBills() return end + -- Get bill statuses from our custom table + local billStatuses = lib.callback.await('billing:server:getAllBillStatuses', false) + local statusMap = {} + + -- Create a map of bill ID to status for quick lookup + if billStatuses then + for _, status in ipairs(billStatuses) do + statusMap[status.bill_id] = status + end + end + local billOptions = {} for _, bill in ipairs(bills) do local timestamp = os.date('%Y-%m-%d %H:%M', bill.date) -- Check if bill is declined in our custom table - local billData = lib.callback.await('billing:server:getBillStatus', false, bill.id) - local isDeclined = billData and billData.declined == 1 + local billStatus = statusMap[bill.id] + local isDeclined = billStatus and billStatus.declined == 1 local status = 'Unbezahlt' if bill.isPaid then diff --git a/resources/[tools]/nordi_billing/billing_server.lua b/resources/[tools]/nordi_billing/billing_server.lua index 2735e6b4c..fcc205a5d 100644 --- a/resources/[tools]/nordi_billing/billing_server.lua +++ b/resources/[tools]/nordi_billing/billing_server.lua @@ -65,6 +65,24 @@ lib.callback.register('billing:server:getBillStatus', function(source, billId) return nil end) +-- Add a callback to get all bill statuses for a player +lib.callback.register('billing:server:getAllBillStatuses', function(source) + local src = source + local player = QBCore.Functions.GetPlayer(src) + + if not player then return nil end + + local citizenId = player.PlayerData.citizenid + + -- Get all bill statuses for this player + local result = MySQL.query.await('SELECT * FROM billing_accounts WHERE receiver_id = ?', {citizenId}) + if result and #result > 0 then + return result + end + + return {} +end) + -- Add a new callback for handling bill responses lib.callback.register('billing:server:handleBillResponse', function(source, data) local src = source @@ -117,7 +135,9 @@ lib.callback.register('billing:server:handleBillResponse', function(source, data return true elseif data.action == 'later' then - -- No action needed, bill remains in system + -- Simply close the prompt without any action + -- The bill will remain in the system as unpaid + -- No need to update anything in the database return true end