@things-factory/accounting 10.1.206 → 10.1.209

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 (76) hide show
  1. package/dist-server/activities/activity-expenditure.js +5 -2
  2. package/dist-server/activities/activity-expenditure.js.map +1 -1
  3. package/dist-server/service/account/account-match.d.ts +4 -5
  4. package/dist-server/service/account/account-match.js +7 -8
  5. package/dist-server/service/account/account-match.js.map +1 -1
  6. package/dist-server/service/account/account-mutation.js +5 -7
  7. package/dist-server/service/account/account-mutation.js.map +1 -1
  8. package/dist-server/service/account/account-service.d.ts +5 -0
  9. package/dist-server/service/account/account-service.js +17 -0
  10. package/dist-server/service/account/account-service.js.map +1 -0
  11. package/dist-server/service/bank-account/bank-account-service.d.ts +4 -1
  12. package/dist-server/service/bank-account/bank-account-service.js +5 -1
  13. package/dist-server/service/bank-account/bank-account-service.js.map +1 -1
  14. package/dist-server/service/expenditure-request/expenditure-request-item.d.ts +4 -3
  15. package/dist-server/service/expenditure-request/expenditure-request-item.js +6 -5
  16. package/dist-server/service/expenditure-request/expenditure-request-item.js.map +1 -1
  17. package/dist-server/service/expenditure-request/expenditure-request-mutation.d.ts +2 -2
  18. package/dist-server/service/expenditure-request/expenditure-request-mutation.js +13 -11
  19. package/dist-server/service/expenditure-request/expenditure-request-mutation.js.map +1 -1
  20. package/dist-server/service/expenditure-request/expenditure-request-query.d.ts +9 -2
  21. package/dist-server/service/expenditure-request/expenditure-request-query.js +28 -6
  22. package/dist-server/service/expenditure-request/expenditure-request-query.js.map +1 -1
  23. package/dist-server/service/expenditure-request/expenditure-request-service.d.ts +14 -4
  24. package/dist-server/service/expenditure-request/expenditure-request-service.js +47 -9
  25. package/dist-server/service/expenditure-request/expenditure-request-service.js.map +1 -1
  26. package/dist-server/service/expenditure-request/expenditure-request-type.d.ts +1 -1
  27. package/dist-server/service/expenditure-request/expenditure-request-type.js +3 -3
  28. package/dist-server/service/expenditure-request/expenditure-request-type.js.map +1 -1
  29. package/dist-server/service/expenditure-request/receipt-reader.d.ts +18 -9
  30. package/dist-server/service/expenditure-request/receipt-reader.js +19 -10
  31. package/dist-server/service/expenditure-request/receipt-reader.js.map +1 -1
  32. package/dist-server/service/index.d.ts +1 -0
  33. package/dist-server/service/index.js +1 -0
  34. package/dist-server/service/index.js.map +1 -1
  35. package/dist-server/service/payment/index.js +3 -0
  36. package/dist-server/service/payment/index.js.map +1 -1
  37. package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.d.ts +0 -1
  38. package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.js +0 -17
  39. package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.js.map +1 -1
  40. package/dist-server/service/recurring-cash-item/recurring-cash-item-service.d.ts +4 -8
  41. package/dist-server/service/recurring-cash-item/recurring-cash-item-service.js +5 -38
  42. package/dist-server/service/recurring-cash-item/recurring-cash-item-service.js.map +1 -1
  43. package/dist-server/service/recurring-cash-item/recurring-cash-item-type.js +1 -1
  44. package/dist-server/service/recurring-cash-item/recurring-cash-item-type.js.map +1 -1
  45. package/dist-server/service/recurring-cash-item/recurring-cash-item.d.ts +2 -2
  46. package/dist-server/service/recurring-cash-item/recurring-cash-item.js +5 -5
  47. package/dist-server/service/recurring-cash-item/recurring-cash-item.js.map +1 -1
  48. package/dist-server/service/recurring-cash-item/recurring-schedule.d.ts +6 -18
  49. package/dist-server/service/recurring-cash-item/recurring-schedule.js +13 -26
  50. package/dist-server/service/recurring-cash-item/recurring-schedule.js.map +1 -1
  51. package/dist-server/service/transaction/transaction-history.d.ts +1 -7
  52. package/dist-server/service/transaction/transaction-history.js +0 -25
  53. package/dist-server/service/transaction/transaction-history.js.map +1 -1
  54. package/dist-server/service/transaction/transaction-period.d.ts +0 -8
  55. package/dist-server/service/transaction/transaction-period.js +0 -30
  56. package/dist-server/service/transaction/transaction-period.js.map +1 -1
  57. package/dist-server/service/transaction/transaction-query.d.ts +0 -2
  58. package/dist-server/service/transaction/transaction-query.js +2 -16
  59. package/dist-server/service/transaction/transaction-query.js.map +1 -1
  60. package/dist-server/service/transaction/transaction-service.d.ts +4 -6
  61. package/dist-server/service/transaction/transaction-service.js +10 -35
  62. package/dist-server/service/transaction/transaction-service.js.map +1 -1
  63. package/dist-server/service/transaction/transaction-type.d.ts +1 -15
  64. package/dist-server/service/transaction/transaction-type.js +2 -58
  65. package/dist-server/service/transaction/transaction-type.js.map +1 -1
  66. package/dist-server/service/transaction/transaction.d.ts +6 -15
  67. package/dist-server/service/transaction/transaction.js +13 -52
  68. package/dist-server/service/transaction/transaction.js.map +1 -1
  69. package/dist-server/tsconfig.tsbuildinfo +1 -1
  70. package/package.json +10 -10
  71. package/translations/en.json +12 -6
  72. package/translations/es.json +12 -6
  73. package/translations/ja.json +11 -1
  74. package/translations/ko.json +13 -7
  75. package/translations/ms.json +11 -1
  76. package/translations/zh.json +11 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,yBAAyB;AACzB,2DAAgC;AAChC,oFAAyD;AACzD,oFAAyD;AACzD,oEAAyC;AACzC,sEAA2C;AAC3C,0EAA+C;AAC/C,4DAAiC;AACjC,4DAAiC;AACjC,oFAAyD;AACzD,oFAAyD;AACzD,wFAA6D;AAC7D,sEAA2C;AAC3C,0EAA+C;AAC/C,oEAAyC;AACzC,oFAAyD;AACzD,yFAA8D;AAE9D,qBAAqB;AACrB,2EAAgD;AAChD,4EAAiD;AACjD,8EAAmD;AACnD,oEAAyC;AACzC,oEAAyC;AACzC,qEAA0C;AAC1C,qEAA0C;AAC1C,yFAA8D;AAC9D,4FAAiE;AACjE,mFAAwD;AACxD,4FAAiE;AACjE,kEAAuC;AACvC,qEAA0C;AAC1C,mEAAwC;AACxC,uEAA4C;AAC5C,uEAA4C;AAC5C,0EAA+C;AAC/C,4EAAiD;AACjD,uEAA4C;AAC5C,4FAAiE;AACjE,8FAAmE;AACnE,0FAA+D;A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AoB;QACvB,GAAG,0BAAsB;QACzB,GAAG,uBAAmB;QACtB,GAAG,gCAA4B;QAC/B,GAAG,+BAA2B;KAC/B;CACF,CAAA","sourcesContent":["/* EXPORT ENTITY TYPES */\nexport * from './cash-flow-type'\nexport * from './financial-statement/financial-statement'\nexport * from './accounting-category/accounting-category'\nexport * from './transaction/transaction'\nexport * from './bank-account/bank-account'\nexport * from './bank-statement/bank-statement'\nexport * from './payment/payment'\nexport * from './account/account'\nexport * from './accounting-document/accounting-document'\nexport * from './recurring-cash-item/recurring-cash-item'\nexport * from './financial-institution/financial-institution'\nexport * from './fiscal-month/fiscal-month'\nexport * from './fiscal-quarter/fiscal-quarter'\nexport * from './fiscal-year/fiscal-year'\nexport * from './expenditure-request/expenditure-request'\nexport * from './expenditure-request/expenditure-request-item'\n\n/* EXPORT SERVICES */\nexport * from './transaction/transaction-period'\nexport * from './transaction/transaction-service'\nexport * from './bank-account/bank-account-service'\nexport * from './payment/payment-targets'\nexport * from './payment/payment-service'\nexport * from './payment/payment-currency'\nexport * from './payment/document-targets'\nexport * from './financial-statement/financial-statement-line'\nexport * from './financial-statement/financial-statement-service'\nexport * from './recurring-cash-item/recurring-schedule'\nexport * from './recurring-cash-item/recurring-cash-item-service'\nexport * from './account/account-match'\nexport * from './account/default-accounts'\nexport * from './account/account-choice'\nexport * from './bank-statement/bank-source'\nexport * from './bank-statement/bank-parser'\nexport * from './bank-statement/bank-reconcile'\nexport * from './bank-statement/bank-import-type'\nexport * from './bank-statement/bank-import'\nexport * from './counterparty-account/counterparty-account-rules'\nexport * from './counterparty-account/counterparty-account-service'\nexport * from './expenditure-request/expenditure-request-rules'\nexport * from './expenditure-request/expenditure-payment-state'\nexport * from './expenditure-request/expenditure-request-service'\n\n/* IMPORT ENTITIES AND RESOLVERS */\nimport {\n entities as FinancialStatementEntities,\n resolvers as FinancialStatementResolvers,\n subscribers as FinancialStatementSubscribers\n} from './financial-statement'\nimport {\n entities as AccountingCategoryEntities,\n resolvers as AccountingCategoryResolvers,\n subscribers as AccountingCategorySubscribers\n} from './accounting-category'\nimport {\n entities as TransactionEntities,\n resolvers as TransactionResolvers,\n subscribers as TransactionSubscribers\n} from './transaction'\nimport {\n entities as BankAccountEntities,\n resolvers as BankAccountResolvers,\n subscribers as BankAccountSubscribers\n} from './bank-account'\nimport {\n entities as BankStatementEntities,\n resolvers as BankStatementResolvers,\n subscribers as BankStatementSubscribers\n} from './bank-statement'\nimport {\n entities as PaymentEntities,\n resolvers as PaymentResolvers,\n subscribers as PaymentSubscribers\n} from './payment'\nimport {\n entities as AccountEntities,\n resolvers as AccountResolvers,\n subscribers as AccountSubscribers\n} from './account'\nimport {\n entities as AccountingDocumentEntities,\n resolvers as AccountingDocumentResolvers,\n subscribers as AccountingDocumentSubscribers\n} from './accounting-document'\nimport {\n entities as RecurringCashItemEntities,\n resolvers as RecurringCashItemResolvers,\n subscribers as RecurringCashItemSubscribers\n} from './recurring-cash-item'\nimport {\n entities as FinancialInstitutionEntities,\n resolvers as FinancialInstitutionResolvers,\n subscribers as FinancialInstitutionSubscribers\n} from './financial-institution'\nimport {\n entities as FiscalMonthEntities,\n resolvers as FiscalMonthResolvers,\n subscribers as FiscalMonthSubscribers\n} from './fiscal-month'\nimport {\n entities as FiscalQuarterEntities,\n resolvers as FiscalQuarterResolvers,\n subscribers as FiscalQuarterSubscribers\n} from './fiscal-quarter'\nimport {\n entities as FiscalYearEntities,\n resolvers as FiscalYearResolvers,\n subscribers as FiscalYearSubscribers\n} from './fiscal-year'\nimport {\n entities as CounterpartyAccountEntities,\n resolvers as CounterpartyAccountResolvers,\n subscribers as CounterpartyAccountSubscribers\n} from './counterparty-account'\nimport {\n entities as ExpenditureRequestEntities,\n resolvers as ExpenditureRequestResolvers,\n subscribers as ExpenditureRequestSubscribers\n} from './expenditure-request'\n\nexport const entities = [\n ...FinancialStatementEntities,\n ...AccountingCategoryEntities,\n ...TransactionEntities,\n ...BankAccountEntities,\n ...BankStatementEntities,\n ...PaymentEntities,\n ...AccountEntities,\n ...AccountingDocumentEntities,\n ...RecurringCashItemEntities,\n ...FinancialInstitutionEntities,\n ...FiscalMonthEntities,\n ...FiscalQuarterEntities,\n ...FiscalYearEntities,\n ...CounterpartyAccountEntities,\n ...ExpenditureRequestEntities\n]\n\nexport const subscribers = [\n ...FinancialStatementSubscribers,\n ...AccountingCategorySubscribers,\n ...TransactionSubscribers,\n ...BankAccountSubscribers,\n ...BankStatementSubscribers,\n ...PaymentSubscribers,\n ...AccountSubscribers,\n ...AccountingDocumentSubscribers,\n ...RecurringCashItemSubscribers,\n ...FinancialInstitutionSubscribers,\n ...FiscalMonthSubscribers,\n ...FiscalQuarterSubscribers,\n ...FiscalYearSubscribers,\n ...CounterpartyAccountSubscribers,\n ...ExpenditureRequestSubscribers\n]\n\nexport const schema = {\n resolverClasses: [\n ...FinancialStatementResolvers,\n ...AccountingCategoryResolvers,\n ...TransactionResolvers,\n ...BankAccountResolvers,\n ...BankStatementResolvers,\n ...PaymentResolvers,\n ...AccountResolvers,\n ...AccountingDocumentResolvers,\n ...RecurringCashItemResolvers,\n ...FinancialInstitutionResolvers,\n ...FiscalMonthResolvers,\n ...FiscalQuarterResolvers,\n ...FiscalYearResolvers,\n ...CounterpartyAccountResolvers,\n ...ExpenditureRequestResolvers\n ]\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,yBAAyB;AACzB,2DAAgC;AAChC,oFAAyD;AACzD,oFAAyD;AACzD,oEAAyC;AACzC,sEAA2C;AAC3C,0EAA+C;AAC/C,4DAAiC;AACjC,4DAAiC;AACjC,oFAAyD;AACzD,oFAAyD;AACzD,wFAA6D;AAC7D,sEAA2C;AAC3C,0EAA+C;AAC/C,oEAAyC;AACzC,oFAAyD;AACzD,yFAA8D;AAE9D,qBAAqB;AACrB,2EAAgD;AAChD,4EAAiD;AACjD,8EAAmD;AACnD,oEAAyC;AACzC,oEAAyC;AACzC,qEAA0C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AA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,GAAG,+BAA2B;QAC9B,GAAG,+BAA2B;QAC9B,GAAG,uBAAoB;QACvB,GAAG,wBAAoB;QACvB,GAAG,0BAAsB;QACzB,GAAG,mBAAgB;QACnB,GAAG,mBAAgB;QACnB,GAAG,+BAA2B;QAC9B,GAAG,+BAA0B;QAC7B,GAAG,iCAA6B;QAChC,GAAG,wBAAoB;QACvB,GAAG,0BAAsB;QACzB,GAAG,uBAAmB;QACtB,GAAG,gCAA4B;QAC/B,GAAG,+BAA2B;KAC/B;CACF,CAAA","sourcesContent":["/* EXPORT ENTITY TYPES */\nexport * from './cash-flow-type'\nexport * from './financial-statement/financial-statement'\nexport * from './accounting-category/accounting-category'\nexport * from './transaction/transaction'\nexport * from './bank-account/bank-account'\nexport * from './bank-statement/bank-statement'\nexport * from './payment/payment'\nexport * from './account/account'\nexport * from './accounting-document/accounting-document'\nexport * from './recurring-cash-item/recurring-cash-item'\nexport * from './financial-institution/financial-institution'\nexport * from './fiscal-month/fiscal-month'\nexport * from './fiscal-quarter/fiscal-quarter'\nexport * from './fiscal-year/fiscal-year'\nexport * from './expenditure-request/expenditure-request'\nexport * from './expenditure-request/expenditure-request-item'\n\n/* EXPORT SERVICES */\nexport * from './transaction/transaction-period'\nexport * from './transaction/transaction-service'\nexport * from './bank-account/bank-account-service'\nexport * from './payment/payment-targets'\nexport * from './payment/payment-service'\nexport * from './payment/payment-currency'\nexport * from './payment/document-targets'\nexport * from './financial-statement/financial-statement-line'\nexport * from './financial-statement/financial-statement-service'\nexport * from './recurring-cash-item/recurring-schedule'\nexport * from './recurring-cash-item/recurring-cash-item-service'\nexport * from './account/account-match'\nexport * from './account/default-accounts'\nexport * from './account/account-choice'\nexport * from './account/account-service'\nexport * from './bank-statement/bank-source'\nexport * from './bank-statement/bank-parser'\nexport * from './bank-statement/bank-reconcile'\nexport * from './bank-statement/bank-import-type'\nexport * from './bank-statement/bank-import'\nexport * from './counterparty-account/counterparty-account-rules'\nexport * from './counterparty-account/counterparty-account-service'\nexport * from './expenditure-request/expenditure-request-rules'\nexport * from './expenditure-request/expenditure-payment-state'\nexport * from './expenditure-request/expenditure-request-service'\n\n/* IMPORT ENTITIES AND RESOLVERS */\nimport {\n entities as FinancialStatementEntities,\n resolvers as FinancialStatementResolvers,\n subscribers as FinancialStatementSubscribers\n} from './financial-statement'\nimport {\n entities as AccountingCategoryEntities,\n resolvers as AccountingCategoryResolvers,\n subscribers as AccountingCategorySubscribers\n} from './accounting-category'\nimport {\n entities as TransactionEntities,\n resolvers as TransactionResolvers,\n subscribers as TransactionSubscribers\n} from './transaction'\nimport {\n entities as BankAccountEntities,\n resolvers as BankAccountResolvers,\n subscribers as BankAccountSubscribers\n} from './bank-account'\nimport {\n entities as BankStatementEntities,\n resolvers as BankStatementResolvers,\n subscribers as BankStatementSubscribers\n} from './bank-statement'\nimport {\n entities as PaymentEntities,\n resolvers as PaymentResolvers,\n subscribers as PaymentSubscribers\n} from './payment'\nimport {\n entities as AccountEntities,\n resolvers as AccountResolvers,\n subscribers as AccountSubscribers\n} from './account'\nimport {\n entities as AccountingDocumentEntities,\n resolvers as AccountingDocumentResolvers,\n subscribers as AccountingDocumentSubscribers\n} from './accounting-document'\nimport {\n entities as RecurringCashItemEntities,\n resolvers as RecurringCashItemResolvers,\n subscribers as RecurringCashItemSubscribers\n} from './recurring-cash-item'\nimport {\n entities as FinancialInstitutionEntities,\n resolvers as FinancialInstitutionResolvers,\n subscribers as FinancialInstitutionSubscribers\n} from './financial-institution'\nimport {\n entities as FiscalMonthEntities,\n resolvers as FiscalMonthResolvers,\n subscribers as FiscalMonthSubscribers\n} from './fiscal-month'\nimport {\n entities as FiscalQuarterEntities,\n resolvers as FiscalQuarterResolvers,\n subscribers as FiscalQuarterSubscribers\n} from './fiscal-quarter'\nimport {\n entities as FiscalYearEntities,\n resolvers as FiscalYearResolvers,\n subscribers as FiscalYearSubscribers\n} from './fiscal-year'\nimport {\n entities as CounterpartyAccountEntities,\n resolvers as CounterpartyAccountResolvers,\n subscribers as CounterpartyAccountSubscribers\n} from './counterparty-account'\nimport {\n entities as ExpenditureRequestEntities,\n resolvers as ExpenditureRequestResolvers,\n subscribers as ExpenditureRequestSubscribers\n} from './expenditure-request'\n\nexport const entities = [\n ...FinancialStatementEntities,\n ...AccountingCategoryEntities,\n ...TransactionEntities,\n ...BankAccountEntities,\n ...BankStatementEntities,\n ...PaymentEntities,\n ...AccountEntities,\n ...AccountingDocumentEntities,\n ...RecurringCashItemEntities,\n ...FinancialInstitutionEntities,\n ...FiscalMonthEntities,\n ...FiscalQuarterEntities,\n ...FiscalYearEntities,\n ...CounterpartyAccountEntities,\n ...ExpenditureRequestEntities\n]\n\nexport const subscribers = [\n ...FinancialStatementSubscribers,\n ...AccountingCategorySubscribers,\n ...TransactionSubscribers,\n ...BankAccountSubscribers,\n ...BankStatementSubscribers,\n ...PaymentSubscribers,\n ...AccountSubscribers,\n ...AccountingDocumentSubscribers,\n ...RecurringCashItemSubscribers,\n ...FinancialInstitutionSubscribers,\n ...FiscalMonthSubscribers,\n ...FiscalQuarterSubscribers,\n ...FiscalYearSubscribers,\n ...CounterpartyAccountSubscribers,\n ...ExpenditureRequestSubscribers\n]\n\nexport const schema = {\n resolverClasses: [\n ...FinancialStatementResolvers,\n ...AccountingCategoryResolvers,\n ...TransactionResolvers,\n ...BankAccountResolvers,\n ...BankStatementResolvers,\n ...PaymentResolvers,\n ...AccountResolvers,\n ...AccountingDocumentResolvers,\n ...RecurringCashItemResolvers,\n ...FinancialInstitutionResolvers,\n ...FiscalMonthResolvers,\n ...FiscalQuarterResolvers,\n ...FiscalYearResolvers,\n ...CounterpartyAccountResolvers,\n ...ExpenditureRequestResolvers\n ]\n}\n"]}
@@ -7,6 +7,9 @@ const event_subscriber_1 = require("./event-subscriber");
7
7
  const payment_query_1 = require("./payment-query");
8
8
  const payment_mutation_1 = require("./payment-mutation");
9
9
  require("./transfer-target");
10
+ const shell_1 = require("@things-factory/shell");
11
+ /* A payment names what it paid by kind and id (§`registerPaymentTarget`); what it pays is tied to it (§`refuseTiedRows`). */
12
+ (0, shell_1.registerKindTie)(payment_1.Payment, { kind: 'targetType', id: 'targetId' });
10
13
  exports.entities = [payment_1.Payment, payment_history_1.PaymentHistory];
11
14
  exports.resolvers = [payment_query_1.PaymentQuery, payment_mutation_1.PaymentMutation];
12
15
  exports.subscribers = [event_subscriber_1.PaymentHistoryEntitySubscriber];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/payment/index.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AACnC,uDAAkD;AAClD,yDAAmE;AACnE,mDAA8C;AAC9C,yDAAoD;AACpD,6BAA0B;AAEb,QAAA,QAAQ,GAAG,CAAC,iBAAO,EAAE,gCAAc,CAAC,CAAA;AACpC,QAAA,SAAS,GAAG,CAAC,4BAAY,EAAE,kCAAe,CAAC,CAAA;AAC3C,QAAA,WAAW,GAAG,CAAC,iDAA8B,CAAC,CAAA","sourcesContent":["import { Payment } from './payment'\nimport { PaymentHistory } from './payment-history'\nimport { PaymentHistoryEntitySubscriber } from './event-subscriber'\nimport { PaymentQuery } from './payment-query'\nimport { PaymentMutation } from './payment-mutation'\nimport './transfer-target'\n\nexport const entities = [Payment, PaymentHistory]\nexport const resolvers = [PaymentQuery, PaymentMutation]\nexport const subscribers = [PaymentHistoryEntitySubscriber]\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/payment/index.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AACnC,uDAAkD;AAClD,yDAAmE;AACnE,mDAA8C;AAC9C,yDAAoD;AACpD,6BAA0B;AAE1B,iDAAuD;AAEvD,6HAA6H;AAC7H,IAAA,uBAAe,EAAC,iBAAO,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAA;AAEnD,QAAA,QAAQ,GAAG,CAAC,iBAAO,EAAE,gCAAc,CAAC,CAAA;AACpC,QAAA,SAAS,GAAG,CAAC,4BAAY,EAAE,kCAAe,CAAC,CAAA;AAC3C,QAAA,WAAW,GAAG,CAAC,iDAA8B,CAAC,CAAA","sourcesContent":["import { Payment } from './payment'\nimport { PaymentHistory } from './payment-history'\nimport { PaymentHistoryEntitySubscriber } from './event-subscriber'\nimport { PaymentQuery } from './payment-query'\nimport { PaymentMutation } from './payment-mutation'\nimport './transfer-target'\n\nimport { registerKindTie } from '@things-factory/shell'\n\n/* A payment names what it paid by kind and id (§`registerPaymentTarget`); what it pays is tied to it (§`refuseTiedRows`). */\nregisterKindTie(Payment, { kind: 'targetType', id: 'targetId' })\n\nexport const entities = [Payment, PaymentHistory]\nexport const resolvers = [PaymentQuery, PaymentMutation]\nexport const subscribers = [PaymentHistoryEntitySubscriber]\n"]}
@@ -3,5 +3,4 @@ import { RecurringCashItemPatch } from './recurring-cash-item-type';
3
3
  export declare class RecurringCashItemMutation {
4
4
  updateMultipleRecurringCashItem(patches: RecurringCashItemPatch[], context: ResolverContext): Promise<RecurringCashItem[]>;
5
5
  deleteRecurringCashItems(ids: string[], context: ResolverContext): Promise<boolean>;
6
- generateForecasts(year: number, month: number, context: ResolverContext): Promise<number>;
7
6
  }
@@ -17,10 +17,6 @@ let RecurringCashItemMutation = class RecurringCashItemMutation {
17
17
  await (0, recurring_cash_item_service_1.saveRecurringCashItems)(tx, domain, user, ids.map(id => ({ id, cuFlag: '-' })));
18
18
  return true;
19
19
  }
20
- async generateForecasts(year, month, context) {
21
- const { domain, user, tx } = context.state;
22
- return await (0, recurring_cash_item_service_1.makeForecasts)(tx, domain, user, year, month);
23
- }
24
20
  };
