diff --git a/public/index.html b/public/index.html index fa806ce..7cfbec1 100755 --- a/public/index.html +++ b/public/index.html @@ -136,22 +136,41 @@ } http("put", "/api/transactions", () => {init()}, JSON.stringify(kvs)) } - function setRowKeyValue(row, wantkey, wantvalue) { + function getRowKeyValue(row, wantkey) { + const inputs = row.getElementsByTagName("td") + for (var i = 0; i < inputs.length; i++) { + const key = inputs[i].getAttribute("key") + if (key == wantkey) { + return inputs[i].innerText + "" + } + } + return null + } + function setRowKeyValues(row, wantKeysWantValues) { const inputs = row.getElementsByTagName("td") var kvs = {} for (var i = 0; i < inputs.length; i++) { const key = inputs[i].getAttribute("key") - if (key == wantkey) { - inputs[i].innerHTML = wantvalue - break + if (key in wantKeysWantValues) { + inputs[i].innerHTML = wantKeysWantValues[key] } } saveTransaction(row) } - zachsPayment = (x) => setRowKeyValue(x, "Payer", "AssetAccount:Zach") - belsPayment = (x) => setRowKeyValue(x, "Payer", "AssetAccount:Bel") - zachsCharge = (x) => setRowKeyValue(x, "Payee", "AssetAccount:Zach") - belsCharge = (x) => setRowKeyValue(x, "Payee", "AssetAccount:Bel") + zachsPayment = (x) => { + setRowKeyValues(x, { + "Payee": getRowKeyValue(x, "Payer"), + "Payer": "AssetAccount:Zach", + }) + } + belsPayment = (x) => { + setRowKeyValues(x, { + "Payee": getRowKeyValue(x, "Payer"), + "Payer": "AssetAccount:Bel", + }) + } + zachsCharge = (x) => setRowKeyValues(x, {"Payee": "AssetAccount:Zach"}) + belsCharge = (x) => setRowKeyValues(x, {"Payee": "AssetAccount:Bel"}) function http(method, remote, callback, body) { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { diff --git a/testdata/2018-.b.dat b/testdata/2018-.b.dat new file mode 100644 index 0000000..d6c14c4 --- /dev/null +++ b/testdata/2018-.b.dat @@ -0,0 +1,75 @@ +2021-08-07 UTAH INFRASTRUCTURE + Withdrawal:UTAHINFRASTRUCTURE $30.00 + AssetAccount:Chase:1049 +2021-08-07 HARMONS - OREM + Withdrawal:HARMONSOREM $8.73 + AssetAccount:Chase:1049 +2021-08-07 MACEY'S 8TH NORTH + Withdrawal:MACEYS8THNORTH $18.05 + AssetAccount:Chase:1049 +2021-08-07 BEEHIVE BROADBAND LL + Withdrawal:BEEHIVEBROADBANDLL $56.38 + AssetAccount:Chase:1049 +2021-08-07 CULLIGAN WATER CONDI + Withdrawal:CULLIGANWATERCONDI $35.00 + AssetAccount:Chase:1049 +2021-08-09 Payment + Withdrawal:Payment $121.38 + AssetAccount:Bel +2021-08-12 HARMONS - OREM + Withdrawal:HARMONSOREM $12.82 + AssetAccount:Chase:1049 +2021-08-12 COSTCO WHSE #0484 + Withdrawal:COSTCOWHSE0484 $76.02 + AssetAccount:Chase:1049 +2021-08-12 TRADER JOE'S #352 + Withdrawal:TRADERJOES352 $64.57 + AssetAccount:Chase:1049 +2021-08-12 TARGET T-1754 + Withdrawal:TARGETT1754 $56.12 + AssetAccount:Chase:1049 +2021-08-13 TARGET T-1754 + Withdrawal:TARGETT1754 $44.66 + AssetAccount:Chase:1049 +2021-08-15 TRADER JOE'S #352 + Withdrawal:TRADERJOES352 $7.70 + AssetAccount:Chase:1049 +2021-08-15 WALGREENS #11150 + Withdrawal:WALGREENS11150 $16.96 + AssetAccount:Chase:1049 +2021-08-15 HARMONS - OREM + Withdrawal:HARMONSOREM $35.30 + AssetAccount:Chase:1049 +2021-08-16 Payment + Withdrawal:Payment $140.49 + AssetAccount:Bel +2021-08-17 Payment + Withdrawal:Payment $20.63 + AssetAccount:Bel +2021-08-19 REDMOND FARMS STORE + Withdrawal:REDMONDFARMSSTORE $42.07 + AssetAccount:Chase:1049 +2021-08-19 TRADER JOE'S #352 + Withdrawal:TRADERJOES352 $52.93 + AssetAccount:Chase:1049 +2021-08-19 COSTCO WHSE #0484 + Withdrawal:COSTCOWHSE0484 $140.93 + AssetAccount:Chase:1049 +2021-08-23 Payment + Withdrawal:Payment $457.21 + AssetAccount:Bel +2021-08-28 TARGET T-1754 + Withdrawal:TARGETT1754 $95.34 + AssetAccount:Chase:1049 +2021-09-01 MACEY'S 8TH NORTH + Withdrawal:MACEYS8THNORTH $16.41 + AssetAccount:Chase:1049 +2021-09-01 COSTCO WHSE #0484 + Withdrawal:COSTCOWHSE0484 $167.81 + AssetAccount:Chase:1049 +2021-09-03 WALGREENS #12294 + Withdrawal:WALGREENS12294 $16.60 + AssetAccount:Chase:1049 +2021-09-03 TST* COSTA VIDA - 01 + Withdrawal:TSTCOSTAVIDA01 $20.78 + AssetAccount:Chase:1049