taxtank-core 0.33.59 → 0.33.61

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. package/esm2022/src/lib/collections/asset-sale.collection.mjs +4 -1
  2. package/esm2022/src/lib/collections/collection-dictionary.mjs +10 -1
  3. package/esm2022/src/lib/collections/collection.mjs +1 -1
  4. package/esm2022/src/lib/collections/holding/holding-sale.collection.mjs +3 -3
  5. package/esm2022/src/lib/collections/holding/holding-trade.collection.mjs +78 -0
  6. package/esm2022/src/lib/collections/holding/holding.collection.mjs +19 -54
  7. package/esm2022/src/lib/collections/holding/index.mjs +3 -2
  8. package/esm2022/src/lib/db/Enums/holding/holding-trade-type.enum.mjs +6 -0
  9. package/esm2022/src/lib/db/Enums/holding/holding-type-category.enum.mjs +1 -1
  10. package/esm2022/src/lib/db/Enums/holding/index.mjs +2 -1
  11. package/esm2022/src/lib/db/Models/holding/holding-sale.mjs +1 -1
  12. package/esm2022/src/lib/db/Models/holding/holding-trade-import.mjs +3 -0
  13. package/esm2022/src/lib/db/Models/holding/holding-trade.mjs +3 -0
  14. package/esm2022/src/lib/db/Models/holding/index.mjs +2 -2
  15. package/esm2022/src/lib/forms/abstract.form.mjs +12 -2
  16. package/esm2022/src/lib/forms/bank/bank-account/bank-account-properties.form.mjs +3 -4
  17. package/esm2022/src/lib/forms/holding/holding-reinvest.form.mjs +14 -14
  18. package/esm2022/src/lib/forms/holding/holding-sale.form.mjs +3 -2
  19. package/esm2022/src/lib/forms/holding/holding-trade/holding-trade-filter.form.mjs +25 -0
  20. package/esm2022/src/lib/forms/holding/holding-trade/holding-trade.form.mjs +30 -0
  21. package/esm2022/src/lib/forms/holding/holding-trade/index.mjs +3 -0
  22. package/esm2022/src/lib/forms/holding/holding-trade-import.form.mjs +25 -0
  23. package/esm2022/src/lib/forms/holding/index.mjs +3 -3
  24. package/esm2022/src/lib/models/endpoint/endpoints.const.mjs +9 -9
  25. package/esm2022/src/lib/models/holding/holding-reinvest.mjs +4 -4
  26. package/esm2022/src/lib/models/holding/holding-sale.mjs +10 -1
  27. package/esm2022/src/lib/models/holding/holding-trade-import.mjs +16 -0
  28. package/esm2022/src/lib/models/holding/holding-trade.mjs +77 -0
  29. package/esm2022/src/lib/models/holding/holding-type-exchange.mjs +4 -1
  30. package/esm2022/src/lib/models/holding/holding-type.mjs +4 -1
  31. package/esm2022/src/lib/models/holding/holding.mjs +44 -71
  32. package/esm2022/src/lib/models/holding/index.mjs +4 -3
  33. package/esm2022/src/lib/services/account-setup/account-setup.service.mjs +3 -3
  34. package/esm2022/src/lib/services/http/holding/holding-trade-import/holding-trade-import-messages.enum.mjs +9 -0
  35. package/esm2022/src/lib/services/http/holding/holding-trade-import/holding-trade-import.service.mjs +37 -0
  36. package/esm2022/src/lib/services/http/holding/holding-trade-messages.enum.mjs +10 -0
  37. package/esm2022/src/lib/services/http/holding/holding-trade.service.mjs +44 -0
  38. package/esm2022/src/lib/services/http/holding/index.mjs +5 -6
  39. package/esm2022/src/lib/services/http/rest/rest.service.mjs +8 -6
  40. package/esm2022/src/lib/services/http/transaction/transaction-allocation/allocation-rule/allocation-rule.service.mjs +5 -3
  41. package/fesm2022/taxtank-core.mjs +347 -193
  42. package/fesm2022/taxtank-core.mjs.map +1 -1
  43. package/package.json +1 -1
  44. package/src/lib/collections/asset-sale.collection.d.ts +3 -0
  45. package/src/lib/collections/collection-dictionary.d.ts +1 -0
  46. package/src/lib/collections/holding/holding-sale.collection.d.ts +4 -4
  47. package/src/lib/collections/holding/holding-trade.collection.d.ts +21 -0
  48. package/src/lib/collections/holding/holding.collection.d.ts +7 -10
  49. package/src/lib/collections/holding/index.d.ts +2 -1
  50. package/src/lib/db/Enums/holding/holding-trade-type.enum.d.ts +4 -0
  51. package/src/lib/db/Enums/holding/index.d.ts +1 -0
  52. package/src/lib/db/Models/holding/holding-sale.d.ts +2 -2
  53. package/src/lib/db/Models/holding/holding-trade-import.d.ts +8 -0
  54. package/src/lib/db/Models/holding/{holding.d.ts → holding-trade.d.ts} +1 -1
  55. package/src/lib/db/Models/holding/index.d.ts +1 -1
  56. package/src/lib/forms/abstract.form.d.ts +3 -1
  57. package/src/lib/forms/bank/bank-account/bank-account-properties.form.d.ts +1 -1
  58. package/src/lib/forms/holding/holding-reinvest.form.d.ts +5 -5
  59. package/src/lib/forms/holding/holding-sale.form.d.ts +2 -2
  60. package/src/lib/forms/holding/holding-trade/holding-trade-filter.form.d.ts +9 -0
  61. package/src/lib/forms/holding/holding-trade/holding-trade.form.d.ts +9 -0
  62. package/src/lib/forms/holding/holding-trade/index.d.ts +2 -0
  63. package/src/lib/forms/holding/holding-trade-import.form.d.ts +8 -0
  64. package/src/lib/forms/holding/index.d.ts +2 -2
  65. package/src/lib/models/holding/holding-reinvest.d.ts +2 -2
  66. package/src/lib/models/holding/holding-sale.d.ts +16 -4
  67. package/src/lib/models/holding/holding-trade-import.d.ts +8 -0
  68. package/src/lib/models/holding/holding-trade.d.ts +41 -0
  69. package/src/lib/models/holding/holding-type-exchange.d.ts +3 -0
  70. package/src/lib/models/holding/holding-type.d.ts +3 -0
  71. package/src/lib/models/holding/holding.d.ts +18 -34
  72. package/src/lib/models/holding/index.d.ts +3 -2
  73. package/src/lib/services/account-setup/account-setup.service.d.ts +2 -2
  74. package/src/lib/services/http/holding/{holding-import/holding-import-messages.enum.d.ts → holding-trade-import/holding-trade-import-messages.enum.d.ts} +1 -1
  75. package/src/lib/services/http/holding/holding-trade-import/holding-trade-import.service.d.ts +17 -0
  76. package/src/lib/services/http/holding/{holding-messages.enum.d.ts → holding-trade-messages.enum.d.ts} +1 -1
  77. package/src/lib/services/http/holding/holding-trade.service.d.ts +20 -0
  78. package/src/lib/services/http/holding/index.d.ts +4 -5
  79. package/src/lib/services/http/rest/rest.service.d.ts +4 -4
  80. package/src/lib/services/http/transaction/transaction-allocation/allocation-rule/allocation-rule.service.d.ts +1 -3
  81. package/esm2022/src/lib/db/Models/holding/holding-import.mjs +0 -3
  82. package/esm2022/src/lib/db/Models/holding/holding.mjs +0 -3
  83. package/esm2022/src/lib/forms/holding/holding-import.form.mjs +0 -25
  84. package/esm2022/src/lib/forms/holding/holding.form.mjs +0 -28
  85. package/esm2022/src/lib/models/holding/holding-import.mjs +0 -16
  86. package/esm2022/src/lib/services/http/holding/holding-import/holding-import-messages.enum.mjs +0 -9
  87. package/esm2022/src/lib/services/http/holding/holding-import/holding-import.service.mjs +0 -37
  88. package/esm2022/src/lib/services/http/holding/holding-messages.enum.mjs +0 -10
  89. package/esm2022/src/lib/services/http/holding/holding-sale-messages.enum.mjs +0 -8
  90. package/esm2022/src/lib/services/http/holding/holding.service.mjs +0 -44
  91. package/src/lib/db/Models/holding/holding-import.d.ts +0 -8
  92. package/src/lib/forms/holding/holding-import.form.d.ts +0 -8
  93. package/src/lib/forms/holding/holding.form.d.ts +0 -8
  94. package/src/lib/models/holding/holding-import.d.ts +0 -8
  95. package/src/lib/services/http/holding/holding-import/holding-import.service.d.ts +0 -17
  96. package/src/lib/services/http/holding/holding-sale-messages.enum.d.ts +0 -6
  97. package/src/lib/services/http/holding/holding.service.d.ts +0 -20
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taxtank-core",
3
- "version": "0.33.59",
3
+ "version": "0.33.61",
4
4
  "private": false,
