diff --git a/code/modules/supply/supply_console.dm b/code/modules/supply/supply_console.dm index 09ba99596a4..337e10fd411 100644 --- a/code/modules/supply/supply_console.dm +++ b/code/modules/supply/supply_console.dm @@ -344,7 +344,7 @@ for(var/datum/station_department/department in SSjobs.station_departments) if(department.department_account == selected_account) order.ordered_by_department = department //now that we know which department this is for, attach it to the order - order.orderedbyaccount = selected_account + order.set_account(selected_account) order.requires_head_approval = TRUE if(length(order.object.department_restrictions) && !(department.department_name in order.object.department_restrictions)) @@ -358,7 +358,7 @@ //===Handle Supply Order=== if(selected_account.account_type == ACCOUNT_TYPE_PERSONAL) //if the account is a personal account (and doesn't require CT approval), go ahead and pay for it now - order.orderedbyaccount = selected_account + order.set_account(selected_account) if(attempt_account_authentification(selected_account, user)) var/paid_for = FALSE if(!order.requires_cargo_approval && pay_with_account(selected_account, order.object.get_cost(), "[order.object.name] Crate Purchase", "Cargo Requests Console", user, account_database.vendor_account)) diff --git a/code/modules/supply/supply_order.dm b/code/modules/supply/supply_order.dm index 99bd05ad6e8..ba2fa011d70 100644 --- a/code/modules/supply/supply_order.dm +++ b/code/modules/supply/supply_order.dm @@ -22,6 +22,16 @@ name = "request form" var/order_number +/// Set the account that made the request and make sure the request is deleted when the account is deleted +/datum/supply_order/proc/set_account(datum/money_account/account) + orderedbyaccount = account + RegisterSignal(orderedbyaccount, COMSIG_PARENT_QDELETING, PROC_REF(clear_request)) + +/// Clear the request from the request list and delete it +/datum/supply_order/proc/clear_request() + SSeconomy.request_list -= src + qdel(src) + /datum/supply_order/proc/createObject(atom/_loc, errors = 0) if(!object) return