taxtank-core 0.28.50 → 0.28.52

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.
@@ -699,6 +699,7 @@ const ENDPOINTS = {
699
699
  SOLE_BUSINESS_LOSSES_POST: new Endpoint('POST', '\\/sole-business-losses'),
700
700
  SOLE_BUSINESS_LOSSES_PUT: new Endpoint('PUT', '\\/sole-business-losses\\/\\d+'),
701
701
  SOLE_BUSINESS_LOSS_OFFSET_RULES_GET: new Endpoint('GET', '\\/sole-business-loss-offset-rules'),
702
+ SOLE_BUSINESS_LOGO_POST: new Endpoint('POST', '\\/sole-businesses\\/\\d+\\/logo'),
702
703
  SOLE_CONTACTS_POST: new Endpoint('POST', '\\/sole-contacts'),
703
704
  SOLE_CONTACTS_PUT: new Endpoint('PUT', '\\/sole-contacts\\/\\d+'),
704
705
  BUSINESS_ACTIVITIES_GET: new Endpoint('GET', '\\/sole-business-activities'),
@@ -8975,6 +8976,7 @@ class MyTaxBusinessDetails {
8975
8976
  this.businessActivities = uniqBy(businesses.mapBy('activity'), 'id');
8976
8977
  this.businessABN = soleDetails === null || soleDetails === void 0 ? void 0 : soleDetails.abn;
8977
8978
  this.businessAddress = (_a = user.address) === null || _a === void 0 ? void 0 : _a.name;
8979
+ this.businesses = businesses;
8978
8980
  this.vehicleClaimDetails = vehicleClaimDetails;
8979
8981
  }
8980
8982
  }
@@ -9083,7 +9085,7 @@ class MyTaxBusinessIncome {
9083
9085
  * https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/4644110466/Tax+Return+MyTax+-+Online+Form (section "Business income or losses")
9084
9086
  */
9085
9087
  class MyTaxBusinessLosses {
9086
- constructor(transactions, depreciations, businessLosses, currentLoss) {
9088
+ constructor(transactions, depreciations, businessLosses, currentLoss, taxSummary) {
9087
9089
  this.currentLoss = currentLoss;
9088
9090
  this.purchasesAndOtherCostsAmount = Math.abs(transactions.getExpenseTransactions()
9089
9091
  .filterBy('chartAccounts.id', ChartAccountsListEnum.PURCHASES_STOCK_INVENTORY)
@@ -9110,14 +9112,22 @@ class MyTaxBusinessLosses {
9110
9112
  .filterBy('chartAccounts.id', ChartAccountsListEnum.INTEREST_EXPENSES_OVERSEAS)
9111
9113
  .sumBy('claimAmount'));
9112
9114
  this.kmsTravelledExpensesAmount = Math.abs(transactions
9113
- .filterBy('chartAccounts.heading.id', [ChartAccountsHeadingListEnum.WORK_RELATED_CAR_EXPENSES, ChartAccountsHeadingListEnum.DEPRECIATION_VEHICLES])
9114
- .sumBy('claimAmount'));
9115
+ .filterBy('chartAccounts.category', [ChartAccountsListEnum.KLMS_TRAVELLED])
9116
+ .sumBy('claimAmount') +
9117
+ depreciations
9118
+ .filterBy('chartAccounts.category', [ChartAccountsListEnum.KLMS_TRAVELLED])
9119
+ .sumBy('claimAmount'));
9120
+ this.logbookExpensesAmount = Math.abs(transactions.getVehicleTransactions().sumBy('claimAmount')) +
9121
+ depreciations.getVehicleDepreciations().sumBy('claimAmount');
9115
9122
  this.otherExpensesAmount = Math.abs(transactions
9116
9123
  .filterBy('chartAccounts.heading.id', ChartAccountsHeadingListEnum.OTHER_EXPENSES)
9117
9124
  .sumBy('claimAmount'));
9118
9125
  this.totalNonPrimaryProductionExpensesAmount = Math.abs(transactions
9119
- .filterBy('chartAccounts.category', [ChartAccountsCategoryEnum.SOLE_EXPENSE, ChartAccountsCategoryEnum.SOLE_DEPRECIATION])
9120
- .sumBy('claimAmount'));
9126
+ .filterBy('chartAccounts.category', [ChartAccountsCategoryEnum.SOLE_EXPENSE])
9127
+ .sumBy('claimAmount')) +
9128
+ depreciations
9129
+ .filterBy('chartAccounts.category', [ChartAccountsCategoryEnum.SOLE_DEPRECIATION])
9130
+ .sumBy('claimAmount');
9121
9131
  // depreciations
9122
9132
  this.depreciationExpensesAmount = depreciations
9123
9133
  .filterBy('chartAccounts.heading.id', ChartAccountsHeadingListEnum.DEPRECIATION_EXPENSES)
@@ -9128,20 +9138,13 @@ class MyTaxBusinessLosses {
9128
9138
  this.deductionsForGeneralSmallBusinessPoolAmount = depreciations
9129
9139
  .getSBPDepreciations()
9130
9140
  .sumBy('claimAmount');
9131
- this.currentYearNetNonPrimaryIncomeOrLossesAmount = transactions.getIncomeTransactions()
9132
- .filterBy('chartAccounts.category', ChartAccountsCategoryEnum.SOLE_INCOME)
9133
- .amount -
9134
- Math.abs(transactions
9135
- .filterBy('chartAccounts.category', [ChartAccountsCategoryEnum.SOLE_EXPENSE, ChartAccountsCategoryEnum.SOLE_DEPRECIATION])
9136
- .sumBy('claimAmount'));
9137
- this.priorYearsNonPrimaryLossesAmount = this.calculatePriorYearsOpenBalance(businessLosses);
9138
- this.netNonPrimaryIncomeOrLossesAmount = transactions.getIncomeTransactions()
9139
- .filterBy('chartAccounts.category', ChartAccountsCategoryEnum.SOLE_INCOME)
9140
- .amount -
9141
+ this.currentYearNetNonPrimaryIncomeOrLossesAmount = +(transactions.sumBy('claimAmount') -
9142
+ depreciations.sumBy('claimAmount'))
9143
+ .toFixed(2);
9144
+ this.priorYearsNonPrimaryLossesAmount = businessLosses.sumBy('openBalance');
9145
+ this.netNonPrimaryIncomeOrLossesAmount = this.currentYearNetNonPrimaryIncomeOrLossesAmount -
9141
9146
  this.priorYearsNonPrimaryLossesAmount;
9142
- }
9143
- calculatePriorYearsOpenBalance(businessLosses) {
9144
- return businessLosses ? businessLosses.sumBy('openBalance') : 0;
9147
+ this.deferredLossesAmount = taxSummary.sole.items.sumByCategoriesAndSection(TAX_RETURN_CATEGORIES.sole.lossCurrent, TaxSummarySectionEnum.SOLE_TANK);
9145
9148
  }
9146
9149
  }
9147
9150
 
@@ -10058,6 +10061,13 @@ var UserEventSettingFieldEnum;
10058
10061
  UserEventSettingFieldEnum["FREQUENCY"] = "frequency";
10059
10062
  })(UserEventSettingFieldEnum || (UserEventSettingFieldEnum = {}));