5
5
  "peerDependencies": {
6
6
  "@angular/common": "^17.0.0",
@@ -3,6 +3,9 @@ import { AssetSale } from '../models';
3
3
  export declare class AssetSaleCollection extends Collection<AssetSale> {
4
4
  get grossCapitalProfit(): number;
5
5
  get fullExemptionSales(): this;
6
+ /**
7
+ * true only for isTaxFree=true
8
+ */
6
9
  get fullExemptionGrossCapitalProfit(): number;
7
10
  get halfExemptionGrossCapitalProfit(): number;
8
11
  get noExemptionGrossCapitalProfit(): number;
@@ -53,4 +53,5 @@ export declare class CollectionDictionary<Collection extends BaseCollection<obje
53
53
  * Group collection items by passed path into items object
54
54
  */
55
55
  private groupItems;
56
+ filter(callback: (collection: Collection) => boolean): CollectionDictionary<Collection>;
56
57
  }
@@ -1,10 +1,10 @@
1
- import { Dictionary, Holding, HoldingSale } from '../../models';
1
+ import { Dictionary, HoldingSale, HoldingTrade } from '../../models';
2
2
  import { ExportableCollection } from '../exportable.collection';
3
3
  import { ExportCell } from '../../models/export/export-cell';
4
- import { HoldingCollection } from './holding.collection';
4
+ import { HoldingTradeCollection } from './holding-trade.collection';
5
5
  export declare class HoldingSaleCollection extends ExportableCollection<HoldingSale> {
6
- filterByTaxFree(holdings: HoldingCollection, isTaxFree?: boolean): this;
6
+ filterByTaxFree(holdings: HoldingTradeCollection, isTaxFree?: boolean): this;
7
7
  getExportHeader(): string[];
8
8
  getExportFooter(): ExportCell[];
9
- getExportBody(holdingsById: Dictionary<Holding>): ExportCell[][];
9
+ getExportBody(holdingsById: Dictionary<HoldingTrade>): ExportCell[][];
10
10
  }
@@ -0,0 +1,21 @@
1
+ import { ExportableCollection } from '../exportable.collection';
2
+ import { HoldingTrade } from '../../models';
3
+ import { ExportCell } from '../../models/export/export-cell';
4
+ export declare class HoldingTradeCollection extends ExportableCollection<HoldingTrade> {
5
+ getExportHeader(): string[];
6
+ getExportFooter(): ExportCell[];
7
+ getExportBody(): ExportCell[][];
8
+ getPurchases(): this;
9
+ getSales(): this;
10
+ getShares(): this;
11
+ getCryptos(): this;
12
+ getOthers(): this;
13
+ /**
14
+ * @TODO vik remove, use holding.marketValue instead
15
+ */
16
+ get marketValue(): number;
17
+ /**
18
+ * @TODO vik remove, use holding.sharedMarketValue instead
19
+ */
20
+ get sharedMarketValue(): number;
21
+ }
@@ -1,17 +1,14 @@
1
- import { ExportableCollection } from '../exportable.collection';
1
+ import { Collection } from '../collection';
2
2
  import { Holding } from '../../models';
3
- import { ExportCell } from '../../models/export/export-cell';
4
- export declare class HoldingCollection extends ExportableCollection<Holding> {
5
- getExportHeader(): string[];
6
- getExportFooter(): ExportCell[];
7
- getExportBody(): ExportCell[][];
3
+ import { HoldingTradeCollection } from './holding-trade.collection';
4
+ import { HoldingTypeCollection } from './holding-type.collection';
5
+ export declare class HoldingCollection extends Collection<Holding> {
6
+ static fromTrades(trades: HoldingTradeCollection, holdingTypes: HoldingTypeCollection): HoldingCollection;
8
7
  getShares(): this;
9
8
  getCryptos(): this;
10
9
  getOthers(): this;
11
- getPurchaseValue(): number;
12
10
  get marketValue(): number;
13
- get sharedMarketValue(): number;
11
+ get purchaseValue(): number;
14
12
  getGrowthCoefficient(): number;
15
- getUnsold(): this;
16
- getUnrealisedProfit(): number;
13
+ getPnl(): number;
17
14
  }
@@ -1,3 +1,4 @@
1
- export * from './holding.collection';
1
+ export * from './holding-trade.collection';
2
2
  export * from './holding-sale.collection';
3
3
  export * from './holding-type.collection';
4
+ export * from './holding.collection';
@@ -0,0 +1,4 @@
1
+ export declare enum HoldingTradeTypeEnum {
2
+ BUY = 1,
3
+ SELL = 2
4
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './holding-type-category.enum';
2
2
  export * from './holding-type-exchange-list.enum';
3
+ export * from './holding-trade-type.enum';
@@ -1,4 +1,4 @@
1
- import { Holding } from './holding';
1
+ import { HoldingTrade } from './holding-trade';
2
2
  import { File } from '../file';
3
3
  export declare class HoldingSale {
4
4
  date?: Date;
@@ -10,6 +10,6 @@ export declare class HoldingSale {
10
10
  grossCapitalGain?: number;
11
11
  netCapitalGain?: number;
12
12
  id?: number;
13
- holding?: Holding;
13
+ holding?: HoldingTrade;
14
14
  file?: File;
15
15
  }
@@ -0,0 +1,8 @@
1
+ import { HoldingTrade } from './holding-trade';
2
+ export declare class HoldingTradeImport {
3
+ originalName?: string;
4
+ id?: number;
5
+ createdAt?: Date;
6
+ updatedAt?: Date;
7
+ holdings?: HoldingTrade[];
8
+ }
@@ -2,7 +2,7 @@ import { User } from '../user/user';
2
2
  import { HoldingType } from './holding-type';
3
3
  import { File } from '../file';
4
4
  import { HoldingSale } from './holding-sale';
5
- export declare class Holding {
5
+ export declare class HoldingTrade {
6
6
  isTaxFree?: boolean;
7
7
  date?: Date;
8
8
  quantity?: number;
@@ -1,4 +1,4 @@
1
- export * from './holding';
1
+ export * from './holding-trade';
2
2
  export * from './holding-type';
3
3
  export * from './holding-sale';
4
4
  export * from './holding-type-exchange';
@@ -1,5 +1,6 @@
1
1
  import { AbstractControl, AbstractControlOptions, AsyncValidatorFn, FormGroup, ValidatorFn } from '@angular/forms';
2
2
  import { EventEmitter, Type } from '@angular/core';
3
+ import { Observable } from 'rxjs';
3
4
  /**
4
5
  * Default Controls Interface with loose typing
5
6
  */
@@ -32,7 +33,7 @@ export declare abstract class AbstractForm<Model, Controls extends ControlsInter
32
33
  protected constructor(controls: Controls, model?: Model, validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null);
33
34
  get saved(): boolean;
34
35
  get currentValue(): Model;
35
- toggleEnabledState(control: AbstractControl): void;
36
+ toggleEnabledState(control?: AbstractControl): void;
36
37
  /**
37
38
  * Check validation and return a new instance of generic model.
38
39
  * Merge form value to initial object
@@ -70,4 +71,5 @@ export declare abstract class AbstractForm<Model, Controls extends ControlsInter
70
71
  onlySelf?: boolean;
71
72
  emitEvent?: boolean;
72
73
  }, controls?: AbstractControl[]): void;
74
+ controlsChanges(controlNames: string[]): Observable<any>;
73
75
  }
@@ -1,5 +1,5 @@
1
1
  import { UntypedFormArray } from '@angular/forms';
2
- import { BankAccountProperty } from '../../../models/bank/bank-account-property';
2
+ import { BankAccountProperty } from '../../../models';
3
3
  /**
4
4
  * Form array with bank account properties
5
5
  * @TODO create AbstractFormArray
@@ -9,21 +9,21 @@ export declare class HoldingReinvestForm extends AbstractForm<HoldingReinvest> i
9
9
  constructor(reinvest: HoldingReinvest);
10
10
  listenEvents(): void;
11
11
  private get transactionForm();
12
- private get holdingForm();
12
+ private get tradeForm();
13
13
  /**
14
14
  * calculated automatically as cashVariance=transactionAmount-frankedAmount-unfrankedAmount
15
15
  */
16
16
  private listenAmountChanges;
17
17
  /**
18
- * Set transaction amount based on holding quantity and price
18
+ * Set transaction amount based on trade quantity and price
19
19
  */
20
- private listenHoldingChanges;
20
+ private listenTradeChanges;
21
21
  /**
22
- * Set holding date the same as transaction date
22
+ * Set trade date the same as transaction date
23
23
  */
24
24
  private listenDateChanges;
25
25
  /**
26
- * @TODO Alex (TT-2847): attach file to both (transaction and holding) when files system refactored
26
+ * @TODO Alex (TT-2847): attach file to both (transaction and trade) when files system refactored
27
27
  */
28
28
  submit(): HoldingReinvest;
29
29
  }
@@ -1,10 +1,10 @@
1
1
  import { IEventListener } from '../../interfaces';
2
- import { Holding, HoldingSale, HoldingType } from '../../models';
2
+ import { HoldingSale, HoldingTrade, HoldingType } from '../../models';
3
3
  import { AbstractForm } from '../abstract.form';
4
4
  export declare class HoldingSaleForm extends AbstractForm<HoldingSale> implements IEventListener {
5
5
  private holding;
6
6
  private isResident;
7
- constructor(sale: HoldingSale, holding: Holding, type: HoldingType, isResident: boolean);
7
+ constructor(sale: HoldingSale, holding: HoldingTrade, type: HoldingType, isResident: boolean);
8
8
  listenEvents(): void;
9
9
  submit(): HoldingSale;
10
10
  private updateGainFields;
@@ -0,0 +1,9 @@
1
+ import { HoldingTrade } from '../../../models';
2
+ import { AbstractForm } from '../../abstract.form';
3
+ import { HoldingTradeCollection } from '../../../collections';
4
+ import { HoldingTypeCategoryEnum } from '../../../db/Enums';
5
+ export declare class HoldingTradeFilterForm extends AbstractForm<HoldingTrade> {
6
+ categories: HoldingTypeCategoryEnum[];
7
+ constructor();
8
+ filter(trades: HoldingTradeCollection): HoldingTradeCollection;
9
+ }
@@ -0,0 +1,9 @@
1
+ import { HoldingTrade } from '../../../models';
2
+ import { AbstractForm } from '../../abstract.form';
3
+ import { IEventListener } from '../../../interfaces';
4
+ export declare class HoldingTradeForm extends AbstractForm<HoldingTrade> implements IEventListener {
5
+ purchaseValue: number;
6
+ constructor(holdingTrade: HoldingTrade);
7
+ listenEvents(): void;
8
+ submit(data?: object, includeDisabledFields?: boolean): HoldingTrade;
9
+ }
@@ -0,0 +1,2 @@
1
+ export * from './holding-trade.form';
2
+ export * from './holding-trade-filter.form';
@@ -0,0 +1,8 @@
1
+ import { AbstractForm } from '../abstract.form';
2
+ import { IEventListener } from '../../interfaces';
3
+ import { HoldingTradeImport } from '../../models';
4
+ export declare class HoldingTradeImportForm extends AbstractForm<HoldingTradeImport> implements IEventListener {
5
+ constructor();
6
+ listenEvents(): void;
7
+ submit(): HoldingTradeImport;
8
+ }
@@ -1,5 +1,5 @@
1
+ export * from './holding-trade';
1
2
  export * from './holding-sale.form';
2
3
  export * from './holding-type.form';
3
- export * from './holding.form';
4
4
  export * from './holding-reinvest.form';
5
- export * from './holding-import.form';
5
+ export * from './holding-trade-import.form';
@@ -1,5 +1,5 @@
1
1
  import { Transaction } from '../transaction';
2
- import { Holding } from './holding';
2
+ import { HoldingTrade } from './holding-trade';
3
3
  import { AbstractModel } from '../../db/Models';
4
4
  import { HoldingType } from './holding-type';
5
5
  /**
@@ -8,6 +8,6 @@ import { HoldingType } from './holding-type';
8
8
  */
9
9
  export declare class HoldingReinvest extends AbstractModel {
10
10
  transaction: Transaction;
11
- holding: Holding;
11
+ trade: HoldingTrade;
12
12
  holdingType: HoldingType;
13
13
  }
@@ -1,23 +1,35 @@
1
- import { Holding } from './holding';
1
+ import { HoldingTrade } from './holding-trade';
2
2
  import { AppFile } from '../file';
3
3
  import { AssetSale } from '../asset-sale';
4
+ /**
5
+ * @TODO vik rename to HoldingTradeParcel when backend ready
6
+ */
4
7
  export declare class HoldingSale extends AssetSale {
5
8
  quantity: number;
6
9
  price: number;
7
10
  fee: number;
8
11
  total: number;
9
- holding?: Holding;
12
+ /**
13
+ * @TODO vik 4521 remove
14
+ */
15
+ holding?: HoldingTrade;
10
16
  file: AppFile;
11
17
  /**
12
18
  * netCapitalGain is different from grossCapitalGain only when 1 year rule applied
13
19
  */
14
20
  isOneYearExemptionApplicable(): boolean;
15
21
  get concession(): string;
16
- getCostBase(holding: Holding): number;
22
+ getCostBase(holding: HoldingTrade): number;
17
23
  /**
18
24
  * Purchase price of sold items
19
25
  */
20
- getPurchasePrice(holding: Holding): number;
26
+ getPurchasePrice(holding: HoldingTrade): number;
27
+ /**
28
+ * total price of sale
29
+ */
21
30
  get netCost(): number;
31
+ /**
32
+ * total price of sale without fee
33
+ */
22
34
  get cost(): number;
23
35
  }
@@ -0,0 +1,8 @@
1
+ import { HoldingTrade, ObservableModel } from '../../db/Models';
2
+ export declare class HoldingTradeImport extends ObservableModel {
3
+ static className: string;
4
+ originalName: string;
5
+ createdAt: Date;
6
+ updatedAt: Date;
7
+ holdings?: HoldingTrade[];
8
+ }
@@ -0,0 +1,41 @@
1
+ import { User } from '../user';
2
+ import { HoldingType } from './holding-type';
3
+ import { AppFile } from '../file';
4
+ import { AbstractModel } from '../../db/Models';
5
+ import { HoldingTradeTypeEnum, HoldingTypeCategoryEnum } from '../../db/Enums';
6
+ export declare class HoldingTrade extends AbstractModel {
7
+ isTaxFree: boolean;
8
+ quantity: number;
9
+ ownershipPercent?: number;
10
+ price: number;
11
+ fee: number;
12
+ type: HoldingTradeTypeEnum;
13
+ date: Date;
14
+ user: User;
15
+ /**
16
+ * @TODO vik 4521 rename to holding
17
+ */
18
+ holdingType: HoldingType;
19
+ file: AppFile;
20
+ /**
21
+ * @TODO Artem/Alex looks bad, come up with a better solution
22
+ * get current category, in holding we are interested in 3 main categories: stock/crypto/other
23
+ */
24
+ category: HoldingTypeCategoryEnum;
25
+ isPurchase(): boolean;
26
+ get typeLabel(): string;
27
+ /**
28
+ * Get total purchasing price
29
+ */
30
+ get total(): number;
31
+ /**
32
+ * @TODO vik remove
33
+ */
34
+ get marketValue(): number;
35
+ /**
36
+ * Get percent difference between current and buy price
37
+ * @TODO vik/alex no need to pass holdingType, should come from backend
38
+ */
39
+ get growthCoefficient(): number;
40
+ heldMoreYear(): boolean;
41
+ }
@@ -1,5 +1,8 @@
1
1
  import { AbstractModel } from '../../db/Models';
2
2
  import { HoldingType } from './holding-type';
3
+ /**
4
+ * @TODO rename 4521 to HoldingExchange when backend ready
5
+ */
3
6
  export declare class HoldingTypeExchange extends AbstractModel {
4
7
  code?: string;
5
8
  name?: string;
@@ -3,6 +3,9 @@ import { User } from '../user';
3
3
  import { AbstractModel } from '../../db/Models';
4
4
  import { HoldingTypeExchange } from './holding-type-exchange';
5
5
  import { AppFile } from '../file';
6
+ /**
7
+ * @TODO vik 4521 rename to Holding when backend ready
8
+ */
6
9
  export declare class HoldingType extends AbstractModel {
7
10
  category?: HoldingTypeCategoryEnum;
8
11
  name?: string;
@@ -1,40 +1,24 @@
1
- import { User } from '../user';
2
- import { HoldingType } from './holding-type';
3
- import { AppFile } from '../file';
4
- import { HoldingSale } from './holding-sale';
5
- import { Collection } from '../../collections';
6
1
  import { AbstractModel } from '../../db/Models';
7
- import { HoldingTypeCategoryEnum } from '../../db/Enums';
2
+ import { HoldingTradeCollection } from '../../collections';
3
+ import { HoldingType } from './holding-type';
8
4
  export declare class Holding extends AbstractModel {
9
- isTaxFree: boolean;
10
- quantity: number;
11
- currentQuantity: number;
12
- ownershipPercent?: number;
13
- price: number;
14
- fee: number;
15
- date: Date;
16
- user: User;
5
+ private trades;
17
6
  type: HoldingType;
18
- file: AppFile;
19
- sales: Collection<HoldingSale>;
20
- /**
21
- * @TODO Artem/Alex looks bad, come up with a better solution
22
- * get current category, in holding we are interested in 3 main categories: stock/crypto/other
23
- */
24
- category: HoldingTypeCategoryEnum;
25
- /**
26
- * Get total purchasing price
27
- */
28
- get purchaseValue(): number;
29
- /**
30
- * Get current market price
31
- */
32
- get marketValue(): number;
7
+ quantity: number;
8
+ avgPrice: number;
9
+ purchaseValue: number;
10
+ marketValue: number;
11
+ pnl: number;
12
+ constructor(trades: HoldingTradeCollection, type: HoldingType);
13
+ getQuantity(): number;
14
+ getPurchaseValue(): number;
15
+ getMarketValue(): number;
16
+ getAvgPrice(): number;
33
17
  /**
34
- * Get percent difference between current and buy price
35
- * @TODO vik/alex no need to pass holdingType, should come from backend
18
+ * profit and loss
36
19
  */
37
- get growthCoefficient(): number;
38
- heldMoreYear(): boolean;
39
- isSold(): boolean;
20
+ getPnl(): number;
21
+ getSharedMarketValue(): number;
22
+ getGrowthCoefficient(): number;
23
+ getUnrealisedProfit(): number;
40
24
  }
@@ -1,6 +1,7 @@
1
- export * from './holding';
1
+ export * from './holding-trade';
2
2
  export * from './holding-type';
3
3
  export * from './holding-sale';
4
4
  export * from './holding-type-exchange';
5
5
  export * from './holding-reinvest';
6
- export * from './holding-import';
6
+ export * from './holding-trade-import';
7
+ export * from './holding';
@@ -1,4 +1,4 @@
1
- import { BankAccountService, ClientInviteService, ClientMovementService, EmployeeInviteService, EmployeeService, FirmService, HoldingService, IncomeSourceService, PropertyService, SoleBusinessService, TransactionAllocationService, TransactionService, UserService, VehicleClaimService } from '../http';
1
+ import { BankAccountService, ClientInviteService, ClientMovementService, EmployeeInviteService, EmployeeService, FirmService, HoldingTradeService, IncomeSourceService, PropertyService, SoleBusinessService, TransactionAllocationService, TransactionService, UserService, VehicleClaimService } from '../http';
2
2
  import { User } from '../../models';
3
3
  import { AccountSetupItemCollection } from '../../collections';
4
4
  import { Observable } from 'rxjs';
@@ -27,7 +27,7 @@ export declare class AccountSetupService {
27
27
  private firmService;
28
28
  items: AccountSetupItemCollection;
29
29
  user: User;
30
- constructor(setupItemService: SetupItemService, propertyService: PropertyService, incomeSourceService: IncomeSourceService, bankAccountsService: BankAccountService, transactionAllocationService: TransactionAllocationService, vehicleClaimService: VehicleClaimService, transactionService: TransactionService, soleBusinessService: SoleBusinessService, holdingService: HoldingService, userService: UserService, clientMovementService: ClientMovementService, clientInviteService: ClientInviteService, employeeService: EmployeeService, employeeInviteService: EmployeeInviteService, firmService: FirmService);
30
+ constructor(setupItemService: SetupItemService, propertyService: PropertyService, incomeSourceService: IncomeSourceService, bankAccountsService: BankAccountService, transactionAllocationService: TransactionAllocationService, vehicleClaimService: VehicleClaimService, transactionService: TransactionService, soleBusinessService: SoleBusinessService, holdingService: HoldingTradeService, userService: UserService, clientMovementService: ClientMovementService, clientInviteService: ClientInviteService, employeeService: EmployeeService, employeeInviteService: EmployeeInviteService, firmService: FirmService);
31
31
  /**
32
32
  * Get list of account setup items for current user/firm
33
33
  */
@@ -1,4 +1,4 @@
1
- export declare enum HoldingImportMessagesEnum {
1
+ export declare enum HoldingTradeImportMessagesEnum {
2
2
  CREATED = "Import created successfully",
3
3
  UPDATED = "Import updated successfully",
4
4
  CONFIRM_DELETE = "Are you sure you want to delete this import?",
@@ -0,0 +1,17 @@
1
+ import { RestMethod, RestService } from '../../rest';
2
+ import { Collection } from '../../../../collections';
3
+ import { UserRolesEnum } from 'taxtank-core/common';
4
+ import { HoldingTradeImport as HoldingTradeImportBase } from '../../../../db/Models/holding/holding-trade-import';
5
+ import { HoldingTradeImport } from '../../../../models';
6
+ import { Observable } from 'rxjs';
7
+ import * as i0 from "@angular/core";
8
+ export declare class HoldingTradeImportService extends RestService<HoldingTradeImportBase, HoldingTradeImport, Collection<HoldingTradeImport>> {
9
+ modelClass: typeof HoldingTradeImport;
10
+ collectionClass: typeof Collection<HoldingTradeImport>;
11
+ endpointUri: string;
12
+ disabledMethods: RestMethod[];
13
+ roles: UserRolesEnum[];
14
+ import(file: File, exchangeId: number, isTaxFree: boolean): Observable<HoldingTradeImport>;
15
+ static ɵfac: i0.ɵɵFactoryDeclaration<HoldingTradeImportService, never>;
16
+ static ɵprov: i0.ɵɵInjectableDeclaration<HoldingTradeImportService>;
17
+ }
@@ -1,4 +1,4 @@
1
- export declare enum HoldingMessagesEnum {
1
+ export declare enum HoldingTradeMessagesEnum {
2
2
  CREATED = "Holding created successfully",
3
3
  UPDATED = "Holding updated successfully",
4
4
  CONFIRM_DELETE = "Are you sure you want to delete this holding?",
@@ -0,0 +1,20 @@
1
+ import { HoldingTrade as HoldingBase } from '../../../db/Models';
2
+ import { HoldingTrade } from '../../../models';
3
+ import { RestMethod, RestService } from '../rest';
4
+ import { HoldingTradeCollection } from '../../../collections';
5
+ import { IEventListener } from '../../../interfaces';
6
+ import { UserRolesEnum } from 'taxtank-core/common';
7
+ import * as i0 from "@angular/core";
8
+ export declare class HoldingTradeService extends RestService<HoldingBase, HoldingTrade, HoldingTradeCollection> implements IEventListener {
9
+ protected environment: any;
10
+ modelClass: typeof HoldingTrade;
11
+ collectionClass: typeof HoldingTradeCollection;
12
+ endpointUri: string;
13
+ disabledMethods: RestMethod[];
14
+ roles: UserRolesEnum[];
15
+ constructor(environment: any);
16
+ listenEvents(): void;
17
+ private listenNotifications;
18
+ static ɵfac: i0.ɵɵFactoryDeclaration<HoldingTradeService, never>;
19
+ static ɵprov: i0.ɵɵInjectableDeclaration<HoldingTradeService>;
20
+ }
@@ -1,9 +1,8 @@
1
- export * from './holding.service';
1
+ export * from './holding-trade.service';
2
2
  export * from './holding-type.service';
3
3
  export * from './holding-sale.service';
4
- export * from './holding-import/holding-import.service';
5
- export * from './holding-import/holding-import-messages.enum';
4
+ export * from './holding-trade-import/holding-trade-import.service';
5
+ export * from './holding-trade-import/holding-trade-import-messages.enum';
6
6
  export * from '../../json/holding/holding-type-exchange.service';
7
- export * from './holding-messages.enum';
8
- export * from './holding-sale-messages.enum';
7
+ export * from './holding-trade-messages.enum';
9
8
  export * from './holding-type-messages.enum';
@@ -49,10 +49,6 @@ export declare abstract class RestService<BaseModel, Model extends AbstractModel
49
49
  * @TODO: TT-4642 check customHttpErrorMessages fix change to backend errors
50
50
  */
51
51
  protected useBackendError: boolean;
52
- /**
53
- * messages that can be redefined in other classes to customize httpErrorMessages
54
- */
55
- protected customHttpErrorMessages: {};
56
52
  /**
57
53
  * mapping with HTTP errors codes and general messages
58
54
  */
@@ -104,6 +100,10 @@ export declare abstract class RestService<BaseModel, Model extends AbstractModel
104
100
  * Remove multiple Model instances from database
105
101
  */
106
102
  deleteBatch(models: Model[]): Observable<void>;
103
+ /**
104
+ * method with messages that can be redefined in other classes to customize httpErrorMessages
105
+ */
106
+ protected getCustomHttpErrorMessages(): Record<number, string>;
107
107
  /**
108
108
  * Handle response errors - shows error in toast
109
109
  * and throws error further
@@ -7,9 +7,7 @@ export declare class AllocationRuleService extends RestService<AllocationRuleBas
7
7
  protected endpointUri: string;
8
8
  collectionClass: typeof AllocationRuleCollection;
9
9
  modelClass: typeof AllocationRule;
10
- customHttpErrorMessages: {
11
- 422: string;
12
- };
10
+ protected getCustomHttpErrorMessages(): Record<number, string>;
13
11
  static ɵfac: i0.ɵɵFactoryDeclaration<AllocationRuleService, never>;
14
12
  static ɵprov: i0.ɵɵInjectableDeclaration<AllocationRuleService>;
15
13
  }
@@ -1,3 +0,0 @@
1
- export class HoldingImport {
2
- }
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaG9sZGluZy1pbXBvcnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy90dC1jb3JlL3NyYy9saWIvZGIvTW9kZWxzL2hvbGRpbmcvaG9sZGluZy1pbXBvcnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsTUFBTSxPQUFPLGFBQWE7Q0FNekIiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBIb2xkaW5nIH0gZnJvbSAnLi9ob2xkaW5nJztcblxuZXhwb3J0IGNsYXNzIEhvbGRpbmdJbXBvcnQge1xuICBvcmlnaW5hbE5hbWU/OiBzdHJpbmc7XG4gIGlkPzogbnVtYmVyO1xuICBjcmVhdGVkQXQ/OiBEYXRlO1xuICB1cGRhdGVkQXQ/OiBEYXRlO1xuICBob2xkaW5ncz86IEhvbGRpbmdbXTtcbn1cbiJdfQ==
@@ -1,3 +0,0 @@
1
- export class Holding {
2
- }
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaG9sZGluZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL3R0LWNvcmUvc3JjL2xpYi9kYi9Nb2RlbHMvaG9sZGluZy9ob2xkaW5nLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBLE1BQU0sT0FBTyxPQUFPO0NBWW5CIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHtVc2VyfSBmcm9tICcuLi91c2VyL3VzZXInO1xuaW1wb3J0IHtIb2xkaW5nVHlwZX0gZnJvbSAnLi9ob2xkaW5nLXR5cGUnO1xuaW1wb3J0IHtGaWxlfSBmcm9tICcuLi9maWxlJztcbmltcG9ydCB7SG9sZGluZ1NhbGV9IGZyb20gJy4vaG9sZGluZy1zYWxlJztcblxuZXhwb3J0IGNsYXNzIEhvbGRpbmcge1xuICBpc1RheEZyZWU/OiBib29sZWFuO1xuICBkYXRlPzogRGF0ZTtcbiAgcXVhbnRpdHk/OiBudW1iZXI7XG4gIHByaWNlPzogbnVtYmVyO1xuICBmZWU/OiBudW1iZXI7XG4gIG93bmVyc2hpcFBlcmNlbnQ/OiBudW1iZXI7XG4gIGlkPzogbnVtYmVyO1xuICB1c2VyPzogVXNlcjtcbiAgdHlwZT86IEhvbGRpbmdUeXBlO1xuICBmaWxlPzogRmlsZTtcbiAgc2FsZXM/OiBIb2xkaW5nU2FsZVtdO1xufVxuIl19