mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 18:32:03 +00:00
Accounting Computer (#33615)
* Accounting Computer * div balance and lint * tweaks * finished * Fix config example * added sound
This commit is contained in:
@@ -98,3 +98,9 @@
|
||||
/obj/item/weapon/storage/wallet/trader/New()
|
||||
..()
|
||||
dispense_cash(rand(150,250),src)
|
||||
|
||||
/obj/item/weapon/storage/wallet/nt
|
||||
icon_state = "wallet-NT"
|
||||
|
||||
/obj/item/weapon/storage/wallet/nt/update_icon()
|
||||
return
|
||||
|
||||
@@ -15,6 +15,8 @@ var/datum/money_account/trader_account
|
||||
|
||||
var/station_allowance = 0//This is what Nanotrasen will send to the Station Account after every salary, as provision for the next salary.
|
||||
var/latejoiner_allowance = 0//Added to station_allowance and reset before every wage payout.
|
||||
var/station_funding = 0 //A bonus to the station allowance that persists between cycles. Admins can set this on the database.
|
||||
var/station_bonus = 0 //A bonus to station allowance that gets reset after wage payout. Admins can boost this too.
|
||||
|
||||
/proc/create_station_account()
|
||||
if(!station_account)
|
||||
@@ -245,7 +247,11 @@ var/latejoiner_allowance = 0//Added to station_allowance and reset before every
|
||||
if(access_level > 0 || isAdminGhost(user) || is_malf_owner(user))
|
||||
|
||||
dat += {"<a href='?src=\ref[src];toggle_activated=1'>[activated ? "Disable" : "Enable"] remote access</a><br>
|
||||
Combined department and personnel budget is currently [station_allowance] credits. A total of [global.requested_payroll_amount] credits were requested during the last payroll cycle.<br>"}
|
||||
Combined department and personnel budget is currently [station_allowance+station_bonus+station_funding] credits. A total of [global.requested_payroll_amount] credits were requested during the last payroll cycle.<br>"}
|
||||
if(station_bonus || isAdminGhost(user))
|
||||
dat += "The budget was increased by a bonus of [station_bonus] this cycle. [isAdminGhost(user) ? "<a href='?src=\ref[src];choice=addbonus;'>Adjust</a>" : ""]<br>"
|
||||
if(station_funding || isAdminGhost(user))
|
||||
dat += "Central Command has earmarked an additional [station_funding] for the budget. [isAdminGhost(user) ? "<a href='?src=\ref[src];choice=addfunding;'>Adjust</a>" : ""]<br>"
|
||||
if(creating_new_account)
|
||||
|
||||
dat += {"<br>
|
||||
@@ -404,6 +410,16 @@ var/latejoiner_allowance = 0//Added to station_allowance and reset before every
|
||||
if("view_accounts_list")
|
||||
detailed_account_view = null
|
||||
creating_new_account = 0
|
||||
if("addfunding")
|
||||
if(!isAdminGhost(usr))
|
||||
return
|
||||
var/new_funding = input(usr, "Adjust the budget for ALL cycles", "Adjust by", station_funding) as null|num
|
||||
station_funding = new_funding
|
||||
if("addbonus")
|
||||
if(!isAdminGhost(usr))
|
||||
return
|
||||
var/new_bonus = input(usr, "Adjust the budget for THIS cycles", "Adjust by", station_bonus) as null|num
|
||||
station_bonus = new_bonus
|
||||
if("toggle_account")
|
||||
if(detailed_account_view)
|
||||
detailed_account_view.disabled = detailed_account_view.disabled ? 0 : 2
|
||||
|
||||
@@ -68,7 +68,11 @@ If all wages are decreased bellow 100%, for example due to the AI spending all t
|
||||
if(!station_account)
|
||||
message_admins("Station allowance skipped, no station account found.")
|
||||
return
|
||||
station_account.money += station_allowance + WageBonuses()
|
||||
|
||||
for(var/obj/machinery/computer/accounting/A in machines)
|
||||
A.new_cycle()
|
||||
station_account.money += station_allowance + WageBonuses() + station_funding + station_bonus
|
||||
station_bonus = 0
|
||||
|
||||
new /datum/transaction(station_account,"Nanotrasen station allowance","[station_allowance]","Nanotrasen Payroll Server",send2PDAs=FALSE)
|
||||
|
||||
|
||||
143
code/modules/library/computers/accounting.dm
Normal file
143
code/modules/library/computers/accounting.dm
Normal file
@@ -0,0 +1,143 @@
|
||||
/obj/machinery/computer/accounting
|
||||
name = "accounting computer"
|
||||
desc = "For virtual bookkeeping. This computer is used in the calculation of overages."
|
||||
pass_flags = PASSTABLE
|
||||
machine_flags = WRENCHMOVE | FIXED2WORK
|
||||
icon = 'icons/obj/library.dmi'
|
||||
icon_state = "computer"
|
||||
req_access = list(access_library)
|
||||
var/savings = 0 //Total savings this cycle
|
||||
var/oldgood = -1 //Was our last calculation correct? -1 indicates no last query this cycle, resets to -1 at cycle end, 0 is bad, 1 is good
|
||||
var/oldentry = 0 //Our last attempted difference
|
||||
|
||||
var/minuend
|
||||
var/subtrahend
|
||||
var/oldquery
|
||||
var/currentqueryname
|
||||
var/nextmin
|
||||
var/nextsub
|
||||
var/entryinfo = "<big>Accounting Report</big><BR>"
|
||||
var/list/contributors = list()
|
||||
|
||||
/obj/machinery/computer/accounting/New()
|
||||
..()
|
||||
generatenext()
|
||||
readynext()
|
||||
|
||||
/obj/machinery/computer/accounting/Destroy()
|
||||
contributors.Cut()
|
||||
..()
|
||||
|
||||
/obj/machinery/computer/accounting/attack_hand(mob/user as mob)
|
||||
if(..())
|
||||
return
|
||||
if(stat & (NOPOWER|BROKEN|FORCEDISABLE))
|
||||
return
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/computer/accounting/ui_interact(mob/user, ui_key="main", datum/nanoui/ui=null, var/force_open=NANOUI_FOCUS)
|
||||
user.set_machine(src)
|
||||
|
||||
var/data[0]
|
||||
data["src"] = "\ref[src]"
|
||||
data["savings"] = savings
|
||||
data["oldgood"] = oldgood
|
||||
data["oldquery"] = oldquery
|
||||
data["oldentry"] = oldentry
|
||||
data["minuend"] = minuend
|
||||
data["subtrahend"] = subtrahend
|
||||
data["currentqueryname"] = currentqueryname
|
||||
data["nextquery"] = "[nextmin] - [nextsub]"
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "accounting.tmpl", src.name, 600, 500)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/computer/accounting/Topic(href, href_list)
|
||||
if(..())
|
||||
return 1
|
||||
if(!allowed(usr))
|
||||
to_chat(usr, "<span class='warning'>You do not have accounting clearance.</span>")
|
||||
return
|
||||
if(href_list["reg"])
|
||||
if(!in_range(src, usr))
|
||||
return 1
|
||||
var/sol = text2num(href_list["reg"])
|
||||
if(isnull(sol))
|
||||
visible_message("<span class='warning'>[src] buzzes rudely.</span>")
|
||||
playsound(src, 'sound/machines/buzz-two.ogg', 50, 0)
|
||||
return 1
|
||||
solve_query(sol)
|
||||
if(!(usr.name in contributors))
|
||||
contributors += usr.name
|
||||
nanomanager.update_uis(src)
|
||||
return 1
|
||||
|
||||
/obj/machinery/computer/accounting/proc/solve_query(var/sol)
|
||||
playsound(loc, "sound/effects/typing[pick(1,2,3)].ogg", 50, 1)
|
||||
var/diff = minuend - subtrahend
|
||||
if(sol == diff)
|
||||
oldgood = TRUE
|
||||
savings += sol
|
||||
entryinfo += "[currentqueryname]: $[sol] overage saved<BR>"
|
||||
else
|
||||
oldgood = FALSE
|
||||
|
||||
spawn(1 SECONDS)
|
||||
playsound(loc, oldgood ? 'sound/machines/ding2.ogg': 'sound/machines/buzz-sigh.ogg', 50, 1)
|
||||
|
||||
oldquery = "[minuend] - [subtrahend]"
|
||||
oldentry = sol
|
||||
readynext()
|
||||
|
||||
|
||||
/obj/machinery/computer/accounting/proc/readynext()
|
||||
currentqueryname = buildname()
|
||||
minuend = nextmin
|
||||
subtrahend = nextsub
|
||||
generatenext()
|
||||
nanomanager.update_uis(src)
|
||||
|
||||
/obj/machinery/computer/accounting/proc/new_cycle()
|
||||
if(!savings)
|
||||
return
|
||||
var/obj/item/weapon/paper/P = new /obj/item/weapon/paper(loc)
|
||||
P.name = "accounting report for [worldtime2text()]"
|
||||
P.info = "[entryinfo]" + "Total savings: $[savings]<BR>Prepared in part by: [english_list(contributors)]<BR>This document is to be verified by Internal Affairs and faxed to Central Command.<BR>"
|
||||
var/image/stampoverlay = image('icons/obj/bureaucracy.dmi')
|
||||
stampoverlay.icon_state = "paper_stamp-cent"
|
||||
if(!P.stamped)
|
||||
P.stamped = new
|
||||
P.stamped += /obj/item/weapon/stamp
|
||||
P.overlays += stampoverlay
|
||||
P.stamps += "<HR><i>It has a Central Command accounting stamp: MQAC[round(savings/50)]TRM</i>"
|
||||
playsound(loc, "sound/effects/dotmatrixprinter.ogg", 40, 1)
|
||||
station_bonus += round(savings/10)
|
||||
savings = 0
|
||||
oldgood = -1
|
||||
oldquery = null
|
||||
oldentry = null
|
||||
contributors.Cut()
|
||||
entryinfo = "<big>Accounting Report</big><BR>"
|
||||
nanomanager.update_uis(src)
|
||||
|
||||
/obj/machinery/computer/accounting/proc/buildname()
|
||||
var/firstpart = pick(list("coordination on", "water resource", "geothermal", "miscellaneous", "programmatic",
|
||||
"management", "disposition", "flood and storm", "vacuum", "atmospheric", "interagency nonstructural",
|
||||
"other technical", "planning assistance", "communications stream", "ecosystem", "biosphere", "exoplanet", "xenopology",
|
||||
"electrical", "culinary", "supply", "genetics", "virology", "command", "horticultural", "human", "fuel", "upgrade",
|
||||
"cyberinfrastructure", "scientific", "cybersecurity", "redesign of", "biological", "important"))
|
||||
|
||||
var/lastpart = pick(list("research", "logistics", "recycling", "outreach", "appropriations", "endowments", "study",
|
||||
"planning assistance", "gauging", "interests", "reduction", "oversight", "investments", "modeling", "determinations",
|
||||
"risk assessment", "inventory", "guidance", "traineeships", "foundations", "repair", "highlights", "splining"))
|
||||
return firstpart + " " + lastpart
|
||||
|
||||
#define APPROXIMATE_PYTHAG (3/7)
|
||||
/obj/machinery/computer/accounting/proc/generatenext()
|
||||
var/greaterval = rand(1001,9999)
|
||||
var/lesserval = rand(201,1000)
|
||||
nextmin = round(greaterval + lesserval*APPROXIMATE_PYTHAG)
|
||||
nextsub = round(sqrt(greaterval**2 + lesserval**2)) //true pythag
|
||||
//Should generate an inaccuracy of 1% to 8.8%
|
||||
@@ -131,6 +131,22 @@ var/list/alldepartments = list("Central Command", "Nanotrasen HR")
|
||||
to_chat(usr, "<span class='danger'>\The [src] displays a 404 error: Central Command not found.</span>")
|
||||
return
|
||||
if(dpt == "Central Command")
|
||||
var/locate_acc = findtext(tofax.stamps,"MQAC")
|
||||
if(locate_acc)
|
||||
var/reward = copytext(tofax.stamps,locate_acc+4,findtext(tofax.stamps,"TRM"))
|
||||
if(!text2num(reward))
|
||||
message_admins("DEBUG: An accounting fax stamp had an irregular reward amount ([reward]) and could not be parsed.")
|
||||
return
|
||||
visible_message("<span class='warning'>The fax machine destroys the original [tofax] per infosec protocol!</span>")
|
||||
qdel(tofax)
|
||||
tofax = null
|
||||
flick("faxreceive",src)
|
||||
playsound(loc, "sound/effects/fax.ogg", 50, 1)
|
||||
var/obj/item/weapon/storage/wallet/nt/wally = new()
|
||||
dispense_cash(text2num(reward),wally)
|
||||
spawn(2 SECONDS)
|
||||
wally.forceMove(loc)
|
||||
log_game("[usr]/([usr.ckey]) received [reward] cash as an automated fax response.")
|
||||
Centcomm_fax(tofax, tofax.name, usr, dpt)
|
||||
else
|
||||
if(findtext(tofax.stamps,"magnetic"))
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.0 KiB |
92
nano/templates/accounting.tmpl
Normal file
92
nano/templates/accounting.tmpl
Normal file
@@ -0,0 +1,92 @@
|
||||
<script type='text/javascript'>
|
||||
function markGreen(){
|
||||
var toColor = document.getElementById('diffinput');
|
||||
toColor.style.backgroundColor = '#DDFFDD';
|
||||
var elem = document.getElementById('regid');
|
||||
var body = $('body');
|
||||
elem.value = body.data('urlParameters')['src'];
|
||||
toColor.focus();
|
||||
}
|
||||
</script>
|
||||
<div class='statusDisplay'>
|
||||
<div class='item'>
|
||||
Record to Present
|
||||
</div>
|
||||
<div class='item'>
|
||||
<div class='itemLabel'>
|
||||
Savings (Current Cycle)
|
||||
</div>
|
||||
<div class='itemContent'>
|
||||
{{:data.savings}}
|
||||
</div>
|
||||
</div>
|
||||
<div class='item'>
|
||||
<div class='itemLabel'>
|
||||
Last Query
|
||||
</div>
|
||||
{{if data.oldgood == -1}}
|
||||
<div class='itemContent'>
|
||||
<span class='average'>No queries this cycle</span>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class='itemContent'>
|
||||
{{:data.oldquery}}
|
||||
</div>
|
||||
<div class='itemLabel'>
|
||||
Last Entry
|
||||
</div>
|
||||
<div class='itemContent'>
|
||||
{{if data.oldgood == 1}}
|
||||
<span class='good'>{{:data.oldentry}}</span>
|
||||
{{else}}
|
||||
<span class='bad'>{{:data.oldentry}}</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
<div class='statusDisplay'>
|
||||
<div class='item'>
|
||||
<h2>Overages for {{:data.currentqueryname}}</h2>
|
||||
</div>
|
||||
<div class='item'>
|
||||
<div class='itemLabel'>
|
||||
Projected Costs
|
||||
</div>
|
||||
<div class='itemContent'>
|
||||
{{:data.minuend}}
|
||||
</div>
|
||||
</div>
|
||||
<div class='item'>
|
||||
<div class='itemLabel'>
|
||||
Actual Costs
|
||||
</div>
|
||||
<div class='itemContent'>
|
||||
{{:data.subtrahend}}
|
||||
</div>
|
||||
</div>
|
||||
<form name='accountcomp' action='?src={{:data.src}}' method='get'>
|
||||
<div class='item'>
|
||||
<div class='itemLabel'>
|
||||
<input type='hidden' name='src' value='' id='regid'>
|
||||
<input type='hidden' name='choice' value='reg'>
|
||||
Difference
|
||||
</div>
|
||||
<div class='itemContent'>
|
||||
<input type='text' id='diffinput' name='reg'>
|
||||
<input type='submit' value='Solve' onclick='markGreen()'>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class='statusDisplay'>
|
||||
<div class='item'>
|
||||
<h2>Next</h2>
|
||||
</div>
|
||||
<div class='itemLabel'>
|
||||
<span class='average'>Next Query</span>
|
||||
</div>
|
||||
<div class='itemContent'>
|
||||
<span class='average'>{{:data.nextquery}}</span>
|
||||
</div>
|
||||
</div>
|
||||
BIN
sound/effects/dotmatrixprinter.ogg
Normal file
BIN
sound/effects/dotmatrixprinter.ogg
Normal file
Binary file not shown.
BIN
sound/effects/typing1.ogg
Normal file
BIN
sound/effects/typing1.ogg
Normal file
Binary file not shown.
BIN
sound/effects/typing2.ogg
Normal file
BIN
sound/effects/typing2.ogg
Normal file
Binary file not shown.
BIN
sound/effects/typing3.ogg
Normal file
BIN
sound/effects/typing3.ogg
Normal file
Binary file not shown.
@@ -1690,6 +1690,7 @@
|
||||
#include "code\modules\library\lib_items.dm"
|
||||
#include "code\modules\library\lib_machines.dm"
|
||||
#include "code\modules\library\lib_readme.dm"
|
||||
#include "code\modules\library\computers\accounting.dm"
|
||||
#include "code\modules\library\computers\base.dm"
|
||||
#include "code\modules\library\computers\checkout.dm"
|
||||
#include "code\modules\library\computers\public.dm"
|
||||
|
||||
Reference in New Issue
Block a user