25
21
  exports.RecurringCashItemMutation = RecurringCashItemMutation;
26
22
  tslib_1.__decorate([
@@ -43,19 +39,6 @@ tslib_1.__decorate([
43
39
  tslib_1.__metadata("design:paramtypes", [Array, Object]),
44
40
  tslib_1.__metadata("design:returntype", Promise)
45
41
  ], RecurringCashItemMutation.prototype, "deleteRecurringCashItems", null);
46
- tslib_1.__decorate([
47
- (0, type_graphql_1.Directive)('@transaction'),
48
- (0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
49
- (0, type_graphql_1.Mutation)(returns => type_graphql_1.Int, {
50
- description: "Make a month's forecasts from the recurring items; returns how many were made"
51
- }),
52
- tslib_1.__param(0, (0, type_graphql_1.Arg)('year', type => type_graphql_1.Int)),
53
- tslib_1.__param(1, (0, type_graphql_1.Arg)('month', type => type_graphql_1.Int)),
54
- tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
55
- tslib_1.__metadata("design:type", Function),
56
- tslib_1.__metadata("design:paramtypes", [Number, Number, Object]),
57
- tslib_1.__metadata("design:returntype", Promise)
58
- ], RecurringCashItemMutation.prototype, "generateForecasts", null);
59
42
  exports.RecurringCashItemMutation = RecurringCashItemMutation = tslib_1.__decorate([
60
43
  (0, type_graphql_1.Resolver)(recurring_cash_item_1.RecurringCashItem),
61
44
  (0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals)
@@ -1 +1 @@
1
- {"version":3,"file":"recurring-cash-item-mutation.js","sourceRoot":"","sources":["../../../server/service/recurring-cash-item/recurring-cash-item-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAA0F;AAE1F,iDAAqD;AAErD,+DAAyD;AACzD,+EAAqF;AACrF,yEAAmE;AAI5D,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAI9B,AAAN,KAAK,CAAC,+BAA+B,CACe,OAAiC,EAC5E,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,IAAA,oDAAsB,EAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IAChE,CAAC;IAKK,AAAN,KAAK,CAAC,wBAAwB,CACE,GAAa,EACpC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IA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G,GAAE,CAAA;;;;yEAWP;AAOK;IALL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,qFAAqF,CAAC;IAChG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,kBAAG,EAAE;QACxB,WAAW,EAAE,+EAA+E;KAC7F,CAAC;IAEC,mBAAA,IAAA,kBAAG,EAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC,CAAA;IACxB,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC,CAAA;IACzB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;kEAKP;oCA5CU,yBAAyB;IAFrC,IAAA,uBAAQ,EAAC,uCAAiB,CAAC;IAC3B,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,yBAAyB,CA6CrC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive, Int, UseMiddleware } from 'type-graphql'\n\nimport { SpeakRefusals } from '@things-factory/shell'\n\nimport { RecurringCashItem } from './recurring-cash-item'\nimport { makeForecasts, saveRecurringCashItems } from './recurring-cash-item-service'\nimport { RecurringCashItemPatch } from './recurring-cash-item-type'\n\n@Resolver(RecurringCashItem)\n@UseMiddleware(SpeakRefusals)\nexport class RecurringCashItemMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [RecurringCashItem], { description: 'To add, modify and delete multiple RecurringCashItems' })\n async updateMultipleRecurringCashItem(\n @Arg('patches', type => [RecurringCashItemPatch]) patches: RecurringCashItemPatch[],\n @Ctx() context: ResolverContext\n ): Promise<RecurringCashItem[]> {\n const { domain, user, tx } = context.state\n\n return await saveRecurringCashItems(tx, domain, user, patches)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete multiple RecurringCashItems' })\n async deleteRecurringCashItems(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, user, tx } = context.state\n await saveRecurringCashItems(\n tx,\n domain,\n user,\n ids.map(id => ({ id, cuFlag: '-' }))\n )\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Int, {\n description: \"Make a month's forecasts from the recurring items; returns how many were made\"\n })\n async generateForecasts(\n @Arg('year', type => Int) year: number,\n @Arg('month', type => Int) month: number,\n @Ctx() context: ResolverContext\n ): Promise<number> {\n const { domain, user, tx } = context.state\n\n return await makeForecasts(tx, domain, user, year, month)\n }\n}\n"]}
1
+ {"version":3,"file":"recurring-cash-item-mutation.js","sourceRoot":"","sources":["../../../server/service/recurring-cash-item/recurring-cash-item-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAqF;AAErF,iDAAqD;AAErD,+DAAyD;AACzD,+EAAsE;AACtE,yEAAmE;AAI5D,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAI9B,AAAN,KAAK,CAAC,+BAA+B,CACe,OAAiC,EAC5E,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,IAAA,oDAAsB,EAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IAChE,CAAC;IAKK,AAAN,KAAK,CAAC,wBAAwB,CACE,GAAa,EACpC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,MAAM,IAAA,oDAAsB,EAC1B,EAAE,EACF,MAAM,EACN,IAAI,EACJ,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CACrC,CAAA;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA;AA9BY,8DAAyB;AAI9B;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,qFAAqF,CAAC;IAChG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,uCAAiB,CAAC,EAAE,EAAE,WAAW,EAAE,uDAAuD,EAAE,CAAC;IAEhH,mBAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,iDAAsB,CAAC,CAAC,CAAA;IAChD,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;gFAKP;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,qFAAqF,CAAC;IAChG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;IAEpF,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;yEAWP;oCA7BU,yBAAyB;IAFrC,IAAA,uBAAQ,EAAC,uCAAiB,CAAC;IAC3B,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,yBAAyB,CA8BrC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive, UseMiddleware } from 'type-graphql'\n\nimport { SpeakRefusals } from '@things-factory/shell'\n\nimport { RecurringCashItem } from './recurring-cash-item'\nimport { saveRecurringCashItems } from './recurring-cash-item-service'\nimport { RecurringCashItemPatch } from './recurring-cash-item-type'\n\n@Resolver(RecurringCashItem)\n@UseMiddleware(SpeakRefusals)\nexport class RecurringCashItemMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [RecurringCashItem], { description: 'To add, modify and delete multiple RecurringCashItems' })\n async updateMultipleRecurringCashItem(\n @Arg('patches', type => [RecurringCashItemPatch]) patches: RecurringCashItemPatch[],\n @Ctx() context: ResolverContext\n ): Promise<RecurringCashItem[]> {\n const { domain, user, tx } = context.state\n\n return await saveRecurringCashItems(tx, domain, user, patches)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete multiple RecurringCashItems' })\n async deleteRecurringCashItems(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, user, tx } = context.state\n await saveRecurringCashItems(\n tx,\n domain,\n user,\n ids.map(id => ({ id, cuFlag: '-' }))\n )\n\n return true\n }\n}\n"]}
@@ -10,14 +10,10 @@ export type RecurringCashItemInput = Partial<Omit<RecurringCashItem, 'account' |
10
10
  id: string;
11
11
  } | null;
12
12
  };
13
- /** Apply rows to a domain's recurring items: `+` (or no id) adds, `M` changes, `-` deletes (softly). */
14
- export declare function saveRecurringCashItems(tx: EntityManager, domain: {
15
- id: string;
16
- }, user: any, inputs: RecurringCashItemInput[]): Promise<RecurringCashItem[]>;
17
13
  /**
18
- * Make the month's forecasts from the recurring items. A forecast already made from an item for that month is not
19
- * made again, so running it twice changes nothing. Returns how many were made.
14
+ * Apply rows to a domain's recurring items: `+` (or no id) adds, `M` changes, `-` deletes (softly). An item another row
15
+ * still names is not deleted (§`refuseTiedRows`).
20
16
  */
21
- export declare function makeForecasts(tx: EntityManager, domain: {
17
+ export declare function saveRecurringCashItems(tx: EntityManager, domain: {
22
18
  id: string;
23
- }, user: any, year: number, month: number): Promise<number>;
19
+ }, user: any, inputs: RecurringCashItemInput[]): Promise<RecurringCashItem[]>;
@@ -1,13 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.saveRecurringCashItems = saveRecurringCashItems;
4
- exports.makeForecasts = makeForecasts;
5
4
  const typeorm_1 = require("typeorm");
6
5
  const shell_1 = require("@things-factory/shell");
7
- const transaction_1 = require("../transaction/transaction");
8
- const transaction_service_1 = require("../transaction/transaction-service");
9
6
  const recurring_cash_item_1 = require("./recurring-cash-item");
10
- const recurring_schedule_1 = require("./recurring-schedule");
11
7
  const MONTH = /^\d{4}-(0[1-9]|1[0-2])$/;
12
8
  function rowOf(input, current) {
13
9
  const { id, cuFlag, ...row } = input;
@@ -31,7 +27,10 @@ function rowOf(input, current) {
31
27
  throw new shell_1.Refusal('recurring-amount-required', {}, 'amount: every month');
32
28
  return row;
33
29
  }
34
- /** Apply rows to a domain's recurring items: `+` (or no id) adds, `M` changes, `-` deletes (softly). */
30
+ /**
31
+ * Apply rows to a domain's recurring items: `+` (or no id) adds, `M` changes, `-` deletes (softly). An item another row
32
+ * still names is not deleted (§`refuseTiedRows`).
33
+ */
35
34
  async function saveRecurringCashItems(tx, domain, user, inputs) {
36
35
  const repo = tx.getRepository(recurring_cash_item_1.RecurringCashItem);
37
36
  const deletes = [...new Set(inputs.filter(one => one.cuFlag === '-' && one.id).map(one => one.id))];
@@ -39,6 +38,7 @@ async function saveRecurringCashItems(tx, domain, user, inputs) {
39
38
  const found = await repo.find({ where: { domain: { id: domain.id }, id: (0, typeorm_1.In)(deletes) } });
40
39
  if (found.length !== deletes.length)
41
40
  throw new shell_1.Refusal('recurring-not-found', {}, 'a recurring item was not found - reload and try again');
41
+ await (0, shell_1.refuseTiedRows)(tx, recurring_cash_item_1.RecurringCashItem, deletes);
42
42
  await repo.softRemove(found);
43
43
  }
44
44
  const saved = [];
@@ -55,37 +55,4 @@ async function saveRecurringCashItems(tx, domain, user, inputs) {
55
55
  }
56
56
  return saved;
57
57
  }
58
- /**
59
- * Make the month's forecasts from the recurring items. A forecast already made from an item for that month is not
60
- * made again, so running it twice changes nothing. Returns how many were made.
61
- */
62
- async function makeForecasts(tx, domain, user, year, month) {
63
- if (!(month >= 1 && month <= 12))
64
- throw new shell_1.Refusal('month-out-of-range', { month }, 'month: must be 1 to 12');
65
- const items = await tx.getRepository(recurring_cash_item_1.RecurringCashItem).find({ where: { domain: { id: domain.id } } });
66
- const made = await tx
67
- .getRepository(transaction_1.Transaction)
68
- .find({
69
- where: { domain: { id: domain.id }, category: transaction_1.TransactionCategory.FORECAST, year, month },
70
- relations: ['recurringItem']
71
- });
72
- const already = new Set(made.map(one => one.recurringItem?.id).filter(Boolean));
73
- const lines = (0, recurring_schedule_1.linesFor)(items, year, month, already);
74
- await (0, transaction_service_1.saveTransactions)(tx, domain, user, lines.map(line => {
75
- return {
76
- cuFlag: '+',
77
- category: transaction_1.TransactionCategory.FORECAST,
78
- type: line.type,
79
- year: line.year,
80
- month: line.month,
81
- description: line.name,
82
- amount: line.amount,
83
- currency: line.currency,
84
- timing: line.timing ?? undefined,
85
- status: transaction_1.ForecastStatus.PLANNED,
86
- recurringItem: { id: line.recurringItemId }
87
- };
88
- }));
89
- return lines.length;
90
- }
91
58
  //# sourceMappingURL=recurring-cash-item-service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"recurring-cash-item-service.js","sourceRoot":"","sources":["../../../server/service/recurring-cash-item/recurring-cash-item-service.ts"],"names":[],"mappings":";;AA0CA,wDA8BC;AAMD,sCAyCC;AAvHD,qCAA2C;AAE3C,iDAA+C;AAE/C,4DAA6F;AAC7F,4EAAqE;AACrE,+DAAyD;AACzD,6DAA+C;AAE/C,MAAM,KAAK,GAAG,yBAAyB,CAAA;AASvC,SAAS,KAAK,CAAC,KAA6B,EAAE,OAAsC;IAClF,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,GAAG,EAAE,GAAG,KAA4B,CAAA;IAC3D,MAAM,MAAM,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,GAAG,EAAE,CAAA;IACrC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IA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O,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAa,CAAC,CAAA;IAE3F,MAAM,KAAK,GAAG,IAAA,6BAAQ,EAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;IACnD,MAAM,IAAA,sCAAgB,EACpB,EAAE,EACF,MAAM,EACN,IAAI,EACJ,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACf,OAAO;YACL,MAAM,EAAE,GAAG;YACX,QAAQ,EAAE,iCAAmB,CAAC,QAAQ;YACtC,IAAI,EAAE,IAAI,CAAC,IAAW;YACtB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,IAAI;YACtB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,SAAS;YAChC,MAAM,EAAE,4BAAc,CAAC,OAAO;YAC9B,aAAa,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,eAAe,EAAE;SAC5C,CAAA;IACH,CAAC,CAAC,CACH,CAAA;IAED,OAAO,KAAK,CAAC,MAAM,CAAA;AACrB,CAAC","sourcesContent":["import { EntityManager, In } from 'typeorm'\n\nimport { Refusal } from '@things-factory/shell'\n\nimport { ForecastStatus, Transaction, TransactionCategory } from '../transaction/transaction'\nimport { saveTransactions } from '../transaction/transaction-service'\nimport { RecurringCashItem } from './recurring-cash-item'\nimport { linesFor } from './recurring-schedule'\n\nconst MONTH = /^\\d{4}-(0[1-9]|1[0-2])$/\n\nexport type RecurringCashItemInput = Partial<Omit<RecurringCashItem, 'account' | 'counterparty'>> & {\n id?: string\n cuFlag?: string\n account?: { id: string } | null\n counterparty?: { id: string } | null\n}\n\nfunction rowOf(input: RecurringCashItemInput, current: RecurringCashItem | undefined): Record<string, any> {\n const { id, cuFlag, ...row } = input as Record<string, any>\n const merged = { ...current, ...row }\n if (!String(merged.name ?? '').trim()) throw new Refusal('recurring-name-required', {}, 'name: what it is')\n if (!merged.type) throw new Refusal('transaction-type-required', {}, 'type: money in or money out')\n if (!MONTH.test(String(merged.startMonth ?? '')))\n throw new Refusal('recurring-start-required', {}, 'startMonth: YYYY-MM')\n if (merged.endMonth && !MONTH.test(merged.endMonth))\n throw new Refusal('recurring-end-not-a-month', {}, 'endMonth: YYYY-MM')\n if (merged.endMonth && merged.endMonth < merged.startMonth)\n throw new Refusal('recurring-end-before-start', {}, 'endMonth: before startMonth')\n if (\n merged.dayOfMonth !== null &&\n merged.dayOfMonth !== undefined &&\n !(merged.dayOfMonth >= 1 && merged.dayOfMonth <= 31)\n ) {\n throw new Refusal('day-of-month-out-of-range', {}, 'dayOfMonth: must be 1 to 31')\n }\n if (!current && (row.amount === undefined || row.amount === null))\n throw new Refusal('recurring-amount-required', {}, 'amount: every month')\n return row\n}\n\n/** Apply rows to a domain's recurring items: `+` (or no id) adds, `M` changes, `-` deletes (softly). */\nexport async function saveRecurringCashItems(\n tx: EntityManager,\n domain: { id: string },\n user: any,\n inputs: RecurringCashItemInput[]\n): Promise<RecurringCashItem[]> {\n const repo = tx.getRepository(RecurringCashItem)\n const deletes = [...new Set(inputs.filter(one => one.cuFlag === '-' && one.id).map(one => one.id!))]\n if (deletes.length) {\n const found = await repo.find({ where: { domain: { id: domain.id }, id: In(deletes) } })\n if (found.length !== deletes.length)\n throw new Refusal('recurring-not-found', {}, 'a recurring item was not found - reload and try again')\n await repo.softRemove(found)\n }\n\n const saved: RecurringCashItem[] = []\n for (const input of inputs.filter(one => one.cuFlag !== '-')) {\n const isNew = !input.id || input.cuFlag === '+'\n const current = isNew ? undefined : await repo.findOne({ where: { domain: { id: domain.id }, id: input.id } })\n if (!isNew && !current)\n throw new Refusal('recurring-not-found', {}, 'a recurring item was not found - reload and try again')\n saved.push(\n await repo.save({\n ...(current ?? { domain, creator: user }),\n ...rowOf(input, current),\n updater: user\n } as RecurringCashItem)\n )\n }\n return saved\n}\n\n/**\n * Make the month's forecasts from the recurring items. A forecast already made from an item for that month is not\n * made again, so running it twice changes nothing. Returns how many were made.\n */\nexport async function makeForecasts(\n tx: EntityManager,\n domain: { id: string },\n user: any,\n year: number,\n month: number\n): Promise<number> {\n if (!(month >= 1 && month <= 12)) throw new Refusal('month-out-of-range', { month }, 'month: must be 1 to 12')\n\n const items = await tx.getRepository(RecurringCashItem).find({ where: { domain: { id: domain.id } } })\n const made = await tx\n .getRepository(Transaction)\n .find({\n where: { domain: { id: domain.id }, category: TransactionCategory.FORECAST, year, month },\n relations: ['recurringItem']\n })\n const already = new Set(made.map(one => one.recurringItem?.id).filter(Boolean) as string[])\n\n const lines = linesFor(items, year, month, already)\n await saveTransactions(\n tx,\n domain,\n user,\n lines.map(line => {\n return {\n cuFlag: '+',\n category: TransactionCategory.FORECAST,\n type: line.type as any,\n year: line.year,\n month: line.month,\n description: line.name,\n amount: line.amount,\n currency: line.currency,\n timing: line.timing ?? undefined,\n status: ForecastStatus.PLANNED,\n recurringItem: { id: line.recurringItemId }\n }\n })\n )\n\n return lines.length\n}\n"]}
1
+ {"version":3,"file":"recurring-cash-item-service.js","sourceRoot":"","sources":["../../../server/service/recurring-cash-item/recurring-cash-item-service.ts"],"names":[],"mappings":";;AA0CA,wDA+BC;AAzED,qCAA2C;AAE3C,iDAA+D;AAE/D,+DAAyD;AAEzD,MAAM,KAAK,GAAG,yBAAyB,CAAA;AASvC,SAAS,KAAK,CAAC,KAA6B,EAAE,OAAsC;IAClF,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,GAAG,EAAE,GAAG,KAA4B,CAAA;IAC3D,MAAM,MAAM,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,GAAG,EAAE,CAAA;IACrC,IAAI,CAAC,MAAM,CAAC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C,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;QAC9G,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO;YACpB,MAAM,IAAI,eAAO,CAAC,qBAAqB,EAAE,EAAE,EAAE,uDAAuD,CAAC,CAAA;QACvG,KAAK,CAAC,IAAI,CACR,MAAM,IAAI,CAAC,IAAI,CAAC;YACd,GAAG,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YACzC,GAAG,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC;YACxB,OAAO,EAAE,IAAI;SACO,CAAC,CACxB,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import { EntityManager, In } from 'typeorm'\n\nimport { Refusal, refuseTiedRows } from '@things-factory/shell'\n\nimport { RecurringCashItem } from './recurring-cash-item'\n\nconst MONTH = /^\\d{4}-(0[1-9]|1[0-2])$/\n\nexport type RecurringCashItemInput = Partial<Omit<RecurringCashItem, 'account' | 'counterparty'>> & {\n id?: string\n cuFlag?: string\n account?: { id: string } | null\n counterparty?: { id: string } | null\n}\n\nfunction rowOf(input: RecurringCashItemInput, current: RecurringCashItem | undefined): Record<string, any> {\n const { id, cuFlag, ...row } = input as Record<string, any>\n const merged = { ...current, ...row }\n if (!String(merged.name ?? '').trim()) throw new Refusal('recurring-name-required', {}, 'name: what it is')\n if (!merged.type) throw new Refusal('transaction-type-required', {}, 'type: money in or money out')\n if (!MONTH.test(String(merged.startMonth ?? '')))\n throw new Refusal('recurring-start-required', {}, 'startMonth: YYYY-MM')\n if (merged.endMonth && !MONTH.test(merged.endMonth))\n throw new Refusal('recurring-end-not-a-month', {}, 'endMonth: YYYY-MM')\n if (merged.endMonth && merged.endMonth < merged.startMonth)\n throw new Refusal('recurring-end-before-start', {}, 'endMonth: before startMonth')\n if (\n merged.dayOfMonth !== null &&\n merged.dayOfMonth !== undefined &&\n !(merged.dayOfMonth >= 1 && merged.dayOfMonth <= 31)\n ) {\n throw new Refusal('day-of-month-out-of-range', {}, 'dayOfMonth: must be 1 to 31')\n }\n if (!current && (row.amount === undefined || row.amount === null))\n throw new Refusal('recurring-amount-required', {}, 'amount: every month')\n return row\n}\n\n/**\n * Apply rows to a domain's recurring items: `+` (or no id) adds, `M` changes, `-` deletes (softly). An item another row\n * still names is not deleted (§`refuseTiedRows`).\n */\nexport async function saveRecurringCashItems(\n tx: EntityManager,\n domain: { id: string },\n user: any,\n inputs: RecurringCashItemInput[]\n): Promise<RecurringCashItem[]> {\n const repo = tx.getRepository(RecurringCashItem)\n const deletes = [...new Set(inputs.filter(one => one.cuFlag === '-' && one.id).map(one => one.id!))]\n if (deletes.length) {\n const found = await repo.find({ where: { domain: { id: domain.id }, id: In(deletes) } })\n if (found.length !== deletes.length)\n throw new Refusal('recurring-not-found', {}, 'a recurring item was not found - reload and try again')\n await refuseTiedRows(tx, RecurringCashItem, deletes)\n await repo.softRemove(found)\n }\n\n const saved: RecurringCashItem[] = []\n for (const input of inputs.filter(one => one.cuFlag !== '-')) {\n const isNew = !input.id || input.cuFlag === '+'\n const current = isNew ? undefined : await repo.findOne({ where: { domain: { id: domain.id }, id: input.id } })\n if (!isNew && !current)\n throw new Refusal('recurring-not-found', {}, 'a recurring item was not found - reload and try again')\n saved.push(\n await repo.save({\n ...(current ?? { domain, creator: user }),\n ...rowOf(input, current),\n updater: user\n } as RecurringCashItem)\n )\n }\n return saved\n}\n"]}
@@ -54,7 +54,7 @@ tslib_1.__decorate([
54
54
  tslib_1.__metadata("design:type", shell_1.ObjectRef)
55
55
  ], RecurringCashItemPatch.prototype, "counterparty", void 0);
56
56
  tslib_1.__decorate([
57
- (0, type_graphql_1.Field)({ nullable: true, description: 'Whether it still makes forecasts' }),
57
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Whether it still falls in its months' }),
58
58
  tslib_1.__metadata("design:type", Boolean)
59
59
  ], RecurringCashItemPatch.prototype, "active", void 0);
60
60
  tslib_1.__decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"recurring-cash-item-type.js","sourceRoot":"","sources":["../../../server/service/recurring-cash-item/recurring-cash-item-type.ts"],"names":[],"mappings":";;;;AAAA,+CAA2E;AAE3E,iDAAiD;AAEjD,sDAAgD;AAChD,+DAAyD;AAGlD,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;CA0ClC,CAAA;AA1CY,wDAAsB;AAEjC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;;kDACxE;AAGX;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;;oDACxC;AAGb;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,qCAAqC,EAAE,CAAC;sCACvF,iBAAS;uDAAA;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,6BAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC;;oDACnE;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;;sDAC7D;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC;;wDACvC;AAGjB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,C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,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;;oDACpD;gCALF,qBAAqB;IADjC,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;GAC5C,qBAAqB,CAMjC","sourcesContent":["import { ObjectType, Field, Float, InputType, Int, ID } from 'type-graphql'\n\nimport { ObjectRef } from '@things-factory/shell'\n\nimport { CashFlowType } from '../cash-flow-type'\nimport { RecurringCashItem } from './recurring-cash-item'\n\n@InputType({ description: 'A recurring item, or a grid row: cuFlag + adds, M changes, - deletes' })\nexport class RecurringCashItemPatch {\n @Field(type => ID, { nullable: true, description: 'The item to change or delete' })\n id?: string\n\n @Field({ nullable: true, description: 'What it is' })\n name?: string\n\n @Field(type => ObjectRef, { nullable: true, description: 'The account subject it is booked to' })\n account?: ObjectRef\n\n @Field(type => CashFlowType, { nullable: true, description: 'Money in or money out' })\n type?: CashFlowType\n\n @Field(type => Float, { nullable: true, description: 'Amount every month' })\n amount?: number\n\n @Field({ nullable: true, description: 'ISO 4217 code' })\n currency?: string\n\n @Field(type => Int, { nullable: true, description: '1-31' })\n dayOfMonth?: number\n\n @Field({ nullable: true, description: 'Falls on the last day of every month' })\n lastDayOfMonth?: boolean\n\n @Field({ nullable: true, description: 'First month - YYYY-MM' })\n startMonth?: string\n\n @Field({ nullable: true, description: 'Last month - YYYY-MM' })\n endMonth?: string\n\n @Field(type => ObjectRef, { nullable: true, description: 'Who it is paid to or received from' })\n counterparty?: ObjectRef\n\n @Field({ nullable: true, description: 'Whether it still makes forecasts' })\n active?: boolean\n\n @Field({ nullable: true, description: 'Notes' })\n notes?: string\n\n @Field({ nullable: true, description: '+ adds, M changes, - deletes' })\n cuFlag?: string\n}\n\n@ObjectType({ description: 'A page of recurring items' })\nexport class RecurringCashItemList {\n @Field(type => [RecurringCashItem], { description: 'The items on this page' })\n items: RecurringCashItem[]\n\n @Field(type => Int, { description: 'How many there are in all' })\n total: number\n}\n"]}
1
+ {"version":3,"file":"recurring-cash-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phql'\n\nimport { ObjectRef } from '@things-factory/shell'\n\nimport { CashFlowType } from '../cash-flow-type'\nimport { RecurringCashItem } from './recurring-cash-item'\n\n@InputType({ description: 'A recurring item, or a grid row: cuFlag + adds, M changes, - deletes' })\nexport class RecurringCashItemPatch {\n @Field(type => ID, { nullable: true, description: 'The item to change or delete' })\n id?: string\n\n @Field({ nullable: true, description: 'What it is' })\n name?: string\n\n @Field(type => ObjectRef, { nullable: true, description: 'The account subject it is booked to' })\n account?: ObjectRef\n\n @Field(type => CashFlowType, { nullable: true, description: 'Money in or money out' })\n type?: CashFlowType\n\n @Field(type => Float, { nullable: true, description: 'Amount every month' })\n amount?: number\n\n @Field({ nullable: true, description: 'ISO 4217 code' })\n currency?: string\n\n @Field(type => Int, { nullable: true, description: '1-31' })\n dayOfMonth?: number\n\n @Field({ nullable: true, description: 'Falls on the last day of every month' })\n lastDayOfMonth?: boolean\n\n @Field({ nullable: true, description: 'First month - YYYY-MM' })\n startMonth?: string\n\n @Field({ nullable: true, description: 'Last month - YYYY-MM' })\n endMonth?: string\n\n @Field(type => ObjectRef, { nullable: true, description: 'Who it is paid to or received from' })\n counterparty?: ObjectRef\n\n @Field({ nullable: true, description: 'Whether it still falls in its months' })\n active?: boolean\n\n @Field({ nullable: true, description: 'Notes' })\n notes?: string\n\n @Field({ nullable: true, description: '+ adds, M changes, - deletes' })\n cuFlag?: string\n}\n\n@ObjectType({ description: 'A page of recurring items' })\nexport class RecurringCashItemList {\n @Field(type => [RecurringCashItem], { description: 'The items on this page' })\n items: RecurringCashItem[]\n\n @Field(type => Int, { description: 'How many there are in all' })\n total: number\n}\n"]}
@@ -4,8 +4,8 @@ import { Counterparty } from '@things-factory/biz-base';
4
4
  import { Account } from '../account/account';
5
5
  import { CashFlowType } from '../cash-flow-type';
6
6
  /**
7
- * Money that comes in or goes out every month on a known day - rent, a subscription, a loan's interest. Each month it
8
- * falls in, it makes a forecast (§`Transaction.recurringItem`).
7
+ * Money that comes in or goes out every month on a known day - rent, a subscription, a loan's interest. An app reads
8
+ * the months it falls in as money still to come (§`recurring-schedule`); nothing is written for them.
9
9
  */
10
10
  export declare class RecurringCashItem {
11
11
  readonly id: string;
@@ -10,8 +10,8 @@ const biz_base_1 = require("@things-factory/biz-base");
10
10
  const account_1 = require("../account/account");
11
11
  const cash_flow_type_1 = require("../cash-flow-type");
12
12
  /**
13
- * Money that comes in or goes out every month on a known day - rent, a subscription, a loan's interest. Each month it
14
- * falls in, it makes a forecast (§`Transaction.recurringItem`).
13
+ * Money that comes in or goes out every month on a known day - rent, a subscription, a loan's interest. An app reads
14
+ * the months it falls in as money still to come (§`recurring-schedule`); nothing is written for them.
15
15
  */
16
16
  let RecurringCashItem = class RecurringCashItem {
17
17
  };
@@ -32,7 +32,7 @@ tslib_1.__decorate([
32
32
  ], RecurringCashItem.prototype, "domainId", void 0);
33
33
  tslib_1.__decorate([
34
34
  (0, typeorm_1.Column)(),
35
- (0, type_graphql_1.Field)({ description: 'What it is - the forecasts it makes take this as their description' }),
35
+ (0, type_graphql_1.Field)({ description: 'What it is' }),
36
36
  tslib_1.__metadata("design:type", String)
37
37
  ], RecurringCashItem.prototype, "name", void 0);
38
38
  tslib_1.__decorate([
@@ -93,7 +93,7 @@ tslib_1.__decorate([
93
93
  ], RecurringCashItem.prototype, "counterpartyId", void 0);
94
94
  tslib_1.__decorate([
95
95
  (0, typeorm_1.Column)({ default: true }),
96
- (0, type_graphql_1.Field)({ description: 'An inactive item makes no more forecasts' }),
96
+ (0, type_graphql_1.Field)({ description: 'An inactive item falls in no more months' }),
97
97
  tslib_1.__metadata("design:type", Boolean)
98
98
  ], RecurringCashItem.prototype, "active", void 0);
99
99
  tslib_1.__decorate([
@@ -113,7 +113,7 @@ tslib_1.__decorate([
113
113
  ], RecurringCashItem.prototype, "updatedAt", void 0);
114
114
  tslib_1.__decorate([
115
115
  (0, typeorm_1.DeleteDateColumn)(),
116
- (0, type_graphql_1.Field)({ nullable: true, description: 'When it was deleted - the forecasts it made are kept' }),
116
+ (0, type_graphql_1.Field)({ nullable: true, description: 'When it was deleted' }),
117
117
  tslib_1.__metadata("design:type", Date)
118
118
  ], RecurringCashItem.prototype, "deletedAt", void 0);
119
119
  tslib_1.__decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"recurring-cash-item.js","sourceRoot":"","sources":["../../../server/service/recurring-cash-item/recurring-cash-item.ts"],"names":[],"mappings":";;;;AAAA,qCAUgB;AAChB,+CAAgE;AAEhE,iDAA2D;AAC3D,yDAAgD;AAChD,uDAAuD;AAEvD,gDAA4C;AAC5C,sDAAgD;AAEhD;;;GAGG;AAII,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CA8F7B,CAAA;AA9FY,8CAAiB;AAGnB;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;;6CACrC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;sCAC7E,cAAM;iDAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,IAAuB,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;;mDACpC;AAIjB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,oEAAoE,EAAE,CAAC;;+CACjF;AAIZ;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;IACpE,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAO,EAAE,EAAE,QAAQ,EAAE,IAA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,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;sCAC7D,gBAAI;kDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,IAAuB,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;;oDACpC;AAIlB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;sCAClE,gBAAI;kDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,IAAuB,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;;oDACpC;4BA7FP,iBAAiB;IAH7B,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,0BAA0B,EAAE,CAAC,IAAuB,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1F,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,4DAA4D,EAAE,CAAC;GAC7E,iBAAiB,CA8F7B","sourcesContent":["import {\n Column,\n CreateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\nimport { Field, Float, ID, Int, ObjectType } from 'type-graphql'\n\nimport { Domain, moneyColumn } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Counterparty } from '@things-factory/biz-base'\n\nimport { Account } from '../account/account'\nimport { CashFlowType } from '../cash-flow-type'\n\n/**\n * Money that comes in or goes out every month on a known day - rent, a subscription, a loan's interest. Each month it\n * falls in, it makes a forecast (§`Transaction.recurringItem`).\n */\n@Entity()\n@Index('ix_recurring_cash_item_0', (item: RecurringCashItem) => [item.domain, item.active])\n@ObjectType({ description: 'Money that comes in or goes out every month on a known day' })\nexport class RecurringCashItem {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier' })\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain whose item it is' })\n domain?: Domain\n\n @RelationId((item: RecurringCashItem) => item.domain)\n domainId?: string\n\n @Column()\n @Field({ description: 'What it is - the forecasts it makes take this as their description' })\n name: string\n\n @ManyToOne(type => Account, { nullable: true, onDelete: 'SET NULL' })\n @Field(type => Account, { nullable: true, description: 'The account subject it is booked to' })\n account?: Account\n\n @RelationId((item: RecurringCashItem) => item.account)\n accountId?: string\n\n @Column({ default: CashFlowType.EXPENSE })\n @Field(type => CashFlowType, { description: 'Money in or money out' })\n type: CashFlowType\n\n @Column(moneyColumn())\n @Field(type => Float, { description: 'Amount every month' })\n amount: number\n\n @Column({ default: 'KRW' })\n @Field({ description: 'ISO 4217 code' })\n currency: string\n\n @Column({ type: 'int', nullable: true })\n @Field(type => Int, {\n nullable: true,\n description: \"1-31; a day past the month's end is its last day. Empty with lastDayOfMonth\"\n })\n dayOfMonth?: number\n\n @Column({ default: false })\n @Field({ description: 'Falls on the last day of every month' })\n lastDayOfMonth: boolean\n\n @Column()\n @Field({ description: 'First month - YYYY-MM' })\n startMonth: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Last month; open-ended when empty - YYYY-MM' })\n endMonth?: string\n\n @ManyToOne(type => Counterparty, { nullable: true, onDelete: 'SET NULL' })\n @Field(type => Counterparty, { nullable: true, description: 'Who it is paid to or received from' })\n counterparty?: Counterparty\n\n @RelationId((item: RecurringCashItem) => item.counterparty)\n counterpartyId?: string\n\n @Column({ default: true })\n @Field({ description: 'An inactive item makes no more forecasts' })\n active: boolean\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Notes' })\n notes?: string\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'When it was created' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'When it last changed' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'When it was deleted - the forecasts it made are kept' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who created it' })\n creator?: User\n\n @RelationId((item: RecurringCashItem) => item.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who last changed it' })\n updater?: User\n\n @RelationId((item: RecurringCashItem) => item.updater)\n updaterId?: string\n}\n"]}
1
+ {"version":3,"file":"recurring-cash-item.js","sourceRoot":"","sources":["../../../server/service/recurring-cash-item/recurring-cash-item.ts"],"names":[],"mappings":";;;;AAAA,qCAUgB;AAChB,+CAAgE;AAEhE,iDAA2D;AAC3D,yDAAgD;AAChD,uDAAuD;AAEvD,gDAA4C;AAC5C,sDAAgD;AAEhD;;;GAGG;AAII,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CA8F7B,CAAA;AA9FY,8CAAiB;AAGnB;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;;6CACrC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;sCAC7E,cAAM;iDAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,IAAuB,EAAE,EAAE,CAAC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,4DAA4D,EAAE,CAAC;GAC7E,iBAAiB,CA8F7B","sourcesContent":["import {\n Column,\n CreateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\nimport { Field, Float, ID, Int, ObjectType } from 'type-graphql'\n\nimport { Domain, moneyColumn } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Counterparty } from '@things-factory/biz-base'\n\nimport { Account } from '../account/account'\nimport { CashFlowType } from '../cash-flow-type'\n\n/**\n * Money that comes in or goes out every month on a known day - rent, a subscription, a loan's interest. An app reads\n * the months it falls in as money still to come (§`recurring-schedule`); nothing is written for them.\n */\n@Entity()\n@Index('ix_recurring_cash_item_0', (item: RecurringCashItem) => [item.domain, item.active])\n@ObjectType({ description: 'Money that comes in or goes out every month on a known day' })\nexport class RecurringCashItem {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier' })\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain whose item it is' })\n domain?: Domain\n\n @RelationId((item: RecurringCashItem) => item.domain)\n domainId?: string\n\n @Column()\n @Field({ description: 'What it is' })\n name: string\n\n @ManyToOne(type => Account, { nullable: true, onDelete: 'SET NULL' })\n @Field(type => Account, { nullable: true, description: 'The account subject it is booked to' })\n account?: Account\n\n @RelationId((item: RecurringCashItem) => item.account)\n accountId?: string\n\n @Column({ default: CashFlowType.EXPENSE })\n @Field(type => CashFlowType, { description: 'Money in or money out' })\n type: CashFlowType\n\n @Column(moneyColumn())\n @Field(type => Float, { description: 'Amount every month' })\n amount: number\n\n @Column({ default: 'KRW' })\n @Field({ description: 'ISO 4217 code' })\n currency: string\n\n @Column({ type: 'int', nullable: true })\n @Field(type => Int, {\n nullable: true,\n description: \"1-31; a day past the month's end is its last day. Empty with lastDayOfMonth\"\n })\n dayOfMonth?: number\n\n @Column({ default: false })\n @Field({ description: 'Falls on the last day of every month' })\n lastDayOfMonth: boolean\n\n @Column()\n @Field({ description: 'First month - YYYY-MM' })\n startMonth: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Last month; open-ended when empty - YYYY-MM' })\n endMonth?: string\n\n @ManyToOne(type => Counterparty, { nullable: true, onDelete: 'SET NULL' })\n @Field(type => Counterparty, { nullable: true, description: 'Who it is paid to or received from' })\n counterparty?: Counterparty\n\n @RelationId((item: RecurringCashItem) => item.counterparty)\n counterpartyId?: string\n\n @Column({ default: true })\n @Field({ description: 'An inactive item falls in no more months' })\n active: boolean\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Notes' })\n notes?: string\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'When it was created' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'When it last changed' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'When it was deleted' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who created it' })\n creator?: User\n\n @RelationId((item: RecurringCashItem) => item.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who last changed it' })\n updater?: User\n\n @RelationId((item: RecurringCashItem) => item.updater)\n updaterId?: string\n}\n"]}
@@ -1,10 +1,9 @@
1
1
  /**
2
- * Which recurring items fall in a month, and the forecast line each one makes.
2
+ * Which recurring items fall in a month, and on which day of it.
3
3
  *
4
- * An item falls in a month when it is active and the month lies within [startMonth, endMonth].
5
- * Its timing is written the way the forecast ledger writes it — `21일`, `말일` — so the calendar
6
- * places the line on that day (§`forecastDay`). An item with neither a day nor 말일 makes a line
7
- * with no timing: the calendar shows it undated, as it does any line nobody gave a day.
4
+ * An item falls in a month when it is active and the month lies within [startMonth, endMonth]. Its day is the day of
5
+ * the month it names - one past the month's end is the last day, as a ledger means it - or the last day for 말일. An
6
+ * item with neither has no day: the calendar shows its month undated, as it does any money nobody gave a day.
8
7
  *
9
8
  * Pure.
10
9
  */
@@ -20,17 +19,6 @@ export interface RecurringItem {
20
19
  endMonth?: string | null;
21
20
  active?: boolean | null;
22
21
  }
23
- export interface GeneratedLine {
24
- recurringItemId: string;
25
- year: number;
26
- month: number;
27
- type: string;
28
- name: string;
29
- amount: number;
30
- currency: string;
31
- timing: string | null;
32
- }
33
22
  export declare function fallsIn(item: RecurringItem, year: number, month: number): boolean;
34
- export declare function timingOf(item: RecurringItem): string | null;
35
- /** The lines to add for a month — leaving out items that already made one (`already`). */
36
- export declare function linesFor(items: readonly RecurringItem[], year: number, month: number, already: ReadonlySet<string>): GeneratedLine[];
23
+ /** The `YYYY-MM-DD` the item falls on in a month, or null when it names no day. */
24
+ export declare function recurringDay(item: Pick<RecurringItem, 'dayOfMonth' | 'lastDayOfMonth'>, year: number, month: number): string | null;
@@ -1,41 +1,28 @@
1
1
  "use strict";
2
2
  /**
3
- * Which recurring items fall in a month, and the forecast line each one makes.
3
+ * Which recurring items fall in a month, and on which day of it.
4
4
  *
5
- * An item falls in a month when it is active and the month lies within [startMonth, endMonth].
6
- * Its timing is written the way the forecast ledger writes it — `21일`, `말일` — so the calendar
7
- * places the line on that day (§`forecastDay`). An item with neither a day nor 말일 makes a line
8
- * with no timing: the calendar shows it undated, as it does any line nobody gave a day.
5
+ * An item falls in a month when it is active and the month lies within [startMonth, endMonth]. Its day is the day of
6
+ * the month it names - one past the month's end is the last day, as a ledger means it - or the last day for 말일. An
7
+ * item with neither has no day: the calendar shows its month undated, as it does any money nobody gave a day.
9
8
  *
10
9
  * Pure.
11
10
  */
12
11
  Object.defineProperty(exports, "__esModule", { value: true });
13
12
  exports.fallsIn = fallsIn;
14
- exports.timingOf = timingOf;
15
- exports.linesFor = linesFor;
16
- const monthKey = (year, month) => `${year}-${String(month).padStart(2, '0')}`;
13
+ exports.recurringDay = recurringDay;
14
+ const pad = (n) => String(n).padStart(2, '0');
15
+ const monthKey = (year, month) => `${year}-${pad(month)}`;
16
+ const lastDay = (year, month) => new Date(Date.UTC(year, month, 0)).getUTCDate();
17
17
  function fallsIn(item, year, month) {
18
18
  const key = monthKey(year, month);
19
19
  return item.active !== false && item.startMonth <= key && (!item.endMonth || key <= item.endMonth);
20
20
  }
21
- function timingOf(item) {
21
+ /** The `YYYY-MM-DD` the item falls on in a month, or null when it names no day. */
22
+ function recurringDay(item, year, month) {
23
+ const last = lastDay(year, month);
22
24
  if (item.lastDayOfMonth)
23
- return '말일';
24
- return item.dayOfMonth ? `${item.dayOfMonth}일` : null;
25
- }
26
- /** The lines to add for a month — leaving out items that already made one (`already`). */
27
- function linesFor(items, year, month, already) {
28
- return items
29
- .filter(item => fallsIn(item, year, month) && !already.has(item.id))
30
- .map(item => ({
31
- recurringItemId: item.id,
32
- year,
33
- month,
34
- type: item.type,
35
- name: item.name,
36
- amount: item.amount,
37
- currency: item.currency || 'KRW',
38
- timing: timingOf(item)
39
- }));
25
+ return `${monthKey(year, month)}-${pad(last)}`;
26
+ return item.dayOfMonth && item.dayOfMonth >= 1 ? `${monthKey(year, month)}-${pad(Math.min(item.dayOfMonth, last))}` : null;
40
27
  }
41
28
  //# sourceMappingURL=recurring-schedule.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"recurring-schedule.js","sourceRoot":"","sources":["../../../server/service/recurring-cash-item/recurring-schedule.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AA4BH,0BAGC;AAED,4BAGC;AAGD,4BAkBC;AA/BD,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,KAAa,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAA;AAE7F,SAAgB,OAAO,CAAC,IAAmB,EAAE,IAAY,EAAE,KAAa;IACtE,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IACjC,OAAO,IAAI,CAAC,MAAM,KAAK,KAAK,IAAI,IAAI,CAAC,UAAU,IAAI,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAA;AACpG,CAAC;AAED,SAAgB,QAAQ,CAAC,IAAmB;IAC1C,IAAI,IAAI,CAAC,cAAc;QAAE,OAAO,IAAI,CAAA;IACpC,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,IAAI,CAAA;AACvD,CAAC;AAED,0FAA0F;AAC1F,SAAgB,QAAQ,CACtB,KAA+B,EAC/B,IAAY,EACZ,KAAa,EACb,OAA4B;IAE5B,OAAO,KAAK;SACT,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACnE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACZ,eAAe,EAAE,IAAI,CAAC,EAAE;QACxB,IAAI;QACJ,KAAK;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,KAAK;QAChC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC;KACvB,CAAC,CAAC,CAAA;AACP,CAAC","sourcesContent":["/**\n * Which recurring items fall in a month, and the forecast line each one makes.\n *\n * An item falls in a month when it is active and the month lies within [startMonth, endMonth].\n * Its timing is written the way the forecast ledger writes it — `21일`, `말일` — so the calendar\n * places the line on that day (§`forecastDay`). An item with neither a day nor 말일 makes a line\n * with no timing: the calendar shows it undated, as it does any line nobody gave a day.\n *\n * Pure.\n */\n\nexport interface RecurringItem {\n id: string\n name: string\n type: string\n amount: number\n currency?: string | null\n dayOfMonth?: number | null\n lastDayOfMonth?: boolean | null\n startMonth: string\n endMonth?: string | null\n active?: boolean | null\n}\n\nexport interface GeneratedLine {\n recurringItemId: string\n year: number\n month: number\n type: string\n name: string\n amount: number\n currency: string\n timing: string | null\n}\n\nconst monthKey = (year: number, month: number) => `${year}-${String(month).padStart(2, '0')}`\n\nexport function fallsIn(item: RecurringItem, year: number, month: number): boolean {\n const key = monthKey(year, month)\n return item.active !== false && item.startMonth <= key && (!item.endMonth || key <= item.endMonth)\n}\n\nexport function timingOf(item: RecurringItem): string | null {\n if (item.lastDayOfMonth) return '말일'\n return item.dayOfMonth ? `${item.dayOfMonth}일` : null\n}\n\n/** The lines to add for a month — leaving out items that already made one (`already`). */\nexport function linesFor(\n items: readonly RecurringItem[],\n year: number,\n month: number,\n already: ReadonlySet<string>\n): GeneratedLine[] {\n return items\n .filter(item => fallsIn(item, year, month) && !already.has(item.id))\n .map(item => ({\n recurringItemId: item.id,\n year,\n month,\n type: item.type,\n name: item.name,\n amount: item.amount,\n currency: item.currency || 'KRW',\n timing: timingOf(item)\n }))\n}\n"]}
1
+ {"version":3,"file":"recurring-schedule.js","sourceRoot":"","sources":["../../../server/service/recurring-cash-item/recurring-schedule.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAmBH,0BAGC;AAGD,oCAIC;AAdD,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;AACrD,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,KAAa,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,CAAA;AACzE,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,KAAa,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAA;AAEhG,SAAgB,OAAO,CAAC,IAAmB,EAAE,IAAY,EAAE,KAAa;IACtE,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IACjC,OAAO,IAAI,CAAC,MAAM,KAAK,KAAK,IAAI,IAAI,CAAC,UAAU,IAAI,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAA;AACpG,CAAC;AAED,mFAAmF;AACnF,SAAgB,YAAY,CAAC,IAA0D,EAAE,IAAY,EAAE,KAAa;IAClH,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IACjC,IAAI,IAAI,CAAC,cAAc;QAAE,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE,CAAA;IACvE,OAAO,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;AAC5H,CAAC","sourcesContent":["/**\n * Which recurring items fall in a month, and on which day of it.\n *\n * An item falls in a month when it is active and the month lies within [startMonth, endMonth]. Its day is the day of\n * the month it names - one past the month's end is the last day, as a ledger means it - or the last day for 말일. An\n * item with neither has no day: the calendar shows its month undated, as it does any money nobody gave a day.\n *\n * Pure.\n */\n\nexport interface RecurringItem {\n id: string\n name: string\n type: string\n amount: number\n currency?: string | null\n dayOfMonth?: number | null\n lastDayOfMonth?: boolean | null\n startMonth: string\n endMonth?: string | null\n active?: boolean | null\n}\n\nconst pad = (n: number) => String(n).padStart(2, '0')\nconst monthKey = (year: number, month: number) => `${year}-${pad(month)}`\nconst lastDay = (year: number, month: number) => new Date(Date.UTC(year, month, 0)).getUTCDate()\n\nexport function fallsIn(item: RecurringItem, year: number, month: number): boolean {\n const key = monthKey(year, month)\n return item.active !== false && item.startMonth <= key && (!item.endMonth || key <= item.endMonth)\n}\n\n/** The `YYYY-MM-DD` the item falls on in a month, or null when it names no day. */\nexport function recurringDay(item: Pick<RecurringItem, 'dayOfMonth' | 'lastDayOfMonth'>, year: number, month: number): string | null {\n const last = lastDay(year, month)\n if (item.lastDayOfMonth) return `${monthKey(year, month)}-${pad(last)}`\n return item.dayOfMonth && item.dayOfMonth >= 1 ? `${monthKey(year, month)}-${pad(Math.min(item.dayOfMonth, last))}` : null\n}\n"]}
@@ -6,8 +6,7 @@ import { Account } from '../account/account';
6
6
  import { BankAccount } from '../bank-account/bank-account';
7
7
  import { BankStatement } from '../bank-statement/bank-statement';
8
8
  import { CashFlowType } from '../cash-flow-type';
9
- import { RecurringCashItem } from '../recurring-cash-item/recurring-cash-item';
10
- import { ForecastStatus, Transaction, TransactionCategory, TransactionSource } from './transaction';
9
+ import { Transaction, TransactionCategory, TransactionSource } from './transaction';
11
10
  /** Each version of a transaction, written when it changes. */
12
11
  export declare class TransactionHistory implements HistoryEntityInterface<Transaction> {
13
12
  readonly id: string;
@@ -45,12 +44,7 @@ export declare class TransactionHistory implements HistoryEntityInterface<Transa
45
44
  bankCounterpartyAccount: string;
46
45
  bankCounterpartyBank: string;
47
46
  bankMemo: string;
48
- timing: string;
49
- status: ForecastStatus;
50
- probability: number;
51
47
  notes: string;
52
- recurringItem: RecurringCashItem;
53
- recurringItemId?: string;
54
48
  createdAt?: Date;
55
49
  updatedAt?: Date;
56
50
  deletedAt?: Date;
@@ -13,7 +13,6 @@ const account_1 = require("../account/account");
13
13
  const bank_account_1 = require("../bank-account/bank-account");
14
14
  const bank_statement_1 = require("../bank-statement/bank-statement");
15
15
  const cash_flow_type_1 = require("../cash-flow-type");
16
- const recurring_cash_item_1 = require("../recurring-cash-item/recurring-cash-item");
17
16
  const transaction_1 = require("./transaction");
18
17
  const ORMCONFIG = env_1.config.get('ormconfig', {});
19
18
  const DATABASE_TYPE = ORMCONFIG.type;
@@ -194,35 +193,11 @@ tslib_1.__decorate([
194
193
  (0, type_graphql_1.Field)({ nullable: true, description: 'bankMemo at this version' }),
195
194
  tslib_1.__metadata("design:type", String)
196
195
  ], TransactionHistory.prototype, "bankMemo", void 0);
197
- tslib_1.__decorate([
198
- (0, typeorm_1.Column)({ nullable: true }),
199
- (0, type_graphql_1.Field)({ nullable: true, description: 'timing at this version' }),
200
- tslib_1.__metadata("design:type", String)
201
- ], TransactionHistory.prototype, "timing", void 0);
202
- tslib_1.__decorate([
203
- (0, typeorm_1.Column)({ nullable: true }),
204
- (0, type_graphql_1.Field)(type => transaction_1.ForecastStatus, { nullable: true, description: 'status at this version' }),
205
- tslib_1.__metadata("design:type", String)
206
- ], TransactionHistory.prototype, "status", void 0);
207
- tslib_1.__decorate([
208
- (0, typeorm_1.Column)({ type: 'int', nullable: true }),
209
- (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: 'probability at this version' }),
210
- tslib_1.__metadata("design:type", Number)
211
- ], TransactionHistory.prototype, "probability", void 0);
212
196
  tslib_1.__decorate([
213
197
  (0, typeorm_1.Column)({ type: 'text', nullable: true }),
214
198
  (0, type_graphql_1.Field)({ nullable: true, description: 'notes at this version' }),
215
199
  tslib_1.__metadata("design:type", String)
216
200
  ], TransactionHistory.prototype, "notes", void 0);
217
- tslib_1.__decorate([
218
- (0, typeorm_1.ManyToOne)(type => recurring_cash_item_1.RecurringCashItem, { nullable: true, createForeignKeyConstraints: false }),
219
- (0, type_graphql_1.Field)(type => recurring_cash_item_1.RecurringCashItem, { nullable: true, description: 'recurringItem at this version' }),
220
- tslib_1.__metadata("design:type", recurring_cash_item_1.RecurringCashItem)
221
- ], TransactionHistory.prototype, "recurringItem", void 0);
222
- tslib_1.__decorate([
223
- (0, typeorm_1.RelationId)((transactionHistory) => transactionHistory.recurringItem),
224
- tslib_1.__metadata("design:type", String)
225
- ], TransactionHistory.prototype, "recurringItemId", void 0);
226
201
  tslib_1.__decorate([
227
202
  (0, typeorm_1.Column)({ nullable: true }),
228
203
  (0, type_graphql_1.Field)({ nullable: true, description: 'When it was created' }),