diff --git a/code/modules/economy/cash_register.dm b/code/modules/economy/cash_register.dm
index 07d49030f7..109572ffc0 100644
--- a/code/modules/economy/cash_register.dm
+++ b/code/modules/economy/cash_register.dm
@@ -51,10 +51,6 @@
overlays -= "register_cash"
else
open_cash_box()
- // Reset if necessary
- else if(transaction_amount)
- reset_memory()
- user << "You reset the machine's memory."
else
user.set_machine(src)
interact(user)
@@ -76,7 +72,12 @@
dat += "Linked account: [linked_account ? linked_account.owner_name : "None"]
"
dat += "[cash_locked? "Unlock" : "Lock"] Cash Box | "
dat += "Custom Order
"
- for(var/i=1, i<=transaction_logs.len, i++)
+
+ if(item_list.len)
+ dat += get_current_transaction()
+ dat += "
"
+
+ for(var/i=transaction_logs.len, i>=1, i--)
dat += "[transaction_logs[i]]
"
if(transaction_logs.len)
@@ -118,12 +119,46 @@
if (!t_purpose || !Adjacent(usr)) return
transaction_purpose = t_purpose
item_list += t_purpose
- var/t_amount = input("Enter price", "New price") as num
+ var/t_amount = round(input("Enter price", "New price") as num)
if (!t_amount || !Adjacent(usr)) return
transaction_amount += t_amount
price_list += t_amount
playsound(src, 'sound/machines/twobeep.ogg', 25)
- src.visible_message("\icon[src][transaction_purpose]: [transaction_amount] Thaler\s.")
+ src.visible_message("\icon[src][transaction_purpose]: [t_amount] Thaler\s.")
+ if("set_amount")
+ var/item_name = locate(href_list["item"])
+ var/n_amount = round(input("Enter amount", "New amount") as num)
+ n_amount = Clamp(n_amount, 0, 20)
+ if (!item_list[item_name] || !Adjacent(usr)) return
+ transaction_amount += (n_amount - item_list[item_name]) * price_list[item_name]
+ if(!n_amount)
+ item_list -= item_name
+ price_list -= item_name
+ else
+ item_list[item_name] = n_amount
+ if("subtract")
+ var/item_name = locate(href_list["item"])
+ if(item_name)
+ transaction_amount -= price_list[item_name]
+ item_list[item_name]--
+ if(item_list[item_name] <= 0)
+ item_list -= item_name
+ price_list -= item_name
+ if("add")
+ var/item_name = locate(href_list["item"])
+ if(item_list[item_name] >= 20) return
+ transaction_amount += price_list[item_name]
+ item_list[item_name]++
+ if("clear")
+ var/item_name = locate(href_list["item"])
+ if(item_name)
+ transaction_amount -= price_list[item_name] * item_list[item_name]
+ item_list -= item_name
+ price_list -= item_name
+ else
+ transaction_amount = 0
+ item_list.Cut()
+ price_list.Cut()
if("reset_log")
transaction_logs.Cut()
usr << "\icon[src]Transaction log reset."
@@ -180,18 +215,18 @@
if (!transaction_amount)
return
- if(!confirm(I))
+ if (cash_open)
+ playsound(src, 'sound/machines/buzz-sigh.ogg', 25)
+ usr << "\icon[src]The cash box is open."
+ return
+
+ if((item_list.len > 1 || item_list[item_list[1]] > 1) && !confirm(I))
return
if (!linked_account)
usr.visible_message("\icon[src]Unable to connect to linked account.")
return
- if (cash_open)
- playsound(src, 'sound/machines/buzz-sigh.ogg', 25)
- usr << "\icon[src]The cash box is open."
- return
-
// Access account for transaction
if(check_account())
var/datum/money_account/D = get_account(I.associated_account_number)
@@ -245,14 +280,14 @@
if (!transaction_amount)
return
- if(!confirm(E))
- return
-
if (cash_open)
playsound(src, 'sound/machines/buzz-sigh.ogg', 25)
usr << "\icon[src]The cash box is open."
return
+ if((item_list.len > 1 || item_list[item_list[1]] > 1) && !confirm(E))
+ return
+
// Access account for transaction
if(check_account())
if(transaction_amount > E.worth)
@@ -283,14 +318,14 @@
if (!transaction_amount)
return
- if(!confirm(SC))
- return
-
if (cash_open)
playsound(src, 'sound/machines/buzz-sigh.ogg', 25)
usr << "\icon[src]The cash box is open."
return
+ if((item_list.len > 1 || item_list[item_list[1]] > 1) && !confirm(SC))
+ return
+
if(transaction_amount > SC.worth)
src.visible_message("\icon[src]Not enough money.")
else
@@ -313,6 +348,9 @@
/obj/machinery/cash_register/proc/scan_item_price(obj/O)
if(!istype(O)) return
+ if(item_list.len > 10)
+ src.visible_message("\icon[src]Only up to ten different items allowed per purchase.")
+ return
if (cash_open)
playsound(src, 'sound/machines/buzz-sigh.ogg', 25)
usr << "\icon[src]The cash box is open."
@@ -330,19 +368,43 @@
transaction_purpose += "
"
transaction_purpose += "[O]: [price] Thaler\s"
transaction_amount += price
- item_list += "[O]"
- price_list += price
+ for(var/previously_scanned in item_list)
+ if(price == price_list[previously_scanned] && O.name == previously_scanned)
+ . = item_list[previously_scanned]++
+ if(!.)
+ item_list[O.name] = 1
+ price_list[O.name] = price
+ . = 1
// Animation and sound
playsound(src, 'sound/machines/twobeep.ogg', 25)
// Reset confirmation
confirm_item = null
+ updateDialog()
+
+
+/obj/machinery/cash_register/proc/get_current_transaction()
+ var/dat = {"
+
+
+ | New Entry |
+
"}
+ var/item_name
+ for(var/i=1, i<=item_list.len, i++)
+ item_name = item_list[i]
+ dat += "| [item_list[item_name] ? "- Set + [item_list[item_name]] x " : ""][item_name] Remove | [price_list[item_name] * item_list[item_name]] þ |
"
+ dat += "
"
+ dat += "| Clear Entry | Total Amount: [transaction_amount] þ |
"
+ dat += "
"
+ return dat
/obj/machinery/cash_register/proc/add_transaction_log(var/c_name, var/p_method, var/t_amount)
var/dat = {"
-
+
+ | New Entry |
+
"}
+ var/item_name
+ for(var/i=1, i<=item_list.len, i++)
+ item_name = item_list[i]
+ dat += "| [item_list[item_name] ? "- Set + [item_list[item_name]] x " : ""][item_name] Remove | [price_list[item_name] * item_list[item_name]] þ |
"
+ dat += "
"
+ dat += "| Clear Entry | Total Amount: [transaction_amount] þ |
"
+ dat += "
"
+ return dat
+
+
/obj/item/device/retail_scanner/proc/add_transaction_log(var/c_name, var/p_method, var/t_amount)
var/dat = {"