@mx-cartographer/experiences 9.7.56 → 9.7.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/core/stores/TransactionStore.d.ts +6 -0
  3. package/dist/core/stores/TransactionStore.es.js +45 -33
  4. package/dist/core/stores/TransactionStore.es.js.map +1 -1
  5. package/dist/core/types/localization/InsightsFeedCopy.d.ts +8 -0
  6. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.d.ts +5 -1
  7. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js +63 -58
  8. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js.map +1 -1
  9. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +115 -107
  10. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
  11. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +7 -1
  12. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +88 -59
  13. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
  14. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.d.ts +7 -1
  15. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js +13 -13
  16. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js.map +1 -1
  17. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.d.ts +1 -1
  18. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js +10 -7
  19. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js.map +1 -1
  20. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +46 -15
  21. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js +87 -59
  22. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -1
  23. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [9.7.57] - 10-28-2026
2
+
3
+ - **CHANGED** - The Upcoming Bill "View Details" drawer (`transaction_history_block` / `upcoming_bill`) reads its facts from the envelope's `drilldown_data` instead of `instance_slot.data`, which fixes its empty chart: `transaction_guids` select the paid bills, `due_date` (YYYY-MM-DD) and `amount` add the projected bar last, `category_guid` colours the bars and `average_amount` is the Trend legend. The source is the registry entry's new optional `slotData` resolver (`resolveUpcomingBillSlotData`); every other drilldown variant still reads `instance_slot.data`. Each fact is narrowed and fails closed: a missing or mistyped due date, amount or `transaction_guids` draws no chart and lists no rows, while a missing average or category only drops the Trend figure or the category colour (WEC-1962)
4
+ - **ADDED** - Tip in the Upcoming Bill drawer, "Tip: Your projected {merchant} bill is due {date}.", from `drilldown_data.merchant_name` and `due_date`, dismissible; no tip when either is missing or the merchant is blank. Copy is the new optional `insights_feed.transaction_history_block.upcoming_bill_tip_message` (`_1{tip}`, `_2{merchant}`, `_3{date}`), no tip until the copy service carries it, so no English is hard-coded (WEC-1962)
5
+ - **CHANGED** - The Upcoming Bill drawer works like legacy pulse's: one bar per paid bill (de-duplicated by date, as `magicTransactions`) plus the projected bill, named by month (`Aug`), or by day (`Oct 2`) when two bars share a month. A bar's tab lists that bill alone (`transactionGuidStrategy`, filtered locally), and the projected tab lists one row for the projected bill, headed by the copy service's `insights_feed.general.projected_amount` (mrs_content ships "PROJECTED AMOUNT" and its translations; no row without it). The projected tab is selected on open, including when the paid bills reach the transaction store after the drawer opens (WEC-1962)
6
+ - **FIXED** - The Upcoming Bill drawer draws a bar for each paid bill even when it is older than the transaction store's 90-day window: the block's open-time prepare hook fetches the paid bills the store lacks by guid (new `TransactionStore.loadTransactionsByGuids`, over `TransactionApi.getTransactionsByGuids`), as pulse's `BeatShell` loads a legacy beat's transactions. A drilldown registry entry opts in with the new `fetchMissingTransactions(beat)` function, which returns the guids from wherever its beat keeps them (`upcoming_bill`: `drilldown_data.transaction_guids`, narrowed with `guidListOf`), and the fetch runs after the 90-day window load so that load cannot replace the older bills. A bar's date is the bill's UTC calendar day, so it no longer names the day before the row's date west of UTC (WEC-1962)
7
+ - **ADDED** - Drilldown registry entries take an optional `beatTransactions` resolver, alongside `slotData`, that builds the drawer's transactions from the beat's own. Upcoming Bill's (`resolveUpcomingBillTransactions`) appends the projected bill (`buildProjectedBillTransaction`, on `PROJECTED_BILL_GUID`) last, so the bars (`buildUpcomingBillSeries`) and the projected tab's row read one list; the block (`splitProjectedTransaction`) keeps it out of the list and the CSV export and hands it to `TransactionDrillDown` as the projected row only when the selected tab's filter matches it (WEC-1962)
8
+ - **ADDED** - Upcoming Bill fixture (`UpcomingBillPayload.json`, the full envelope in tupac's shape; `miniBeats` derives the mini with its own guid) and the `InsightsV2/Insights/UpcomingBill` story: full and mini cards and the open "View Details" drawer (WEC-1962)
9
+
1
10
  ## [9.7.56] - 10-27-2026
2
11
 
3
12
  - **ADDED** - Monthly Non-Essential Category Summary's "View more" drawer on Insights 2.0 (MEW2-3375): the `transaction_history_block` `non_essential_category_summary` row, a tabs-only drawer (no chart, no month tabs) with one side tab per `series` row (Non-essential / Essential) that lists that side's `aggregated_guids` within its month. Fixtures (`mock/BlockBeatsData/NonEssentialCategorySummary*.ts`), drawer stories, contract test and the block doc
@@ -73,6 +73,12 @@ export declare class TransactionStore {
73
73
  updateTag: (tag: Tag) => Promise<void>;
74
74
  /** Resolves `true` when the transaction was saved, `false` when the API call failed. */
75
75
  updateTransaction: (transaction: Transaction) => Promise<boolean>;
76
+ /**
77
+ * Adds the given transactions by guid, fetching only those the store lacks: an insight drawer's
78
+ * own transactions can be older than the date-range cache (pulse's BeatShell loads a legacy beat's
79
+ * the same way). Leaves `cachedStartDate` alone, since the range itself is not loaded.
80
+ */
81
+ loadTransactionsByGuids: (guids: string[]) => Promise<void>;
76
82
  loadEmbeddedInstanceTransactions: (fromDate: Date) => Promise<void>;
77
83
  private captureError;
78
84
  }
@@ -1,8 +1,8 @@
1
- import { TransactionType as T } from "../types/Transaction.es.js";
1
+ import { TransactionType as f } from "../types/Transaction.es.js";
2
2
  import { endOfUtcDay as g, startOfUtcDay as h } from "../utils/DateUtil.es.js";
3
3
  import { BeatApi as l } from "../api/BeatApi.es.js";
4
4
  import { TransactionApi as u } from "../api/TransactionApi.es.js";
5
- import { upsertByGuid as f } from "../utils/upsertByGuid.es.js";
5
+ import { upsertByGuid as p } from "../utils/upsertByGuid.es.js";
6
6
  import { TABLE_CONST as S } from "../constants/Table.es.js";
7
7
  import { COLUMN_NAMES as y, DEFAULT_TRANSACTION as m } from "../constants/Transaction.es.js";
8
8
  import { buildDetailedTransactions as L, flattenTransactionsWithSplits as w, sortAndFilterTransactions as D } from "../utils/TransactionUtils.es.js";
@@ -11,8 +11,8 @@ import { isBefore as R } from "date-fns/isBefore";
11
11
  import { startOfMonth as d } from "date-fns/startOfMonth";
12
12
  import { startOfToday as c } from "date-fns/startOfToday";
13
13
  import { subDays as E } from "date-fns/subDays";
14
- import { formatISO as b } from "date-fns/formatISO";
15
- import { makeAutoObservable as p, runInAction as r } from "mobx";
14
+ import { formatISO as B } from "date-fns/formatISO";
15
+ import { makeAutoObservable as T, runInAction as r } from "mobx";
16
16
  var z = class {
17
17
  globalStore;
18
18
  uiStore;
@@ -41,7 +41,7 @@ var z = class {
41
41
  sortColumn = y.DATE;
42
42
  sortDirection = S.DESC;
43
43
  constructor(t) {
44
- this.globalStore = t, this.uiStore = new B(), this.api = new u(t.endpoint, t.sessionToken, t.onError), this.beatApi = new l(t.endpoint, t.sessionToken, t.onError), p(this);
44
+ this.globalStore = t, this.uiStore = new b(), this.api = new u(t.endpoint, t.sessionToken, t.onError), this.beatApi = new l(t.endpoint, t.sessionToken, t.onError), T(this);
45
45
  }
46
46
  loadTransactionData = async () => {
47
47
  this.globalStore.accountStore.isAccountDataLoaded || await this.globalStore.accountStore.loadAccountData(), this.globalStore.categoryStore.categoriesLoaded || await this.globalStore.categoryStore.loadCategories(), await Promise.all([
@@ -110,7 +110,7 @@ var z = class {
110
110
  };
111
111
  addOrUpdateTransactionRule = async (t, a) => {
112
112
  try {
113
- const s = this.transactionRules.find((e) => e.guid === a.user_transaction_rule_guid);
113
+ const s = this.transactionRules.find((i) => i.guid === a.user_transaction_rule_guid);
114
114
  return s ? await this.api.updateTransactionRule({
115
115
  ...s,
116
116
  category_guid: t,
@@ -128,8 +128,8 @@ var z = class {
128
128
  try {
129
129
  const a = await this.api.addTransaction(t);
130
130
  a && r(() => {
131
- this.setTransactions(f(this.transactions, a, !0));
132
- const s = a.transaction_type === T.CREDIT ? a.amount : -a.amount;
131
+ this.setTransactions(p(this.transactions, a, !0));
132
+ const s = a.transaction_type === f.CREDIT ? a.amount : -a.amount;
133
133
  this.globalStore.accountStore.updateAccountBalance(a.account_guid, s);
134
134
  });
135
135
  } catch (a) {
@@ -139,7 +139,7 @@ var z = class {
139
139
  loadAssociatedBeats = async (t) => {
140
140
  if (this.associatedBeatsLoading) return;
141
141
  this.associatedBeatsLoading = !0;
142
- const a = t ? b(t, { representation: "date" }) : void 0;
142
+ const a = t ? B(t, { representation: "date" }) : void 0;
143
143
  try {
144
144
  const s = await this.beatApi.getBeatsWithAssociatedTransaction(a);
145
145
  this.setAssociatedBeats(s);
@@ -253,19 +253,19 @@ var z = class {
253
253
  if (!this.transactionSplitting) {
254
254
  this.transactionSplitting = !0;
255
255
  try {
256
- const s = await this.api.updateTransaction(t), e = [];
257
- for (let i = 0; i < a.length; i++) {
258
- const o = await this.api.addTransaction(a[i]);
259
- e.push(o);
256
+ const s = await this.api.updateTransaction(t), i = [];
257
+ for (let e = 0; e < a.length; e++) {
258
+ const o = await this.api.addTransaction(a[e]);
259
+ i.push(o);
260
260
  }
261
- const n = this.transactions.findIndex((i) => i.guid === t.guid);
261
+ const n = this.transactions.findIndex((e) => e.guid === t.guid);
262
262
  if (n >= 0) {
263
- const i = this.transactions.filter((o) => o.guid !== t.guid && o.parent_guid !== t.guid);
263
+ const e = this.transactions.filter((o) => o.guid !== t.guid && o.parent_guid !== t.guid);
264
264
  this.setTransactions([
265
- ...i.slice(0, n),
265
+ ...e.slice(0, n),
266
266
  s,
267
- ...e,
268
- ...i.slice(n)
267
+ ...i,
268
+ ...e.slice(n)
269
269
  ]);
270
270
  }
271
271
  } catch (s) {
@@ -281,16 +281,16 @@ var z = class {
281
281
  await this.api.removeTransactionSplit(t);
282
282
  const s = [...this.transactions];
283
283
  a.forEach((n) => {
284
- const i = s.findIndex((o) => o.guid === n.guid);
285
- i >= 0 && s.splice(i, 1);
284
+ const e = s.findIndex((o) => o.guid === n.guid);
285
+ e >= 0 && s.splice(e, 1);
286
286
  });
287
- const e = s.findIndex((n) => n.guid === t);
287
+ const i = s.findIndex((n) => n.guid === t);
288
288
  r(() => {
289
- const n = s[e];
290
- n && (n.has_been_split = !1), e >= 0 && this.setTransactions([
291
- ...s.slice(0, e),
289
+ const n = s[i];
290
+ n && (n.has_been_split = !1), i >= 0 && this.setTransactions([
291
+ ...s.slice(0, i),
292
292
  n,
293
- ...s.slice(e + 1)
293
+ ...s.slice(i + 1)
294
294
  ]);
295
295
  });
296
296
  } catch (a) {
@@ -299,9 +299,9 @@ var z = class {
299
299
  };
300
300
  updateTaggings = async (t, a) => {
301
301
  try {
302
- const s = this.taggings.filter((i) => i.transaction_guid === a), e = new Set(s.map((i) => i.tag_guid)), n = new Set(t);
303
- for (const i of t) e.has(i) || await this.addTagging(i, a);
304
- for (const i of s) n.has(i.tag_guid) || await this.removeTagging(i.guid);
302
+ const s = this.taggings.filter((e) => e.transaction_guid === a), i = new Set(s.map((e) => e.tag_guid)), n = new Set(t);
303
+ for (const e of t) i.has(e) || await this.addTagging(e, a);
304
+ for (const e of s) n.has(e.tag_guid) || await this.removeTagging(e.guid);
305
305
  await this.loadTaggings();
306
306
  } catch (s) {
307
307
  this.captureError("updateTaggings", s);
@@ -316,7 +316,7 @@ var z = class {
316
316
  };
317
317
  updateTransaction = async (t) => {
318
318
  try {
319
- const a = await this.api.updateTransaction(t), s = this.transactions.findIndex((e) => e.guid === t.guid);
319
+ const a = await this.api.updateTransaction(t), s = this.transactions.findIndex((i) => i.guid === t.guid);
320
320
  return s >= 0 && this.setTransactions([
321
321
  ...this.transactions.slice(0, s),
322
322
  a,
@@ -326,6 +326,18 @@ var z = class {
326
326
  return this.captureError("updateTransaction", a), !1;
327
327
  }
328
328
  };
329
+ loadTransactionsByGuids = async (t) => {
330
+ const a = new Set(this.transactions.map((i) => i.guid)), s = t.filter((i) => !a.has(i));
331
+ if (s.length)
332
+ try {
333
+ const i = await this.api.getTransactionsByGuids(s);
334
+ r(() => {
335
+ this.transactions = i.reduce((n, e) => p(n, e), this.transactions);
336
+ });
337
+ } catch (i) {
338
+ this.captureError("loadTransactionsByGuids", i);
339
+ }
340
+ };
329
341
  loadEmbeddedInstanceTransactions = async (t) => {
330
342
  try {
331
343
  const a = await this.api.getTransactionsByDateRange(h(t), g(c()));
@@ -338,7 +350,7 @@ var z = class {
338
350
  store: "TransactionStore",
339
351
  action: t
340
352
  });
341
- }, B = class {
353
+ }, b = class {
342
354
  beginDate = d(/* @__PURE__ */ new Date());
343
355
  endDate = A(/* @__PURE__ */ new Date());
344
356
  expandedSplits = [];
@@ -351,7 +363,7 @@ var z = class {
351
363
  isAmountValid = !1;
352
364
  showInsights = !1;
353
365
  constructor() {
354
- p(this);
366
+ T(this);
355
367
  }
356
368
  setDateRange = (t, a) => {
357
369
  this.beginDate = t, this.endDate = a;
@@ -367,7 +379,7 @@ var z = class {
367
379
  this.height = t, this.width = a;
368
380
  };
369
381
  toggleSplit = (t) => {
370
- const a = [...this.expandedSplits], s = this.expandedSplits.findIndex((e) => e === t);
382
+ const a = [...this.expandedSplits], s = this.expandedSplits.findIndex((i) => i === t);
371
383
  s >= 0 ? a.splice(s, 1) : a.push(t), this.expandedSplits = a;
372
384
  };
373
385
  clearExpandedSplits = () => {
@@ -379,7 +391,7 @@ var z = class {
379
391
  };
380
392
  export {
381
393
  z as TransactionStore,
382
- B as UiStore
394
+ b as UiStore
383
395
  };
384
396
 
385
397
  //# sourceMappingURL=TransactionStore.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TransactionStore.es.js","names":[],"sources":["../../../src/core/stores/TransactionStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { formatISO } from 'date-fns/formatISO'\nimport { isBefore } from 'date-fns/isBefore'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { startOfToday } from 'date-fns/startOfToday'\nimport { subDays } from 'date-fns/subDays'\n\nimport { endOfUtcDay, startOfUtcDay } from '../utils/DateUtil'\n\nimport { BeatApi, TransactionApi } from '../api'\nimport { TABLE_CONST } from '../constants/Table'\nimport { COLUMN_NAMES, DEFAULT_TRANSACTION } from '../constants/Transaction'\nimport { TransactionType } from '../types'\nimport type { Beat, Tag, Tagging, Transaction, TransactionRule } from '../types'\nimport {\n buildDetailedTransactions,\n flattenTransactionsWithSplits,\n sortAndFilterTransactions,\n} from '../utils/TransactionUtils'\n\nimport { GlobalStore } from './GlobalStore'\nimport { upsertByGuid } from '../utils/upsertByGuid'\n\nexport type TransactionFilter = {\n accounts?: string[]\n dateRange?: { start: Date; end: Date }\n custom?: (value: Transaction) => boolean\n searchTerm?: string\n showSplits?: boolean\n}\n\nexport class TransactionStore {\n globalStore: GlobalStore\n uiStore: UiStore\n api = new TransactionApi('/', '')\n beatApi = new BeatApi('/', '')\n\n associatedBeats: Beat[] = []\n associatedBeatsLoaded: boolean = false\n associatedBeatsLoading: boolean = false\n transactions: Transaction[] = []\n transactionsLoaded: boolean = false\n transactionsLoading: boolean = false\n taggings: Tagging[] = []\n taggingsLoaded: boolean = false\n taggingsLoading: boolean = false\n tags: Tag[] = []\n tagsLoaded: boolean = false\n tagsLoading: boolean = false\n transactionRules: TransactionRule[] = []\n transactionRulesLoaded: boolean = false\n transactionRulesLoading: boolean = false\n transactionSplitting: boolean = false\n\n cachedStartDate: Date = subDays(startOfToday(), 90)\n filter: TransactionFilter = {}\n isLoading = true\n\n alert = ''\n\n sortColumn = COLUMN_NAMES.DATE\n sortDirection = TABLE_CONST.DESC\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.uiStore = new UiStore()\n this.api = new TransactionApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n this.beatApi = new BeatApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n loadTransactionData = async () => {\n if (!this.globalStore.accountStore.isAccountDataLoaded) {\n await this.globalStore.accountStore.loadAccountData()\n }\n if (!this.globalStore.categoryStore.categoriesLoaded) {\n await this.globalStore.categoryStore.loadCategories()\n }\n await Promise.all([\n this.loadAssociatedBeats(startOfMonth(new Date())),\n this.loadTags(),\n this.loadTaggings(),\n this.loadTransactionRules(),\n // By default loads 90 days of transactions\n this.loadTransactions(this.cachedStartDate),\n ])\n }\n\n // Fills in whatever `isTransactionDataLoaded` still waits for and leaves every list a host already\n // seeded (`GlobalStore.loadData`) as it is.\n loadMissingTransactionData = async () => {\n if (!this.globalStore.accountStore.isAccountDataLoaded) {\n await this.globalStore.accountStore.loadAccountData()\n }\n if (!this.globalStore.categoryStore.categoriesLoaded) {\n await this.globalStore.categoryStore.loadCategories()\n }\n await Promise.all([\n this.associatedBeatsLoaded || this.loadAssociatedBeats(startOfMonth(new Date())),\n this.tagsLoaded || this.loadTags(),\n this.taggingsLoaded || this.loadTaggings(),\n this.transactionRulesLoaded || this.loadTransactionRules(),\n this.transactionsLoaded || this.loadTransactions(this.cachedStartDate),\n ])\n }\n\n get isTransactionDataLoaded(): boolean {\n return (\n this.associatedBeatsLoaded &&\n this.tagsLoaded &&\n this.taggingsLoaded &&\n this.transactionRulesLoaded &&\n this.transactionsLoaded\n )\n }\n\n get detailedTransactions(): Transaction[] {\n return this.isTransactionDataLoaded\n ? buildDetailedTransactions(\n this.transactions,\n this.globalStore.accountStore.visibleAccounts,\n this.globalStore.categoryStore.categories,\n this.taggings,\n this.globalStore.copyStore.copy.categories,\n )\n : []\n }\n\n get sortedTransactions(): Transaction[] {\n return sortAndFilterTransactions(\n this.filter,\n this.uiStore.expandedSplits,\n this.sortColumn,\n this.sortDirection,\n this.tags,\n this.detailedTransactions,\n )\n }\n\n get sortedTransactionsWithSplits(): Transaction[] {\n return flattenTransactionsWithSplits(this.sortedTransactions, this.detailedTransactions)\n }\n\n setAssociatedBeats = (beats: Beat[]) => {\n this.associatedBeats = beats\n this.associatedBeatsLoading = false\n this.associatedBeatsLoaded = true\n }\n\n setTaggings = (taggings: Tagging[]) => {\n this.taggings = taggings\n this.taggingsLoading = false\n this.taggingsLoaded = true\n }\n\n setTags = (tags: Tag[]) => {\n this.tags = tags\n this.tagsLoading = false\n this.tagsLoaded = true\n }\n\n setTransactionRules = (transactionRules: TransactionRule[]) => {\n this.transactionRules = transactionRules\n this.transactionRulesLoading = false\n this.transactionRulesLoaded = true\n }\n\n setTransactions = (transactions: Transaction[]) => {\n this.transactions = transactions\n this.transactionsLoading = false\n this.transactionsLoaded = true\n }\n\n setAlert = (alert: string) => {\n this.alert = alert\n }\n\n addTag = async (name: string) => {\n try {\n await this.api.addTag({ name } as Tag)\n await this.loadTags()\n } catch (error) {\n this.captureError('addTag', error)\n }\n }\n\n addTagging = async (tagGuid: string, transactionGuid: string) => {\n try {\n await this.api.addTagging({\n tag_guid: tagGuid,\n transaction_guid: transactionGuid,\n } as Tagging)\n } catch (error) {\n this.captureError('addTagging', error)\n }\n }\n\n /** Resolves `true` when the rule was saved, `false` when an API call failed. */\n addOrUpdateTransactionRule = async (\n categoryGuid: string,\n transaction: Transaction,\n ): Promise<boolean> => {\n try {\n const existingRule = this.transactionRules.find(\n (rule: TransactionRule) => rule.guid === transaction.user_transaction_rule_guid,\n ) as TransactionRule | undefined\n\n if (existingRule) {\n await this.api.updateTransactionRule({\n ...existingRule,\n category_guid: categoryGuid,\n description: transaction.description,\n } as TransactionRule)\n } else {\n await this.api.addTransactionRule({\n category_guid: categoryGuid,\n description: transaction.description,\n match_description: transaction.description,\n } as TransactionRule)\n }\n await this.loadTransactionRules()\n return true\n } catch (error) {\n this.captureError('addOrUpdateTransactionRule', error)\n return false\n }\n }\n\n addTransaction = async (transaction: Transaction) => {\n try {\n const newTransaction = await this.api.addTransaction(transaction)\n\n if (newTransaction) {\n runInAction(() => {\n this.setTransactions(upsertByGuid(this.transactions, newTransaction, true))\n\n // Brokaw may insert the transaction via WebSocket, but it never\n // updates the account balance — that only happens here.\n // See: money-dashboard/src/util/BrokawClient.ts::handleTransactionEvents (search \"setTransactions\")\n // If that handler ever calls updateAccountBalance, remove this call or guard on !existing.\n const balanceChange =\n newTransaction.transaction_type === TransactionType.CREDIT\n ? newTransaction.amount\n : -newTransaction.amount\n\n this.globalStore.accountStore.updateAccountBalance(\n newTransaction.account_guid,\n balanceChange,\n )\n })\n }\n } catch (error) {\n this.captureError('addTransaction', error)\n }\n }\n\n loadAssociatedBeats = async (fromDate?: Date) => {\n if (this.associatedBeatsLoading) return\n\n this.associatedBeatsLoading = true\n const fromDateISO = fromDate ? formatISO(fromDate, { representation: 'date' }) : undefined\n try {\n const beats = await this.beatApi.getBeatsWithAssociatedTransaction(fromDateISO)\n this.setAssociatedBeats(beats)\n } catch (error) {\n this.captureError('loadAssociatedBeats', error)\n this.setAssociatedBeats([])\n } finally {\n // Clear the in-flight flag even on failure so a later load (e.g. a widget\n // remount) can retry instead of being no-oped by the guard above, which would\n // leave isTransactionDataLoaded false and the list empty until a hard refresh.\n runInAction(() => {\n this.associatedBeatsLoading = false\n })\n }\n }\n\n loadTags = async () => {\n if (this.tagsLoading) return\n\n this.tagsLoading = true\n try {\n const tags = await this.api.getTags()\n this.setTags(tags)\n } catch (error) {\n this.captureError('loadTags', error)\n } finally {\n runInAction(() => {\n this.tagsLoading = false\n })\n }\n }\n\n loadTaggings = async () => {\n if (this.taggingsLoading) return\n\n this.taggingsLoading = true\n try {\n const taggings = await this.api.getTaggings()\n this.setTaggings(taggings)\n } catch (error) {\n this.captureError('loadTaggings', error)\n this.setTaggings([])\n } finally {\n runInAction(() => {\n this.taggingsLoading = false\n })\n }\n }\n\n loadTransactionRules = async () => {\n if (this.transactionRulesLoading) return\n\n this.transactionRulesLoading = true\n try {\n const transactionRules = await this.api.getTransactionRules()\n this.setTransactionRules(transactionRules)\n } catch (error) {\n // Catch so a rejection can't abort the Promise.all in loadTransactionData.\n this.captureError('loadTransactionRules', error)\n this.setTransactionRules([])\n } finally {\n runInAction(() => {\n this.transactionRulesLoading = false\n })\n }\n }\n\n loadTransactions = async (startDate: Date = this.cachedStartDate) => {\n if (this.transactionsLoading) return\n\n this.setIsLoading(true)\n this.transactionsLoading = true\n\n try {\n const transactions = await this.api.getTransactionsByDateRange(\n startOfUtcDay(startDate),\n endOfUtcDay(startOfToday()),\n )\n this.setTransactions(transactions)\n // Advance the cache only after the range is actually loaded, so the invariant\n // \"we hold transactions back to cachedStartDate\" always holds.\n runInAction(() => {\n this.cachedStartDate = startDate\n })\n } catch (error) {\n this.captureError('loadTransactions', error)\n } finally {\n // See loadAssociatedBeats: clear the flag on failure so retries aren't no-oped.\n runInAction(() => {\n this.transactionsLoading = false\n })\n this.setIsLoading(false)\n }\n }\n\n modifyTransactionByAccountGuid = (guid: string, updates: Partial<Transaction>) => {\n this.transactions = this.transactions.map((txn) =>\n txn.account_guid === guid ? { ...txn, ...updates } : txn,\n )\n }\n\n removeTag = async (tagGuid: string) => {\n try {\n await this.api.removeTag(tagGuid)\n await this.loadTags()\n } catch (error) {\n this.captureError('removeTag', error)\n }\n }\n\n removeTagging = async (taggingGuid: string) => {\n try {\n await this.api.removeTagging(taggingGuid)\n } catch (error) {\n this.captureError('removeTagging', error)\n }\n }\n\n removeTransaction = async (transactionGuid: string) => {\n try {\n await this.api.removeTransaction(transactionGuid)\n\n const index = this.transactions.findIndex((t: Transaction) => t.guid === transactionGuid)\n\n if (index >= 0) {\n const updatedTransactions = [...this.transactions]\n updatedTransactions.splice(index, 1)\n this.setTransactions(updatedTransactions)\n }\n } catch (error) {\n this.captureError('removeTransaction', error)\n }\n }\n\n setFilter = (filter: TransactionFilter) => {\n this.filter = filter\n\n // Only reload if the new start date is prior to the cached start date; end date\n // is always today. loadTransactions advances cachedStartDate on success, so we\n // must not advance it here (a skipped/failed load would leave the list empty).\n if (filter.dateRange && isBefore(filter.dateRange.start, this.cachedStartDate)) {\n this.loadTransactions(filter.dateRange.start)\n }\n }\n\n setIsLoading = (isLoading: boolean) => (this.isLoading = isLoading)\n\n splitTransaction = async (transaction: Transaction, splits: Transaction[]) => {\n if (this.transactionSplitting) return\n this.transactionSplitting = true\n\n try {\n const updatedTransaction = await this.api.updateTransaction(transaction)\n const children = [] as Transaction[]\n\n for (let i = 0; i < splits.length; i++) {\n const child = await this.api.addTransaction(splits[i])\n children.push(child)\n }\n\n const index = this.transactions.findIndex((t: Transaction) => t.guid === transaction.guid)\n\n if (index >= 0) {\n // Remove old parent and any existing children\n const filtered = this.transactions.filter(\n (t) => t.guid !== transaction.guid && t.parent_guid !== transaction.guid,\n )\n\n // Insert updated parent + new children at original position\n this.setTransactions([\n ...filtered.slice(0, index),\n updatedTransaction,\n ...children,\n ...filtered.slice(index),\n ])\n }\n } catch (error) {\n this.captureError('splitTransaction', error)\n throw error\n } finally {\n this.transactionSplitting = false\n }\n }\n\n unSplitTransaction = async (guid: string) => {\n try {\n const children = this.transactions.filter((t) => t.parent_guid === guid)\n\n await this.api.removeTransactionSplit(guid)\n\n // Remove children\n const transactions = [...this.transactions]\n children.forEach((child) => {\n const index = transactions.findIndex((t) => t.guid === child.guid)\n\n if (index >= 0) {\n transactions.splice(index, 1)\n }\n })\n\n // Update parent\n const index = transactions.findIndex((t) => t.guid === guid)\n\n runInAction(() => {\n const transaction = transactions[index]\n if (transaction) {\n transaction.has_been_split = false\n }\n\n if (index >= 0) {\n this.setTransactions([\n ...transactions.slice(0, index),\n transaction,\n ...transactions.slice(index + 1),\n ])\n }\n })\n } catch (error) {\n this.captureError('unSplitTransaction', error)\n }\n }\n\n updateTaggings = async (tagGuids: string[], transactionGuid: string) => {\n try {\n const currentTaggings = this.taggings.filter((t) => t.transaction_guid === transactionGuid)\n\n const currentTagGuids = new Set(currentTaggings.map((t) => t.tag_guid))\n const incomingTagGuids = new Set(tagGuids)\n\n // Add new taggings that don't already exist\n for (const tagGuid of tagGuids) {\n if (!currentTagGuids.has(tagGuid)) {\n await this.addTagging(tagGuid, transactionGuid)\n }\n }\n\n // Remove taggings that are no longer needed\n for (const tagging of currentTaggings) {\n if (!incomingTagGuids.has(tagging.tag_guid)) {\n await this.removeTagging(tagging.guid)\n }\n }\n\n await this.loadTaggings()\n } catch (error) {\n this.captureError('updateTaggings', error)\n }\n }\n\n updateTag = async (tag: Tag) => {\n try {\n await this.api.updateTag(tag)\n await this.loadTags()\n } catch (error) {\n this.captureError('updateTag', error)\n }\n }\n\n /** Resolves `true` when the transaction was saved, `false` when the API call failed. */\n updateTransaction = async (transaction: Transaction): Promise<boolean> => {\n try {\n const updatedTransaction = await this.api.updateTransaction(transaction)\n\n const index = this.transactions.findIndex((t: Transaction) => t.guid === transaction.guid)\n\n if (index >= 0) {\n this.setTransactions([\n ...this.transactions.slice(0, index),\n updatedTransaction,\n ...this.transactions.slice(index + 1),\n ])\n }\n return true\n } catch (error) {\n this.captureError('updateTransaction', error)\n return false\n }\n }\n\n // This is used for loading the transactions list on demand, on clicking the different transactions of the insightful beats.\n loadEmbeddedInstanceTransactions = async (fromDate: Date) => {\n try {\n const transactions = await this.api.getTransactionsByDateRange(\n startOfUtcDay(fromDate),\n endOfUtcDay(startOfToday()),\n )\n this.cachedStartDate = fromDate\n this.transactions = transactions\n } catch (error) {\n this.captureError('loadEmbeddedInstanceTransactions', error)\n }\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'TransactionStore', action })\n}\n\nexport class UiStore {\n beginDate = startOfMonth(new Date())\n endDate = endOfMonth(new Date())\n\n expandedSplits = [] as string[]\n height = 550\n width = 1000\n shouldDisableDrawerScroll = false\n\n searchValue = ''\n selectedAccountGuids = [] as string[]\n\n manualTransaction: Transaction = DEFAULT_TRANSACTION\n isAmountValid = false\n\n showInsights = false\n\n constructor() {\n makeAutoObservable(this)\n }\n\n setDateRange = (beginDate: Date, endDate: Date) => {\n this.beginDate = beginDate\n this.endDate = endDate\n }\n\n setIsAmountValid = (valid: boolean) => (this.isAmountValid = valid)\n\n setSearchValue = (searchValue: string) => (this.searchValue = searchValue)\n\n setSelectedAccountGuids = (accountGuids: string[]) => (this.selectedAccountGuids = accountGuids)\n\n setShouldDisableDrawerScroll = (shouldDisable: boolean) =>\n (this.shouldDisableDrawerScroll = shouldDisable)\n\n setShowInsights = (showInsights: boolean) => {\n this.showInsights = showInsights\n }\n\n setSize = (height: number, width: number) => {\n this.height = height\n this.width = width\n }\n\n toggleSplit = (guid: string) => {\n const expandedSplits = [...this.expandedSplits]\n const index = this.expandedSplits.findIndex((splitGuid) => splitGuid === guid)\n\n if (index >= 0) {\n expandedSplits.splice(index, 1)\n } else {\n expandedSplits.push(guid)\n }\n\n this.expandedSplits = expandedSplits\n }\n\n clearExpandedSplits = () => {\n if (this.expandedSplits.length === 0) return\n this.expandedSplits = []\n }\n\n updateManualTransaction = (manualTransaction: Transaction) => {\n this.manualTransaction = manualTransaction\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgCA,IAAa,IAAb,MAA8B;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,MAAM,IAAI,EAAe,KAAK,EAAE;AAAA,EAChC,UAAU,IAAI,EAAQ,KAAK,EAAE;AAAA,EAE7B,kBAA0B,CAAC;AAAA,EAC3B,wBAAiC;AAAA,EACjC,yBAAkC;AAAA,EAClC,eAA8B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iB,CAAC;AAAA,EACzB;AAAA,EAEA,0BAAA,CAA2B,MAAmC;AAC5D,SAAK,oBAAoB;AAAA,EAC3B;AACF"}
1
+ {"version":3,"file":"TransactionStore.es.js","names":[],"sources":["../../../src/core/stores/TransactionStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { formatISO } from 'date-fns/formatISO'\nimport { isBefore } from 'date-fns/isBefore'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { startOfToday } from 'date-fns/startOfToday'\nimport { subDays } from 'date-fns/subDays'\n\nimport { endOfUtcDay, startOfUtcDay } from '../utils/DateUtil'\n\nimport { BeatApi, TransactionApi } from '../api'\nimport { TABLE_CONST } from '../constants/Table'\nimport { COLUMN_NAMES, DEFAULT_TRANSACTION } from '../constants/Transaction'\nimport { TransactionType } from '../types'\nimport type { Beat, Tag, Tagging, Transaction, TransactionRule } from '../types'\nimport {\n buildDetailedTransactions,\n flattenTransactionsWithSplits,\n sortAndFilterTransactions,\n} from '../utils/TransactionUtils'\n\nimport { GlobalStore } from './GlobalStore'\nimport { upsertByGuid } from '../utils/upsertByGuid'\n\nexport type TransactionFilter = {\n accounts?: string[]\n dateRange?: { start: Date; end: Date }\n custom?: (value: Transaction) => boolean\n searchTerm?: string\n showSplits?: boolean\n}\n\nexport class TransactionStore {\n globalStore: GlobalStore\n uiStore: UiStore\n api = new TransactionApi('/', '')\n beatApi = new BeatApi('/', '')\n\n associatedBeats: Beat[] = []\n associatedBeatsLoaded: boolean = false\n associatedBeatsLoading: boolean = false\n transactions: Transaction[] = []\n transactionsLoaded: boolean = false\n transactionsLoading: boolean = false\n taggings: Tagging[] = []\n taggingsLoaded: boolean = false\n taggingsLoading: boolean = false\n tags: Tag[] = []\n tagsLoaded: boolean = false\n tagsLoading: boolean = false\n transactionRules: TransactionRule[] = []\n transactionRulesLoaded: boolean = false\n transactionRulesLoading: boolean = false\n transactionSplitting: boolean = false\n\n cachedStartDate: Date = subDays(startOfToday(), 90)\n filter: TransactionFilter = {}\n isLoading = true\n\n alert = ''\n\n sortColumn = COLUMN_NAMES.DATE\n sortDirection = TABLE_CONST.DESC\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.uiStore = new UiStore()\n this.api = new TransactionApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n this.beatApi = new BeatApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n loadTransactionData = async () => {\n if (!this.globalStore.accountStore.isAccountDataLoaded) {\n await this.globalStore.accountStore.loadAccountData()\n }\n if (!this.globalStore.categoryStore.categoriesLoaded) {\n await this.globalStore.categoryStore.loadCategories()\n }\n await Promise.all([\n this.loadAssociatedBeats(startOfMonth(new Date())),\n this.loadTags(),\n this.loadTaggings(),\n this.loadTransactionRules(),\n // By default loads 90 days of transactions\n this.loadTransactions(this.cachedStartDate),\n ])\n }\n\n // Fills in whatever `isTransactionDataLoaded` still waits for and leaves every list a host already\n // seeded (`GlobalStore.loadData`) as it is.\n loadMissingTransactionData = async () => {\n if (!this.globalStore.accountStore.isAccountDataLoaded) {\n await this.globalStore.accountStore.loadAccountData()\n }\n if (!this.globalStore.categoryStore.categoriesLoaded) {\n await this.globalStore.categoryStore.loadCategories()\n }\n await Promise.all([\n this.associatedBeatsLoaded || this.loadAssociatedBeats(startOfMonth(new Date())),\n this.tagsLoaded || this.loadTags(),\n this.taggingsLoaded || this.loadTaggings(),\n this.transactionRulesLoaded || this.loadTransactionRules(),\n this.transactionsLoaded || this.loadTransactions(this.cachedStartDate),\n ])\n }\n\n get isTransactionDataLoaded(): boolean {\n return (\n this.associatedBeatsLoaded &&\n this.tagsLoaded &&\n this.taggingsLoaded &&\n this.transactionRulesLoaded &&\n this.transactionsLoaded\n )\n }\n\n get detailedTransactions(): Transaction[] {\n return this.isTransactionDataLoaded\n ? buildDetailedTransactions(\n this.transactions,\n this.globalStore.accountStore.visibleAccounts,\n this.globalStore.categoryStore.categories,\n this.taggings,\n this.globalStore.copyStore.copy.categories,\n )\n : []\n }\n\n get sortedTransactions(): Transaction[] {\n return sortAndFilterTransactions(\n this.filter,\n this.uiStore.expandedSplits,\n this.sortColumn,\n this.sortDirection,\n this.tags,\n this.detailedTransactions,\n )\n }\n\n get sortedTransactionsWithSplits(): Transaction[] {\n return flattenTransactionsWithSplits(this.sortedTransactions, this.detailedTransactions)\n }\n\n setAssociatedBeats = (beats: Beat[]) => {\n this.associatedBeats = beats\n this.associatedBeatsLoading = false\n this.associatedBeatsLoaded = true\n }\n\n setTaggings = (taggings: Tagging[]) => {\n this.taggings = taggings\n this.taggingsLoading = false\n this.taggingsLoaded = true\n }\n\n setTags = (tags: Tag[]) => {\n this.tags = tags\n this.tagsLoading = false\n this.tagsLoaded = true\n }\n\n setTransactionRules = (transactionRules: TransactionRule[]) => {\n this.transactionRules = transactionRules\n this.transactionRulesLoading = false\n this.transactionRulesLoaded = true\n }\n\n setTransactions = (transactions: Transaction[]) => {\n this.transactions = transactions\n this.transactionsLoading = false\n this.transactionsLoaded = true\n }\n\n setAlert = (alert: string) => {\n this.alert = alert\n }\n\n addTag = async (name: string) => {\n try {\n await this.api.addTag({ name } as Tag)\n await this.loadTags()\n } catch (error) {\n this.captureError('addTag', error)\n }\n }\n\n addTagging = async (tagGuid: string, transactionGuid: string) => {\n try {\n await this.api.addTagging({\n tag_guid: tagGuid,\n transaction_guid: transactionGuid,\n } as Tagging)\n } catch (error) {\n this.captureError('addTagging', error)\n }\n }\n\n /** Resolves `true` when the rule was saved, `false` when an API call failed. */\n addOrUpdateTransactionRule = async (\n categoryGuid: string,\n transaction: Transaction,\n ): Promise<boolean> => {\n try {\n const existingRule = this.transactionRules.find(\n (rule: TransactionRule) => rule.guid === transaction.user_transaction_rule_guid,\n ) as TransactionRule | undefined\n\n if (existingRule) {\n await this.api.updateTransactionRule({\n ...existingRule,\n category_guid: categoryGuid,\n description: transaction.description,\n } as TransactionRule)\n } else {\n await this.api.addTransactionRule({\n category_guid: categoryGuid,\n description: transaction.description,\n match_description: transaction.description,\n } as TransactionRule)\n }\n await this.loadTransactionRules()\n return true\n } catch (error) {\n this.captureError('addOrUpdateTransactionRule', error)\n return false\n }\n }\n\n addTransaction = async (transaction: Transaction) => {\n try {\n const newTransaction = await this.api.addTransaction(transaction)\n\n if (newTransaction) {\n runInAction(() => {\n this.setTransactions(upsertByGuid(this.transactions, newTransaction, true))\n\n // Brokaw may insert the transaction via WebSocket, but it never\n // updates the account balance — that only happens here.\n // See: money-dashboard/src/util/BrokawClient.ts::handleTransactionEvents (search \"setTransactions\")\n // If that handler ever calls updateAccountBalance, remove this call or guard on !existing.\n const balanceChange =\n newTransaction.transaction_type === TransactionType.CREDIT\n ? newTransaction.amount\n : -newTransaction.amount\n\n this.globalStore.accountStore.updateAccountBalance(\n newTransaction.account_guid,\n balanceChange,\n )\n })\n }\n } catch (error) {\n this.captureError('addTransaction', error)\n }\n }\n\n loadAssociatedBeats = async (fromDate?: Date) => {\n if (this.associatedBeatsLoading) return\n\n this.associatedBeatsLoading = true\n const fromDateISO = fromDate ? formatISO(fromDate, { representation: 'date' }) : undefined\n try {\n const beats = await this.beatApi.getBeatsWithAssociatedTransaction(fromDateISO)\n this.setAssociatedBeats(beats)\n } catch (error) {\n this.captureError('loadAssociatedBeats', error)\n this.setAssociatedBeats([])\n } finally {\n // Clear the in-flight flag even on failure so a later load (e.g. a widget\n // remount) can retry instead of being no-oped by the guard above, which would\n // leave isTransactionDataLoaded false and the list empty until a hard refresh.\n runInAction(() => {\n this.associatedBeatsLoading = false\n })\n }\n }\n\n loadTags = async () => {\n if (this.tagsLoading) return\n\n this.tagsLoading = true\n try {\n const tags = await this.api.getTags()\n this.setTags(tags)\n } catch (error) {\n this.captureError('loadTags', error)\n } finally {\n runInAction(() => {\n this.tagsLoading = false\n })\n }\n }\n\n loadTaggings = async () => {\n if (this.taggingsLoading) return\n\n this.taggingsLoading = true\n try {\n const taggings = await this.api.getTaggings()\n this.setTaggings(taggings)\n } catch (error) {\n this.captureError('loadTaggings', error)\n this.setTaggings([])\n } finally {\n runInAction(() => {\n this.taggingsLoading = false\n })\n }\n }\n\n loadTransactionRules = async () => {\n if (this.transactionRulesLoading) return\n\n this.transactionRulesLoading = true\n try {\n const transactionRules = await this.api.getTransactionRules()\n this.setTransactionRules(transactionRules)\n } catch (error) {\n // Catch so a rejection can't abort the Promise.all in loadTransactionData.\n this.captureError('loadTransactionRules', error)\n this.setTransactionRules([])\n } finally {\n runInAction(() => {\n this.transactionRulesLoading = false\n })\n }\n }\n\n loadTransactions = async (startDate: Date = this.cachedStartDate) => {\n if (this.transactionsLoading) return\n\n this.setIsLoading(true)\n this.transactionsLoading = true\n\n try {\n const transactions = await this.api.getTransactionsByDateRange(\n startOfUtcDay(startDate),\n endOfUtcDay(startOfToday()),\n )\n this.setTransactions(transactions)\n // Advance the cache only after the range is actually loaded, so the invariant\n // \"we hold transactions back to cachedStartDate\" always holds.\n runInAction(() => {\n this.cachedStartDate = startDate\n })\n } catch (error) {\n this.captureError('loadTransactions', error)\n } finally {\n // See loadAssociatedBeats: clear the flag on failure so retries aren't no-oped.\n runInAction(() => {\n this.transactionsLoading = false\n })\n this.setIsLoading(false)\n }\n }\n\n modifyTransactionByAccountGuid = (guid: string, updates: Partial<Transaction>) => {\n this.transactions = this.transactions.map((txn) =>\n txn.account_guid === guid ? { ...txn, ...updates } : txn,\n )\n }\n\n removeTag = async (tagGuid: string) => {\n try {\n await this.api.removeTag(tagGuid)\n await this.loadTags()\n } catch (error) {\n this.captureError('removeTag', error)\n }\n }\n\n removeTagging = async (taggingGuid: string) => {\n try {\n await this.api.removeTagging(taggingGuid)\n } catch (error) {\n this.captureError('removeTagging', error)\n }\n }\n\n removeTransaction = async (transactionGuid: string) => {\n try {\n await this.api.removeTransaction(transactionGuid)\n\n const index = this.transactions.findIndex((t: Transaction) => t.guid === transactionGuid)\n\n if (index >= 0) {\n const updatedTransactions = [...this.transactions]\n updatedTransactions.splice(index, 1)\n this.setTransactions(updatedTransactions)\n }\n } catch (error) {\n this.captureError('removeTransaction', error)\n }\n }\n\n setFilter = (filter: TransactionFilter) => {\n this.filter = filter\n\n // Only reload if the new start date is prior to the cached start date; end date\n // is always today. loadTransactions advances cachedStartDate on success, so we\n // must not advance it here (a skipped/failed load would leave the list empty).\n if (filter.dateRange && isBefore(filter.dateRange.start, this.cachedStartDate)) {\n this.loadTransactions(filter.dateRange.start)\n }\n }\n\n setIsLoading = (isLoading: boolean) => (this.isLoading = isLoading)\n\n splitTransaction = async (transaction: Transaction, splits: Transaction[]) => {\n if (this.transactionSplitting) return\n this.transactionSplitting = true\n\n try {\n const updatedTransaction = await this.api.updateTransaction(transaction)\n const children = [] as Transaction[]\n\n for (let i = 0; i < splits.length; i++) {\n const child = await this.api.addTransaction(splits[i])\n children.push(child)\n }\n\n const index = this.transactions.findIndex((t: Transaction) => t.guid === transaction.guid)\n\n if (index >= 0) {\n // Remove old parent and any existing children\n const filtered = this.transactions.filter(\n (t) => t.guid !== transaction.guid && t.parent_guid !== transaction.guid,\n )\n\n // Insert updated parent + new children at original position\n this.setTransactions([\n ...filtered.slice(0, index),\n updatedTransaction,\n ...children,\n ...filtered.slice(index),\n ])\n }\n } catch (error) {\n this.captureError('splitTransaction', error)\n throw error\n } finally {\n this.transactionSplitting = false\n }\n }\n\n unSplitTransaction = async (guid: string) => {\n try {\n const children = this.transactions.filter((t) => t.parent_guid === guid)\n\n await this.api.removeTransactionSplit(guid)\n\n // Remove children\n const transactions = [...this.transactions]\n children.forEach((child) => {\n const index = transactions.findIndex((t) => t.guid === child.guid)\n\n if (index >= 0) {\n transactions.splice(index, 1)\n }\n })\n\n // Update parent\n const index = transactions.findIndex((t) => t.guid === guid)\n\n runInAction(() => {\n const transaction = transactions[index]\n if (transaction) {\n transaction.has_been_split = false\n }\n\n if (index >= 0) {\n this.setTransactions([\n ...transactions.slice(0, index),\n transaction,\n ...transactions.slice(index + 1),\n ])\n }\n })\n } catch (error) {\n this.captureError('unSplitTransaction', error)\n }\n }\n\n updateTaggings = async (tagGuids: string[], transactionGuid: string) => {\n try {\n const currentTaggings = this.taggings.filter((t) => t.transaction_guid === transactionGuid)\n\n const currentTagGuids = new Set(currentTaggings.map((t) => t.tag_guid))\n const incomingTagGuids = new Set(tagGuids)\n\n // Add new taggings that don't already exist\n for (const tagGuid of tagGuids) {\n if (!currentTagGuids.has(tagGuid)) {\n await this.addTagging(tagGuid, transactionGuid)\n }\n }\n\n // Remove taggings that are no longer needed\n for (const tagging of currentTaggings) {\n if (!incomingTagGuids.has(tagging.tag_guid)) {\n await this.removeTagging(tagging.guid)\n }\n }\n\n await this.loadTaggings()\n } catch (error) {\n this.captureError('updateTaggings', error)\n }\n }\n\n updateTag = async (tag: Tag) => {\n try {\n await this.api.updateTag(tag)\n await this.loadTags()\n } catch (error) {\n this.captureError('updateTag', error)\n }\n }\n\n /** Resolves `true` when the transaction was saved, `false` when the API call failed. */\n updateTransaction = async (transaction: Transaction): Promise<boolean> => {\n try {\n const updatedTransaction = await this.api.updateTransaction(transaction)\n\n const index = this.transactions.findIndex((t: Transaction) => t.guid === transaction.guid)\n\n if (index >= 0) {\n this.setTransactions([\n ...this.transactions.slice(0, index),\n updatedTransaction,\n ...this.transactions.slice(index + 1),\n ])\n }\n return true\n } catch (error) {\n this.captureError('updateTransaction', error)\n return false\n }\n }\n\n /**\n * Adds the given transactions by guid, fetching only those the store lacks: an insight drawer's\n * own transactions can be older than the date-range cache (pulse's BeatShell loads a legacy beat's\n * the same way). Leaves `cachedStartDate` alone, since the range itself is not loaded.\n */\n loadTransactionsByGuids = async (guids: string[]) => {\n const held = new Set(this.transactions.map((transaction) => transaction.guid))\n const missing = guids.filter((guid) => !held.has(guid))\n if (!missing.length) return\n\n try {\n const loaded: Transaction[] = await this.api.getTransactionsByGuids(missing)\n runInAction(() => {\n this.transactions = loaded.reduce(\n (transactions, transaction) => upsertByGuid(transactions, transaction),\n this.transactions,\n )\n })\n } catch (error) {\n this.captureError('loadTransactionsByGuids', error)\n }\n }\n\n // This is used for loading the transactions list on demand, on clicking the different transactions of the insightful beats.\n loadEmbeddedInstanceTransactions = async (fromDate: Date) => {\n try {\n const transactions = await this.api.getTransactionsByDateRange(\n startOfUtcDay(fromDate),\n endOfUtcDay(startOfToday()),\n )\n this.cachedStartDate = fromDate\n this.transactions = transactions\n } catch (error) {\n this.captureError('loadEmbeddedInstanceTransactions', error)\n }\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'TransactionStore', action })\n}\n\nexport class UiStore {\n beginDate = startOfMonth(new Date())\n endDate = endOfMonth(new Date())\n\n expandedSplits = [] as string[]\n height = 550\n width = 1000\n shouldDisableDrawerScroll = false\n\n searchValue = ''\n selectedAccountGuids = [] as string[]\n\n manualTransaction: Transaction = DEFAULT_TRANSACTION\n isAmountValid = false\n\n showInsights = false\n\n constructor() {\n makeAutoObservable(this)\n }\n\n setDateRange = (beginDate: Date, endDate: Date) => {\n this.beginDate = beginDate\n this.endDate = endDate\n }\n\n setIsAmountValid = (valid: boolean) => (this.isAmountValid = valid)\n\n setSearchValue = (searchValue: string) => (this.searchValue = searchValue)\n\n setSelectedAccountGuids = (accountGuids: string[]) => (this.selectedAccountGuids = accountGuids)\n\n setShouldDisableDrawerScroll = (shouldDisable: boolean) =>\n (this.shouldDisableDrawerScroll = shouldDisable)\n\n setShowInsights = (showInsights: boolean) => {\n this.showInsights = showInsights\n }\n\n setSize = (height: number, width: number) => {\n this.height = height\n this.width = width\n }\n\n toggleSplit = (guid: string) => {\n const expandedSplits = [...this.expandedSplits]\n const index = this.expandedSplits.findIndex((splitGuid) => splitGuid === guid)\n\n if (index >= 0) {\n expandedSplits.splice(index, 1)\n } else {\n expandedSplits.push(guid)\n }\n\n this.expandedSplits = expandedSplits\n }\n\n clearExpandedSplits = () => {\n if (this.expandedSplits.length === 0) return\n this.expandedSplits = []\n }\n\n updateManualTransaction = (manualTrans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AAA,EACzB;AAAA,EAEA,eAAA,CAAgB,GAAiB,MAAkB;AACjD,SAAK,YAAY,GACjB,KAAK,UAAU;AAAA,EACjB;AAAA,EAEA,mBAAA,CAAoB,MAAoB,KAAK,gBAAgB;AAAA,EAE7D,iBAAA,CAAkB,MAAyB,KAAK,cAAc;AAAA,EAE9D,0BAAA,CAA2B,MAA4B,KAAK,uBAAuB;AAAA,EAEnF,+BAAA,CAAgC,MAC7B,KAAK,4BAA4B;AAAA,EAEpC,kBAAA,CAAmB,MAA0B;AAC3C,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA,UAAA,CAAW,GAAgB,MAAkB;AAC3C,SAAK,SAAS,GACd,KAAK,QAAQ;AAAA,EACf;AAAA,EAEA,cAAA,CAAe,MAAiB;AAC9B,UAAM,IAAiB,CAAC,GAAG,KAAK,cAAc,GACxC,IAAQ,KAAK,eAAe,UAAA,CAAW,MAAc,MAAc,CAAI;AAE7E,IAAI,KAAS,IACX,EAAe,OAAO,GAAO,CAAC,IAE9B,EAAe,KAAK,CAAI,GAG1B,KAAK,iBAAiB;AAAA,EACxB;AAAA,EAEA,sBAAA,MAA4B;AAC1B,IAAI,KAAK,eAAe,WAAW,MACnC,KAAK,iBAAiB,CAAC;AAAA,EACzB;AAAA,EAEA,0BAAA,CAA2B,MAAmC;AAC5D,SAAK,oBAAoB;AAAA,EAC3B;AACF"}
@@ -16,6 +16,8 @@ interface GeneralInsightsFeedCopy {
16
16
  new_information_available: string;
17
17
  tip_section_message: string;
18
18
  tip_section_title: string;
19
+ /** Heads Upcoming Bill's projected-bill row in its drawer (legacy pulse's "PROJECTED AMOUNT"). */
20
+ projected_amount?: string;
19
21
  transaction_history_title: string;
20
22
  transaction_details_title: string;
21
23
  /**
@@ -108,6 +110,12 @@ export interface TransactionHistoryBlock {
108
110
  cost_living_to_income_drawer_title: string;
109
111
  non_essential_category_summary_drawer_title: string;
110
112
  monthly_deposit_summary_drawer_title: string;
113
+ /**
114
+ * The Upcoming Bill drawer's tip: `_1{tip}` the bold tip title, `_2{merchant}` the merchant and
115
+ * `_3{date}` the due date. Optional: until the localized-content service ships it (mrs_content
116
+ * 5.7.29), the drawer shows no tip.
117
+ */
118
+ upcoming_bill_tip_message?: string;
111
119
  }
112
120
  export interface HiddenConfirmationCopy {
113
121
  title: string;
@@ -20,8 +20,12 @@ interface TransactionDrillDownProps {
20
20
  transactionFilter?: (selectedIndex: number) => (transaction: Transaction) => boolean;
21
21
  baseTransactions?: Transaction[];
22
22
  subTabs?: Omit<SubTabsProps, 'id'>;
23
+ projectedRow?: {
24
+ heading: string;
25
+ transaction: Transaction;
26
+ };
23
27
  }
24
- export declare const TransactionDrillDown: (({ ariaLabel, heading, subHeadingText, icon, tabs, selectedIndex, top, onSelectionChange, transactionFilter, tipSection, onEachRowClick, baseTransactions, subTabs, }: TransactionDrillDownProps) => import("react/jsx-runtime").JSX.Element) & {
28
+ export declare const TransactionDrillDown: (({ ariaLabel, heading, subHeadingText, icon, tabs, selectedIndex, top, onSelectionChange, transactionFilter, tipSection, onEachRowClick, baseTransactions, subTabs, projectedRow, }: TransactionDrillDownProps) => import("react/jsx-runtime").JSX.Element) & {
25
29
  displayName: string;
26
30
  };
27
31
  export default TransactionDrillDown;
@@ -1,82 +1,84 @@
1
- import { useGlobalCopyStore as A, useGlobalUiStore as G, useTransactionStore as U } from "../../../common/context/hooks.es.js";
2
- import { exportTransactionsToCSV as E } from "../../../core/utils/TransactionUtils.es.js";
3
- import N from "../../../common/components/Loader.es.js";
4
- import R from "../../../transactions/components/shared/TransactionList.es.js";
5
- import { TipSection as V } from "../../../insights/components/shared/ChartDrawerTemplate/TipSection.es.js";
6
- import { SubTabs as q, subTabPanelProps as z } from "../../components/SubTabs.es.js";
1
+ import { useGlobalCopyStore as U, useGlobalUiStore as j, useTransactionStore as E } from "../../../common/context/hooks.es.js";
2
+ import { exportTransactionsToCSV as N } from "../../../core/utils/TransactionUtils.es.js";
3
+ import R from "../../../common/components/Loader.es.js";
4
+ import V from "../../../transactions/components/shared/transactionlist/TransactionRow.es.js";
5
+ import q from "../../../common/components/SubheaderRow.es.js";
6
+ import z from "../../../transactions/components/shared/TransactionList.es.js";
7
+ import { TipSection as J } from "../../../insights/components/shared/ChartDrawerTemplate/TipSection.es.js";
8
+ import { SubTabs as K, subTabPanelProps as M } from "../../components/SubTabs.es.js";
7
9
  import "react";
8
- import { observer as J } from "mobx-react-lite";
9
- import m from "@mui/material/Stack";
10
- import { H3 as K, Text as p } from "@mxenabled/mxui";
11
- import M from "@mui/material/Button";
12
- import { Icon as O } from "@mxenabled/mx-icons";
10
+ import { observer as O } from "mobx-react-lite";
11
+ import p from "@mui/material/Stack";
12
+ import { H3 as Q, Text as b } from "@mxenabled/mxui";
13
+ import X from "@mui/material/Button";
14
+ import { Icon as Y } from "@mxenabled/mx-icons";
13
15
  import { jsx as r, jsxs as o } from "react/jsx-runtime";
14
- import n from "@mui/material/Box";
15
- import Q from "@mui/material/Tab";
16
- import X from "@mui/material/Tabs";
17
- var y = "transaction-drill-down-panel", C = (b) => `transaction-details-tab-${b}`, S = "transaction-drill-down-series", br = J(function({ ariaLabel: _, heading: e, subHeadingText: s, icon: g, tabs: f, selectedIndex: l, top: w, onSelectionChange: D, transactionFilter: h, tipSection: v, onEachRowClick: B, baseTransactions: I, subTabs: x }) {
18
- const { transactions: c } = A(), { isCopyLoaded: L } = G(), { sortedTransactionsWithSplits: k, tags: P, detailedTransactions: W } = U();
19
- if (!L) return /* @__PURE__ */ r(N, {});
20
- const d = !!f?.length, t = x?.tabs.length ? x : void 0, $ = _ ?? c.transactions_title, j = (a, i) => {
21
- D?.(i);
22
- }, T = h ? (I ?? W).filter(h(l)) : void 0, u = T ?? k;
23
- return /* @__PURE__ */ o(n, {
16
+ import t from "@mui/material/Box";
17
+ import Z from "@mui/material/Tab";
18
+ import F from "@mui/material/Tabs";
19
+ var _ = "transaction-drill-down-panel", g = (f) => `transaction-details-tab-${f}`, y = "transaction-drill-down-series", Tr = O(function({ ariaLabel: C, heading: e, subHeadingText: s, icon: w, tabs: h, selectedIndex: l, top: D, onSelectionChange: B, transactionFilter: u, tipSection: v, onEachRowClick: I, baseTransactions: L, subTabs: T, projectedRow: c }) {
20
+ const { transactions: d } = U(), { isCopyLoaded: k } = j(), { sortedTransactionsWithSplits: P, tags: W, detailedTransactions: $ } = E();
21
+ if (!k) return /* @__PURE__ */ r(R, {});
22
+ const m = !!h?.length, a = T?.tabs.length ? T : void 0, A = C ?? d.transactions_title, G = (i, n) => {
23
+ B?.(n);
24
+ }, x = u ? (L ?? $).filter(u(l)) : void 0, S = x ?? P;
25
+ return /* @__PURE__ */ o(t, {
24
26
  sx: {
25
27
  bgcolor: "background.paper",
26
28
  width: "100%"
27
29
  },
28
- children: [d && /* @__PURE__ */ r(X, {
29
- "aria-label": $,
30
- onChange: j,
30
+ children: [m && /* @__PURE__ */ r(F, {
31
+ "aria-label": A,
32
+ onChange: G,
31
33
  value: l,
32
34
  variant: "fullWidth",
33
- children: f.map((a, i) => /* @__PURE__ */ r(Q, {
34
- "aria-controls": y,
35
- "aria-label": a.ariaLabel,
36
- id: C(i),
37
- label: a.label,
35
+ children: h.map((i, n) => /* @__PURE__ */ r(Z, {
36
+ "aria-controls": _,
37
+ "aria-label": i.ariaLabel,
38
+ id: g(n),
39
+ label: i.label,
38
40
  sx: {
39
41
  minWidth: "auto",
40
42
  px: 0
41
43
  }
42
- }, `${a.label}-${i}`))
43
- }), /* @__PURE__ */ o(n, {
44
- "aria-labelledby": d ? C(l) : void 0,
45
- id: y,
46
- role: d ? "tabpanel" : void 0,
44
+ }, `${i.label}-${n}`))
45
+ }), /* @__PURE__ */ o(t, {
46
+ "aria-labelledby": m ? g(l) : void 0,
47
+ id: _,
48
+ role: m ? "tabpanel" : void 0,
47
49
  children: [
48
- (e || s) && /* @__PURE__ */ o(m, {
50
+ (e || s) && /* @__PURE__ */ o(p, {
49
51
  sx: {
50
52
  gap: 4,
51
53
  pt: 16,
52
54
  px: 24
53
55
  },
54
- children: [e && /* @__PURE__ */ r(K, { children: e }), s && /* @__PURE__ */ o(m, {
56
+ children: [e && /* @__PURE__ */ r(Q, { children: e }), s && /* @__PURE__ */ o(p, {
55
57
  sx: {
56
58
  alignItems: "center",
57
59
  flexDirection: "row",
58
60
  gap: 8
59
61
  },
60
- children: [g, /* @__PURE__ */ r(p, {
62
+ children: [w, /* @__PURE__ */ r(b, {
61
63
  textTransform: "uppercase",
62
64
  variant: "body2",
63
65
  children: s
64
66
  })]
65
67
  })]
66
68
  }),
67
- /* @__PURE__ */ r(n, {
69
+ /* @__PURE__ */ r(t, {
68
70
  sx: { pt: 16 },
69
- children: w
71
+ children: D
70
72
  }),
71
- t && /* @__PURE__ */ r(q, {
72
- ...t,
73
- id: S
73
+ a && /* @__PURE__ */ r(K, {
74
+ ...a,
75
+ id: y
74
76
  }),
75
- /* @__PURE__ */ o(n, {
76
- ...t && z(S, t.selectedIndex),
77
+ /* @__PURE__ */ o(t, {
78
+ ...a && M(y, a.selectedIndex),
77
79
  children: [
78
- v && /* @__PURE__ */ r(V, { ...v }),
79
- /* @__PURE__ */ o(m, {
80
+ v && /* @__PURE__ */ r(J, { ...v }),
81
+ /* @__PURE__ */ o(p, {
80
82
  sx: {
81
83
  alignItems: "center",
82
84
  borderBottomColor: "divider",
@@ -88,26 +90,29 @@ var y = "transaction-drill-down-panel", C = (b) => `transaction-details-tab-${b}
88
90
  pt: 16,
89
91
  px: 24
90
92
  },
91
- children: [/* @__PURE__ */ r(p, {
93
+ children: [/* @__PURE__ */ r(b, {
92
94
  bold: !0,
93
95
  variant: "body1",
94
- children: c.transactions_title
95
- }), u.length > 0 && /* @__PURE__ */ r(M, {
96
+ children: d.transactions_title
97
+ }), S.length > 0 && /* @__PURE__ */ r(X, {
96
98
  onClick: () => {
97
- E(u, P);
99
+ N(S, W);
98
100
  },
99
- startIcon: /* @__PURE__ */ r(O, { name: "ios_share" }),
101
+ startIcon: /* @__PURE__ */ r(Y, { name: "ios_share" }),
100
102
  sx: { height: 28 },
101
- children: /* @__PURE__ */ r(p, {
103
+ children: /* @__PURE__ */ r(b, {
102
104
  bold: !0,
103
105
  variant: "body2",
104
- children: c.export_csv_btn
106
+ children: d.export_csv_btn
105
107
  })
106
108
  })]
107
109
  }),
108
- /* @__PURE__ */ r(R, {
109
- transaction: T,
110
- onClick: B
110
+ c ? /* @__PURE__ */ o(t, { children: [/* @__PURE__ */ r(q, { children: c.heading }), /* @__PURE__ */ r(V, {
111
+ component: "div",
112
+ transaction: c.transaction
113
+ })] }) : /* @__PURE__ */ r(z, {
114
+ transaction: x,
115
+ onClick: I
111
116
  })
112
117
  ]
113
118
  })
@@ -116,8 +121,8 @@ var y = "transaction-drill-down-panel", C = (b) => `transaction-details-tab-${b}
116
121
  });
117
122
  });
118
123
  export {
119
- br as TransactionDrillDown,
120
- br as default
124
+ Tr as TransactionDrillDown,
125
+ Tr as default
121
126
  };
122
127
 
123
128
  //# sourceMappingURL=TransactionDrillDown.es.js.map