From 9de5a66926e602ad4827c10c7be3f602c127340f Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Sat, 15 Aug 2020 17:06:58 -0700
Subject: [PATCH] Add JSDoc for cashX, repX, forceNeg.

---
 src/js/economyJS.js | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/js/economyJS.js b/src/js/economyJS.js
index ab6cc26a67e..881b547b57f 100644
--- a/src/js/economyJS.js
+++ b/src/js/economyJS.js
@@ -2272,11 +2272,16 @@ Make sure that expenses arrive in the COST slot as a negative, they are often po
 
 Costs don't have to be numbers either, you can use variables. <<run cashX(forceNeg(_ContractCost), "slaveTransfer", $activeSlave)>>. forceNeg makes sure that whatever value _ContractCost has is negative, and will therefore be recorded as an expense. You don't have to use it if you're sure the number you are passing along is negative.
 
-A full list of categories (slaveMod, slaveTransfer, event) are in the widget "setupLastWeeksCash", currently found in costsWidgets.tw. It's important to match your cost to one of those categories (or add a new one there, and display it in costsBudget.tw.)
+A full list of categories (slaveMod, slaveTransfer, event) are in App.Data.Records.LastWeeksCash(). It's important to match your cost to one of those categories (or add a new one there, and display it in costsBudget.tw.)
 
 The third category, the "slave slot" is completely optional. Sometimes you just want to spend money by yourself.
 
 */
+/** Spend or gain money and record the transaction for accounting
+ * @param {number} cost
+ * @param {string} what - @see App.Data.Records.LastWeeksCash() for a full list
+ * @param {App.Entity.SlaveState} [who] - the slave whose ledger the transaction should be recorded to. V.PC may be passed but will be ignored.
+ */
 globalThis.cashX = function(cost, what, who) {
 	if (!Number.isFinite(cost)) {
 		V.lastWeeksCashErrors += `Expected a finite number for ${what}, but got ${cost}<br>`;
@@ -2327,7 +2332,7 @@ globalThis.cashX = function(cost, what, who) {
 			if (what === "slaveTransfer") {
 				who.slaveCost = cost;
 			} else {
-				who.lastWeeksCashExpenses = cost;
+				// who.lastWeeksCashExpenses = cost; - weekly slave expenses are not tracked this way
 				who.lifetimeCashExpenses += cost;
 			}
 		}
@@ -2349,6 +2354,11 @@ globalThis.cashX = function(cost, what, who) {
 	return cost;
 };
 
+/** Spend or gain reputation and record the transaction for accounting
+ * @param {number} rep
+ * @param {string} what - @see App.Data.Records.LastWeeksRep() for a full list
+ * @param {App.Entity.SlaveState} [who] - the slave whose ledger the transaction should be recorded to. V.PC may be passed but will be ignored.
+ */
 globalThis.repX = function(rep, what, who) {
 	if (!Number.isFinite(rep)) {
 		V.lastWeeksRepErrors += `Expected a finite number for ${what}, but got ${rep}<br>`;
@@ -2409,6 +2419,10 @@ globalThis.repX = function(rep, what, who) {
 	return rep;
 };
 
+/** Make sure a number is negative.
+ * @param {number} x
+ * @returns {number}
+ */
 globalThis.forceNeg = function(x) {
 	return -Math.abs(x);
 };
-- 
GitLab