10060
10063
 
10064
+ var MessagesEnum$1;
10065
+ (function (MessagesEnum) {
10066
+ MessagesEnum["LOGO_UPDATED"] = "Logo updated successfully";
10067
+ MessagesEnum["LOGO_ERROR_FORMAT"] = "Wrong file format. Allowed extensions: jpg, img, png";
10068
+ MessagesEnum["LOGO_ERROR_SIZE"] = "The file is too big. Maximum size is 2mb";
10069
+ })(MessagesEnum$1 || (MessagesEnum$1 = {}));
10070
+
10061
10071
  class SoleBusinessService extends RestService {
10062
10072
  constructor() {
10063
10073
  super(...arguments);
@@ -10071,6 +10081,24 @@ class SoleBusinessService extends RestService {
10071
10081
  return business;
10072
10082
  }));
10073
10083
  }
10084
+ uploadLogo(business, file) {
10085
+ const formData = new FormData();
10086
+ formData.append('file', file);
10087
+ return this.http.post(`${this.environment.apiV2}/${this.url}/${business.id}/logo`, formData)
10088
+ .pipe(map((updatedBusiness) => {
10089
+ const tempCache = cloneDeep$1(this.cache);
10090
+ replace(tempCache, plainToClass(SoleBusiness, updatedBusiness));
10091
+ this.cache = tempCache;
10092
+ this.cacheSubject.next(this.cache);
10093
+ this.toastService.success(MessagesEnum$1.LOGO_UPDATED);
10094
+ }), catchError((error) => {
10095
+ // Show error when user provided wrong image (format or size)
10096
+ if (error.status === 422) {
10097
+ this.toastService.error(error.error.violations[0].message);
10098
+ }
10099
+ return throwError$1(error);
10100
+ }));
10101
+ }
10074
10102
  }
10075
10103
  SoleBusinessService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SoleBusinessService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
10076
10104
  SoleBusinessService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: SoleBusinessService, providedIn: 'root' });
@@ -16394,7 +16422,7 @@ class PropertySaleExemptionsForm extends AbstractForm {
16394
16422
 
16395
16423
  class MyTaxBusinessDetailsForm extends AbstractForm {
16396
16424
  constructor(businessDetails) {
16397
- var _a, _b;
16425
+ var _a;
16398
16426
  super({
16399
16427
  vehicleClaimMethod: new FormControl({
16400
16428
  value: (_a = businessDetails.vehicleClaimDetails) === null || _a === void 0 ? void 0 : _a.method,
@@ -16403,11 +16431,10 @@ class MyTaxBusinessDetailsForm extends AbstractForm {
16403
16431
  businessType: new FormControl({ value: BusinessTypeEnum.SOLE_TRADER, disabled: true }),
16404
16432
  // business details
16405
16433
  mainBusinessActivity: new FormControl(businessDetails.businessActivities[0]),
16406
- mainBusinessName: new FormControl({ value: (_b = businessDetails.businesses) === null || _b === void 0 ? void 0 : _b.first.name, disabled: true }),
16434
+ mainBusinessName: new FormControl({ value: businessDetails.businesses.first.name, disabled: true }),
16407
16435
  mainBusinessABN: new FormControl({ value: businessDetails.businessABN, disabled: true }),
16408
16436
  mainBusinessAddress: new FormControl({ value: businessDetails.businessAddress, disabled: true }),
16409
- // By default, we show it as 1, but user can change it
16410
- numberOfBusinessActivities: new FormControl(1)
16437
+ numberOfBusinessActivities: new FormControl(businessDetails.businessActivities.length)
16411
16438
  });
16412
16439
  this.businessDetails = businessDetails;
16413
16440
  this.listenEvents();
@@ -16541,6 +16568,10 @@ class MyTaxBusinessLossesForm extends AbstractForm {
16541
16568
  value: businessLosses.kmsTravelledExpensesAmount,
16542
16569
  disabled: true
16543
16570
  }),
16571
+ logbookExpensesAmount: new FormControl({
16572
+ value: businessLosses.logbookExpensesAmount,
16573
+ disabled: true
16574
+ }),
16544
16575
  otherExpensesAmount: new FormControl({
16545
16576
  value: businessLosses.otherExpensesAmount,
16546
16577
  disabled: true