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.
@@ -1948,8 +1948,8 @@ var ChartAccountsCategoryEnum;
1948
1948
  ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["SOLE_INCOME"] = 12] = "SOLE_INCOME";
1949
1949
  ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["SOLE_EXPENSE"] = 13] = "SOLE_EXPENSE";
1950
1950
  ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["SOLE_DEPRECIATION"] = 14] = "SOLE_DEPRECIATION";
1951
- ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["HOLDING_EXPENSE"] = 15] = "HOLDING_EXPENSE";
1952
- ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["HOLDING_INCOME"] = 16] = "HOLDING_INCOME";
1951
+ ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["HOLDING_INCOME"] = 15] = "HOLDING_INCOME";
1952
+ ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["HOLDING_EXPENSE"] = 16] = "HOLDING_EXPENSE";
1953
1953
  })(ChartAccountsCategoryEnum || (ChartAccountsCategoryEnum = {}));
1954
1954
 
1955
1955
  var ChartAccountsEtpEnum;
@@ -7037,7 +7037,7 @@ class UserEventTypeCollection extends Collection {
7037
7037
 
7038
7038
  class HoldingCollection extends ExportableCollection {
7039
7039
  getExportHeader() {
7040
- return ['Date', 'Ticker', 'Asset type', 'Qty bought', 'Qty current', 'Buy price/Unit', 'Current price/Unit', 'Total MV', 'Profit/Loss'];
7040
+ return ['Date', 'Ticker', 'Name', 'Asset type', 'Qty bought', 'Qty current', 'Buy price/Unit', 'Current price/Unit', 'Total MV', 'Profit/Loss'];
7041
7041
  }
7042
7042
  getExportFooter() {
7043
7043
  return [
@@ -7048,6 +7048,10 @@ class HoldingCollection extends ExportableCollection {
7048
7048
  return this.items.map((holding) => {
7049
7049
  return [
7050
7050
  plainToClass(ExportCell, { value: holding.date, type: ExportCellTypeEnum.DATE }),
7051
+ plainToClass(ExportCell, {
7052
+ value: this.holdingTypesById.get(holding.type.id).ticker,
7053
+ type: ExportCellTypeEnum.STRING
7054
+ }),
7051
7055
  plainToClass(ExportCell, {
7052
7056
  value: this.holdingTypesById.get(holding.type.id).name,
7053
7057
  type: ExportCellTypeEnum.STRING
@@ -7099,7 +7103,7 @@ class HoldingCollection extends ExportableCollection {
7099
7103
  }
7100
7104
  }
7101
7105
 
7102
- class HoldingSaleCollection extends Collection {
7106
+ class HoldingSaleCollection extends ExportableCollection {
7103
7107
  /**
7104
7108
  * @TODO vik remove?
7105
7109
  */
@@ -7116,6 +7120,35 @@ class HoldingSaleCollection extends Collection {
7116
7120
  get noExemptionGrossCapitalGain() {
7117
7121
  return this.filter((sale) => sale.netCapitalGain > 0 && sale.netCapitalGain === sale.grossCapitalGain).grossCapitalGain;
7118
7122
  }
7123
+ getExportHeader() {
7124
+ return ['Ticker', 'Asset type', 'Date of buy', 'Date of sale', 'My Capital Gain/(Loss)', 'Exempt or Concession'];
7125
+ }
7126
+ getExportFooter() {
7127
+ return [
7128
+ plainToClass(ExportCell, { value: '', type: ExportCellTypeEnum.STRING }),
7129
+ ];
7130
+ }
7131
+ getExportBody() {
7132
+ return this.items.map((sale) => {
7133
+ return [
7134
+ plainToClass(ExportCell, {
7135
+ value: this.holdingTypesById.get(this.holdingsById.get(sale.holding.id).type.id).ticker,
7136
+ type: ExportCellTypeEnum.STRING
7137
+ }),
7138
+ plainToClass(ExportCell, {
7139
+ value: this.holdingsById.get(sale.holding.id).type.categoryLabel,
7140
+ type: ExportCellTypeEnum.STRING
7141
+ }),
7142
+ plainToClass(ExportCell, { value: this.holdingsById.get(sale.holding.id)?.date, type: ExportCellTypeEnum.DATE }),
7143
+ plainToClass(ExportCell, { value: sale.date, type: ExportCellTypeEnum.DATE }),
7144
+ plainToClass(ExportCell, { value: sale.grossCapitalGain, type: ExportCellTypeEnum.CURRENCY }),
7145
+ plainToClass(ExportCell, {
7146
+ value: sale.isOneYearExemptionApplicable() ? '50% (1 year rule)' : 'None',
7147
+ type: ExportCellTypeEnum.STRING
7148
+ }),
7149
+ ];
7150
+ });
7151
+ }
7119
7152
  }
7120
7153
 
7121
7154
  class HoldingTypeCollection extends Collection {
@@ -16153,7 +16186,7 @@ const ACCOUNT_SETUP_ITEMS = {
16153
16186
  * Checks required steps and their completion
16154
16187
  */
16155
16188
  class AccountSetupService {
16156
- constructor(clientIncomeTypesService, propertyService, incomeSourceService, bankAccountsService, transactionAllocationService, vehicleClaimService, transactionService, soleBusinessService, holdingService) {
16189
+ constructor(clientIncomeTypesService, propertyService, incomeSourceService, bankAccountsService, transactionAllocationService, vehicleClaimService, transactionService, soleBusinessService, holdingService, userService) {
16157
16190
  this.clientIncomeTypesService = clientIncomeTypesService;
16158
16191
  this.propertyService = propertyService;
16159
16192
  this.incomeSourceService = incomeSourceService;
@@ -16163,6 +16196,7 @@ class AccountSetupService {
16163
16196
  this.transactionService = transactionService;
16164
16197
  this.soleBusinessService = soleBusinessService;
16165
16198
  this.holdingService = holdingService;
16199
+ this.userService = userService;
16166
16200
  this.cacheSubject = new ReplaySubject(1);
16167
16201
  }
16168
16202
  /**
@@ -16215,25 +16249,26 @@ class AccountSetupService {
16215
16249
  */
16216
16250
  createBatch(incomeTypes) {
16217
16251
  const batch = [];
16252
+ const user = this.userService.getCache();
16218
16253
  // Salary item is completed when user added salary income source
16219
- if (incomeTypes.work) {
16254
+ if (incomeTypes.work && user.hasRoles(UserRolesEnum.WORK_TANK)) {
16220
16255
  batch.push(this.create(AccountSetupItemsEnum.SALARY, this.getIncomeSources(true)),
16221
16256
  // Other income is a part of work tank, completed when user added at least one other income source
16222
16257
  this.create(AccountSetupItemsEnum.OTHER_INCOME, this.getIncomeSources()));
16223
16258
  }
16224
16259
  // Rental income item is completed when user added at least one property
16225
- if (incomeTypes.property) {
16260
+ if (incomeTypes.property && user.hasRoles(UserRolesEnum.PROPERTY_TANK)) {
16226
16261
  batch.push(this.create(AccountSetupItemsEnum.PROPERTY, this.propertyService.getArray()));
16227
16262
  }
16228
16263
  // Sole business item is completed when user added at least one business
16229
- if (incomeTypes.sole) {
16264
+ if (incomeTypes.sole && user.hasRoles(UserRolesEnum.SOLE_TANK)) {
16230
16265
  batch.push(this.create(AccountSetupItemsEnum.SOLE_BUSINESS, this.soleBusinessService.get()));
16231
16266
  }
16232
16267
  // holdings item is completed when user added at least one holding
16233
- if (incomeTypes.holdings) {
16268
+ if (incomeTypes.holdings && user.hasRoles(UserRolesEnum.HOLDING_TANK)) {
16234
16269
  batch.push(this.create(AccountSetupItemsEnum.HOLDINGS, this.holdingService.getArray()));
16235
16270
  }
16236
- if (incomeTypes.sole || incomeTypes.property || incomeTypes.work) {
16271
+ if (incomeTypes.sole || incomeTypes.property || incomeTypes.work || incomeTypes.holdings) {
16237
16272
  // Bank feeds item is completed when user added at least one bank account (basiq or manual)
16238
16273
  batch.push(this.create(AccountSetupItemsEnum.BANK_FEEDS, this.bankAccountsService.getArray()));
16239
16274
  // Logbook item is completed when user has at least one vehicle claim with any method (kms or logbook)
@@ -16271,14 +16306,14 @@ class AccountSetupService {
16271
16306
  }));
16272
16307
  }
16273
16308
  }
16274
- 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 });
16309
+ 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 });
16275
16310
  AccountSetupService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AccountSetupService, providedIn: 'root' });
16276
16311
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: AccountSetupService, decorators: [{
16277
16312
  type: Injectable,
16278
16313
  args: [{
16279
16314
  providedIn: 'root'
16280
16315
  }]
16281
- }], ctorParameters: function () { return [{ type: ClientIncomeTypesService }, { type: PropertyService }, { type: IncomeSourceService }, { type: BankAccountService }, { type: TransactionAllocationService }, { type: VehicleClaimService }, { type: TransactionService }, { type: SoleBusinessService }, { type: HoldingService }]; } });
16316
+ }], ctorParameters: function () { return [{ type: ClientIncomeTypesService }, { type: PropertyService }, { type: IncomeSourceService }, { type: BankAccountService }, { type: TransactionAllocationService }, { type: VehicleClaimService }, { type: TransactionService }, { type: SoleBusinessService }, { type: HoldingService }, { type: UserService }]; } });
16282
16317
 
16283
16318
  /**
16284
16319
  * Service to work with Rewardful (affiliate program) API
@@ -17179,6 +17214,10 @@ class XlsxService {
17179
17214
  xlsx.utils.book_append_sheet(workbook, worksheet);
17180
17215
  return xlsx.write(workbook, { bookType: 'xlsx', type: 'array' });
17181
17216
  }
17217
+ /**
17218
+ * @TODO vik/artem work with ExportDataTable instead of ExportableCollection
17219
+ * @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
17220
+ */
17182
17221
  exportArrayToExcel(exportableCollection, name) {
17183
17222
  const workbook = xlsx.utils.book_new();
17184
17223
  // create empty worksheet
@@ -20192,7 +20231,8 @@ class HoldingSaleForm extends AbstractForm {
20192
20231
  this.get('netCapitalGain').setValue(this.calculateNetCapitalGain(totalCapitalGain, date));
20193
20232
  }
20194
20233
  calculateTotalCapitalGain(price, quantity, fee) {
20195
- return round((price - this.holding.price) * quantity - this.holding.fee - fee, 2);
20234
+ const fees = quantity * this.holding.fee / this.holding.quantity + fee;
20235
+ return round((price - this.holding.price) * quantity - fees, 2);
20196
20236
  }
20197
20237
  calculateNetCapitalGain(totalCapitalGain, date) {
20198
20238
  let netCapitalGain = (totalCapitalGain * this.holding.ownershipPercent) / 100;