taxtank-core 0.30.46 → 0.30.48

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.
@@ -1961,8 +1961,8 @@ var ChartAccountsCategoryEnum;
1961
1961
  ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["SOLE_INCOME"] = 12] = "SOLE_INCOME";
1962
1962
  ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["SOLE_EXPENSE"] = 13] = "SOLE_EXPENSE";
1963
1963
  ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["SOLE_DEPRECIATION"] = 14] = "SOLE_DEPRECIATION";
1964
- ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["HOLDING_EXPENSE"] = 15] = "HOLDING_EXPENSE";
1965
- ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["HOLDING_INCOME"] = 16] = "HOLDING_INCOME";
1964
+ ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["HOLDING_INCOME"] = 15] = "HOLDING_INCOME";
1965
+ ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["HOLDING_EXPENSE"] = 16] = "HOLDING_EXPENSE";
1966
1966
  })(ChartAccountsCategoryEnum || (ChartAccountsCategoryEnum = {}));
1967
1967
 
1968
1968
  var ChartAccountsEtpEnum;
@@ -7071,7 +7071,7 @@ class UserEventTypeCollection extends Collection {
7071
7071
 
7072
7072
  class HoldingCollection extends ExportableCollection {
7073
7073
  getExportHeader() {
7074
- return ['Date', 'Ticker', 'Asset type', 'Qty bought', 'Qty current', 'Buy price/Unit', 'Current price/Unit', 'Total MV', 'Profit/Loss'];
7074
+ return ['Date', 'Ticker', 'Name', 'Asset type', 'Qty bought', 'Qty current', 'Buy price/Unit', 'Current price/Unit', 'Total MV', 'Profit/Loss'];
7075
7075
  }
7076
7076
  getExportFooter() {
7077
7077
  return [
@@ -7082,6 +7082,10 @@ class HoldingCollection extends ExportableCollection {
7082
7082
  return this.items.map((holding) => {
7083
7083
  return [
7084
7084
  plainToClass(ExportCell, { value: holding.date, type: ExportCellTypeEnum.DATE }),
7085
+ plainToClass(ExportCell, {
7086
+ value: this.holdingTypesById.get(holding.type.id).ticker,
7087
+ type: ExportCellTypeEnum.STRING
7088
+ }),
7085
7089
  plainToClass(ExportCell, {
7086
7090
  value: this.holdingTypesById.get(holding.type.id).name,
7087
7091
  type: ExportCellTypeEnum.STRING
@@ -7133,7 +7137,7 @@ class HoldingCollection extends ExportableCollection {
7133
7137
  }
7134
7138
  }
7135
7139
 
7136
- class HoldingSaleCollection extends Collection {
7140
+ class HoldingSaleCollection extends ExportableCollection {
7137
7141
  /**
7138
7142
  * @TODO vik remove?
7139
7143
  */
@@ -7150,6 +7154,36 @@ class HoldingSaleCollection extends Collection {
7150
7154
  get noExemptionGrossCapitalGain() {
7151
7155
  return this.filter((sale) => sale.netCapitalGain > 0 && sale.netCapitalGain === sale.grossCapitalGain).grossCapitalGain;
7152
7156
  }
7157
+ getExportHeader() {
7158
+ return ['Ticker', 'Asset type', 'Date of buy', 'Date of sale', 'My Capital Gain/(Loss)', 'Exempt or Concession'];
7159
+ }
7160
+ getExportFooter() {
7161
+ return [
7162
+ plainToClass(ExportCell, { value: '', type: ExportCellTypeEnum.STRING }),
7163
+ ];
7164
+ }
7165
+ getExportBody() {
7166
+ return this.items.map((sale) => {
7167
+ var _a;
7168
+ return [
7169
+ plainToClass(ExportCell, {
7170
+ value: this.holdingTypesById.get(this.holdingsById.get(sale.holding.id).type.id).ticker,
7171
+ type: ExportCellTypeEnum.STRING
7172
+ }),
7173
+ plainToClass(ExportCell, {
7174
+ value: this.holdingsById.get(sale.holding.id).type.categoryLabel,
7175
+ type: ExportCellTypeEnum.STRING
7176
+ }),
7177
+ plainToClass(ExportCell, { value: (_a = this.holdingsById.get(sale.holding.id)) === null || _a === void 0 ? void 0 : _a.date, type: ExportCellTypeEnum.DATE }),
7178
+ plainToClass(ExportCell, { value: sale.date, type: ExportCellTypeEnum.DATE }),
7179
+ plainToClass(ExportCell, { value: sale.grossCapitalGain, type: ExportCellTypeEnum.CURRENCY }),
7180
+ plainToClass(ExportCell, {
7181
+ value: sale.isOneYearExemptionApplicable() ? '50% (1 year rule)' : 'None',
7182
+ type: ExportCellTypeEnum.STRING
7183
+ }),
7184
+ ];
7185
+ });
7186
+ }
7153
7187
  }
7154
7188
 
7155
7189
  class HoldingTypeCollection extends Collection {
@@ -16272,7 +16306,7 @@ const ACCOUNT_SETUP_ITEMS = {
16272
16306
  * Checks required steps and their completion
16273
16307
  */
16274
16308
  class AccountSetupService {
16275
- constructor(clientIncomeTypesService, propertyService, incomeSourceService, bankAccountsService, transactionAllocationService, vehicleClaimService, transactionService, soleBusinessService, holdingService) {
16309
+ constructor(clientIncomeTypesService, propertyService, incomeSourceService, bankAccountsService, transactionAllocationService, vehicleClaimService, transactionService, soleBusinessService, holdingService, userService) {
16276
16310
  this.clientIncomeTypesService = clientIncomeTypesService;
16277
16311
  this.propertyService = propertyService;
16278
16312
  this.incomeSourceService = incomeSourceService;
@@ -16282,6 +16316,7 @@ class AccountSetupService {
16282
16316
  this.transactionService = transactionService;
16283
16317
  this.soleBusinessService = soleBusinessService;
16284
16318
  this.holdingService = holdingService;
16319
+ this.userService = userService;
16285
16320
  this.cacheSubject = new ReplaySubject(1);
16286
16321
  }
16287
16322
  /**
@@ -16334,25 +16369,26 @@ class AccountSetupService {
16334
16369
  */
16335
16370
  createBatch(incomeTypes) {
16336
16371
  const batch = [];
16372
+ const user = this.userService.getCache();
16337
16373
  // Salary item is completed when user added salary income source
16338
- if (incomeTypes.work) {
16374
+ if (incomeTypes.work && user.hasRoles(UserRolesEnum.WORK_TANK)) {
16339
16375
  batch.push(this.create(AccountSetupItemsEnum.SALARY, this.getIncomeSources(true)),
16340
16376
  // Other income is a part of work tank, completed when user added at least one other income source
16341
16377
  this.create(AccountSetupItemsEnum.OTHER_INCOME, this.getIncomeSources()));
16342
16378
  }
16343
16379
  // Rental income item is completed when user added at least one property
16344
- if (incomeTypes.property) {
16380
+ if (incomeTypes.property && user.hasRoles(UserRolesEnum.PROPERTY_TANK)) {
16345
16381
  batch.push(this.create(AccountSetupItemsEnum.PROPERTY, this.propertyService.getArray()));
16346
16382
  }
16347
16383
  // Sole business item is completed when user added at least one business
16348
- if (incomeTypes.sole) {
16384
+ if (incomeTypes.sole && user.hasRoles(UserRolesEnum.SOLE_TANK)) {
16349
16385
  batch.push(this.create(AccountSetupItemsEnum.SOLE_BUSINESS, this.soleBusinessService.get()));
16350
16386
  }
16351
16387
  // holdings item is completed when user added at least one holding
16352
- if (incomeTypes.holdings) {
16388
+ if (incomeTypes.holdings && user.hasRoles(UserRolesEnum.HOLDING_TANK)) {
16353
16389
  batch.push(this.create(AccountSetupItemsEnum.HOLDINGS, this.holdingService.getArray()));
16354
16390
  }
16355
- if (incomeTypes.sole || incomeTypes.property || incomeTypes.work) {
16391
+ if (incomeTypes.sole || incomeTypes.property || incomeTypes.work || incomeTypes.holdings) {
16356
16392
  // Bank feeds item is completed when user added at least one bank account (basiq or manual)
16357
16393
  batch.push(this.create(AccountSetupItemsEnum.BANK_FEEDS, this.bankAccountsService.getArray()));
16358
16394
  // Logbook item is completed when user has at least one vehicle claim with any method (kms or logbook)
@@ -16390,14 +16426,14 @@ class AccountSetupService {
16390
16426
  }));
16391
16427
  }
16392
16428
  }
16393
- AccountSetupService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AccountSetupService, deps: [{ token: ClientIncomeTypesService }, { token: PropertyService }, { token: IncomeSourceService }, { token: BankAccountService }, { token: TransactionAllocationService }, { token: VehicleClaimService }, { token: TransactionService }, { token: SoleBusinessService }, { token: HoldingService }], target: i0.ɵɵFactoryTarget.Injectable });
16429
+ AccountSetupService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AccountSetupService, deps: [{ token: ClientIncomeTypesService }, { token: PropertyService }, { token: IncomeSourceService }, { token: BankAccountService }, { token: TransactionAllocationService }, { token: VehicleClaimService }, { token: TransactionService }, { token: SoleBusinessService }, { token: HoldingService }, { token: UserService }], target: i0.ɵɵFactoryTarget.Injectable });
16394
16430
  AccountSetupService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AccountSetupService, providedIn: 'root' });
16395
16431
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AccountSetupService, decorators: [{
16396
16432
  type: Injectable,
16397
16433
  args: [{
16398
16434
  providedIn: 'root'
16399
16435
  }]
16400
- }], ctorParameters: function () { return [{ type: ClientIncomeTypesService }, { type: PropertyService }, { type: IncomeSourceService }, { type: BankAccountService }, { type: TransactionAllocationService }, { type: VehicleClaimService }, { type: TransactionService }, { type: SoleBusinessService }, { type: HoldingService }]; } });
16436
+ }], ctorParameters: function () { return [{ type: ClientIncomeTypesService }, { type: PropertyService }, { type: IncomeSourceService }, { type: BankAccountService }, { type: TransactionAllocationService }, { type: VehicleClaimService }, { type: TransactionService }, { type: SoleBusinessService }, { type: HoldingService }, { type: UserService }]; } });
16401
16437
 
16402
16438
  /**
16403
16439
  * Service to work with Rewardful (affiliate program) API
@@ -17299,6 +17335,10 @@ class XlsxService {
17299
17335
  xlsx.utils.book_append_sheet(workbook, worksheet);
17300
17336
  return xlsx.write(workbook, { bookType: 'xlsx', type: 'array' });
17301
17337
  }
17338
+ /**
17339
+ * @TODO vik/artem work with ExportDataTable instead of ExportableCollection
17340
+ * @TODO vik/artem why so much code? here is 6 rows solution https://stackoverflow.com/questions/64939994/how-to-export-array-of-objects-to-an-excel-in-angular-8
17341
+ */
17302
17342
  exportArrayToExcel(exportableCollection, name) {
17303
17343
  const workbook = xlsx.utils.book_new();
17304
17344
  // create empty worksheet
@@ -20324,7 +20364,8 @@ class HoldingSaleForm extends AbstractForm {
20324
20364
  this.get('netCapitalGain').setValue(this.calculateNetCapitalGain(totalCapitalGain, date));
20325
20365
  }
20326
20366
  calculateTotalCapitalGain(price, quantity, fee) {
20327
- return round((price - this.holding.price) * quantity - this.holding.fee - fee, 2);
20367
+ const fees = quantity * this.holding.fee / this.holding.quantity + fee;
20368
+ return round((price - this.holding.price) * quantity - fees, 2);
20328
20369
  }
20329
20370
  calculateNetCapitalGain(totalCapitalGain, date) {
20330
20371
  let netCapitalGain = (totalCapitalGain * this.holding.ownershipPercent) / 100;