taxtank-core 0.30.105 → 0.30.106

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.
@@ -20,6 +20,7 @@ import differenceBy from 'lodash/differenceBy';
20
20
  import moment from 'moment';
21
21
  import { DateRange } from 'moment-range';
22
22
  import intersection from 'lodash/intersection';
23
+ import range from 'lodash/range';
23
24
  import { Validators, UntypedFormGroup, UntypedFormControl, UntypedFormArray, FormArray, FormGroup, FormControl } from '@angular/forms';
24
25
  import compact from 'lodash/compact';
25
26
  import concat from 'lodash/concat';
@@ -1068,7 +1069,8 @@ var ChartAccountsListEnum;
1068
1069
  ChartAccountsListEnum[ChartAccountsListEnum["KLMS_TRAVELLED_FOR_WORK"] = 24] = "KLMS_TRAVELLED_FOR_WORK";
1069
1070
  ChartAccountsListEnum[ChartAccountsListEnum["DIRECTOR_FEES"] = 6] = "DIRECTOR_FEES";
1070
1071
  ChartAccountsListEnum[ChartAccountsListEnum["SALARY_OR_WAGES"] = 2] = "SALARY_OR_WAGES";
1071
- ChartAccountsListEnum[ChartAccountsListEnum["VEHICLES"] = 25] = "VEHICLES";
1072
+ ChartAccountsListEnum[ChartAccountsListEnum["WORK_VEHICLES"] = 25] = "WORK_VEHICLES";
1073
+ ChartAccountsListEnum[ChartAccountsListEnum["SOLE_VEHICLES"] = 721] = "SOLE_VEHICLES";
1072
1074
  ChartAccountsListEnum[ChartAccountsListEnum["COMMERCIAL_VEHICLES"] = 26] = "COMMERCIAL_VEHICLES";
1073
1075
  ChartAccountsListEnum[ChartAccountsListEnum["VEHICLE_LOAN_INTEREST"] = 37] = "VEHICLE_LOAN_INTEREST";
1074
1076
  ChartAccountsListEnum[ChartAccountsListEnum["VEHICLE_LOAN_PRINCIPAL"] = 38] = "VEHICLE_LOAN_PRINCIPAL";
@@ -1835,6 +1837,90 @@ const USER_WORK_POSITION = {
1835
1837
  class ClientDetails extends ClientDetails$1 {
1836
1838
  }
1837
1839
 
1840
+ /**
1841
+ * @TODO move to pipe/translation
1842
+ * enum with months short names.
1843
+ * Order of items match with financial year months order
1844
+ */
1845
+ var MonthNameShortEnum;
1846
+ (function (MonthNameShortEnum) {
1847
+ MonthNameShortEnum["JULY"] = "Jul";
1848
+ MonthNameShortEnum["AUGUST"] = "Aug";
1849
+ MonthNameShortEnum["SEPTEMBER"] = "Sep";
1850
+ MonthNameShortEnum["OCTOBER"] = "Oct";
1851
+ MonthNameShortEnum["NOVEMBER"] = "Nov";
1852
+ MonthNameShortEnum["DECEMBER"] = "Dec";
1853
+ MonthNameShortEnum["JANUARY"] = "Jan";
1854
+ MonthNameShortEnum["FEBRUARY"] = "Feb";
1855
+ MonthNameShortEnum["MARCH"] = "Mar";
1856
+ MonthNameShortEnum["APRIL"] = "Apr";
1857
+ MonthNameShortEnum["MAY"] = "May";
1858
+ MonthNameShortEnum["JUNE"] = "Jun";
1859
+ })(MonthNameShortEnum || (MonthNameShortEnum = {}));
1860
+
1861
+ /**
1862
+ * enum with months indexes.
1863
+ * item value match with js Date month index from 0 to 11
1864
+ * Order of items match with financial year months order
1865
+ */
1866
+ var MonthNumberEnum;
1867
+ (function (MonthNumberEnum) {
1868
+ MonthNumberEnum[MonthNumberEnum["JULY"] = 6] = "JULY";
1869
+ MonthNumberEnum[MonthNumberEnum["AUGUST"] = 7] = "AUGUST";
1870
+ MonthNumberEnum[MonthNumberEnum["SEPTEMBER"] = 8] = "SEPTEMBER";
1871
+ MonthNumberEnum[MonthNumberEnum["OCTOBER"] = 9] = "OCTOBER";
1872
+ MonthNumberEnum[MonthNumberEnum["NOVEMBER"] = 10] = "NOVEMBER";
1873
+ MonthNumberEnum[MonthNumberEnum["DECEMBER"] = 11] = "DECEMBER";
1874
+ MonthNumberEnum[MonthNumberEnum["JANUARY"] = 0] = "JANUARY";
1875
+ MonthNumberEnum[MonthNumberEnum["FEBRUARY"] = 1] = "FEBRUARY";
1876
+ MonthNumberEnum[MonthNumberEnum["MARCH"] = 2] = "MARCH";
1877
+ MonthNumberEnum[MonthNumberEnum["APRIL"] = 3] = "APRIL";
1878
+ MonthNumberEnum[MonthNumberEnum["MAY"] = 4] = "MAY";
1879
+ MonthNumberEnum[MonthNumberEnum["JUNE"] = 5] = "JUNE";
1880
+ })(MonthNumberEnum || (MonthNumberEnum = {}));
1881
+
1882
+ const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan'];
1883
+
1884
+ class AnnualClientDetails extends AbstractModel {
1885
+ constructor() {
1886
+ super(...arguments);
1887
+ this.financialYear = new FinancialYear().year;
1888
+ }
1889
+ }
1890
+ __decorate([
1891
+ Type(() => ClientDetails)
1892
+ ], AnnualClientDetails.prototype, "clientDetails", void 0);
1893
+
1894
+ class ClientIncomeTypes extends ClientIncomeTypes$1 {
1895
+ /**
1896
+ * Get count of selected income types
1897
+ */
1898
+ get length() {
1899
+ return Object.values(this).filter((value) => typeof value === 'boolean' && value).length;
1900
+ }
1901
+ }
1902
+
1903
+ var ClientInviteStatusEnum;
1904
+ (function (ClientInviteStatusEnum) {
1905
+ ClientInviteStatusEnum[ClientInviteStatusEnum["PENDING"] = 1] = "PENDING";
1906
+ ClientInviteStatusEnum[ClientInviteStatusEnum["REJECTED"] = 2] = "REJECTED";
1907
+ })(ClientInviteStatusEnum || (ClientInviteStatusEnum = {}));
1908
+
1909
+ var ClientInviteTypeEnum;
1910
+ (function (ClientInviteTypeEnum) {
1911
+ ClientInviteTypeEnum[ClientInviteTypeEnum["FROM_CLIENT"] = 1] = "FROM_CLIENT";
1912
+ ClientInviteTypeEnum[ClientInviteTypeEnum["FROM_EMPLOYEE"] = 2] = "FROM_EMPLOYEE";
1913
+ })(ClientInviteTypeEnum || (ClientInviteTypeEnum = {}));
1914
+
1915
+ class RegistrationInvite extends RegistrationInvite$1 {
1916
+ getPhotoPlaceholder() {
1917
+ return `${this.firstName[0].toUpperCase()}${this.firstName[1]}`;
1918
+ }
1919
+ getPhoto() {
1920
+ return null;
1921
+ }
1922
+ }
1923
+
1838
1924
  var PhoneTypeEnum;
1839
1925
  (function (PhoneTypeEnum) {
1840
1926
  PhoneTypeEnum[PhoneTypeEnum["MOBILE"] = 1] = "MOBILE";
@@ -1879,11 +1965,64 @@ __decorate([
1879
1965
  Type(() => Phone)
1880
1966
  ], Firm.prototype, "phone", void 0);
1881
1967
 
1882
- class EmployeeDetails extends EmployeeDetails$1 {
1968
+ class ClientInvite extends ClientInvite$1 {
1969
+ /**
1970
+ * Check if client invite status is pending
1971
+ */
1972
+ isPending() {
1973
+ return this.status === ClientInviteStatusEnum.PENDING;
1974
+ }
1975
+ /**
1976
+ * Check if client invite status is accepted
1977
+ */
1978
+ isAccepted() {
1979
+ return !this.isPending() && !this.isRejected();
1980
+ }
1981
+ /**
1982
+ * Check if client invite status is rejected
1983
+ */
1984
+ isRejected() {
1985
+ return this.status === ClientInviteStatusEnum.REJECTED;
1986
+ }
1987
+ /**
1988
+ * Check if client invite initiated by firm
1989
+ */
1990
+ isFromEmployee() {
1991
+ return this.type === ClientInviteTypeEnum.FROM_EMPLOYEE;
1992
+ }
1993
+ /**
1994
+ * Check if client invite initiated by client
1995
+ */
1996
+ isFromClient() {
1997
+ return this.type === ClientInviteTypeEnum.FROM_CLIENT;
1998
+ }
1999
+ get firstName() {
2000
+ var _a;
2001
+ return this.client ? this.client.firstName : (_a = this.registrationInvite) === null || _a === void 0 ? void 0 : _a.firstName;
2002
+ }
2003
+ get email() {
2004
+ var _a;
2005
+ return this.client ? this.client.email : (_a = this.registrationInvite) === null || _a === void 0 ? void 0 : _a.email;
2006
+ }
1883
2007
  }
2008
+ __decorate([
2009
+ Type(() => Date)
2010
+ ], ClientInvite.prototype, "sentOn", void 0);
2011
+ __decorate([
2012
+ Type(() => Date)
2013
+ ], ClientInvite.prototype, "updatedAt", void 0);
1884
2014
  __decorate([
1885
2015
  Type(() => Firm)
1886
- ], EmployeeDetails.prototype, "firm", void 0);
2016
+ ], ClientInvite.prototype, "firm", void 0);
2017
+ __decorate([
2018
+ Type(() => User)
2019
+ ], ClientInvite.prototype, "client", void 0);
2020
+ __decorate([
2021
+ Type(() => User)
2022
+ ], ClientInvite.prototype, "employee", void 0);
2023
+ __decorate([
2024
+ Type(() => RegistrationInvite)
2025
+ ], ClientInvite.prototype, "registrationInvite", void 0);
1887
2026
 
1888
2027
  var ServiceProductStatusEnum;
1889
2028
  (function (ServiceProductStatusEnum) {
@@ -2515,50 +2654,6 @@ class ChartAccountsMetaField extends ChartAccountsMetaField$1 {
2515
2654
  }
2516
2655
  }
2517
2656
 
2518
- /**
2519
- * @TODO move to pipe/translation
2520
- * enum with months short names.
2521
- * Order of items match with financial year months order
2522
- */
2523
- var MonthNameShortEnum;
2524
- (function (MonthNameShortEnum) {
2525
- MonthNameShortEnum["JULY"] = "Jul";
2526
- MonthNameShortEnum["AUGUST"] = "Aug";
2527
- MonthNameShortEnum["SEPTEMBER"] = "Sep";
2528
- MonthNameShortEnum["OCTOBER"] = "Oct";
2529
- MonthNameShortEnum["NOVEMBER"] = "Nov";
2530
- MonthNameShortEnum["DECEMBER"] = "Dec";
2531
- MonthNameShortEnum["JANUARY"] = "Jan";
2532
- MonthNameShortEnum["FEBRUARY"] = "Feb";
2533
- MonthNameShortEnum["MARCH"] = "Mar";
2534
- MonthNameShortEnum["APRIL"] = "Apr";
2535
- MonthNameShortEnum["MAY"] = "May";
2536
- MonthNameShortEnum["JUNE"] = "Jun";
2537
- })(MonthNameShortEnum || (MonthNameShortEnum = {}));
2538
-
2539
- /**
2540
- * enum with months indexes.
2541
- * item value match with js Date month index from 0 to 11
2542
- * Order of items match with financial year months order
2543
- */
2544
- var MonthNumberEnum;
2545
- (function (MonthNumberEnum) {
2546
- MonthNumberEnum[MonthNumberEnum["JULY"] = 6] = "JULY";
2547
- MonthNumberEnum[MonthNumberEnum["AUGUST"] = 7] = "AUGUST";
2548
- MonthNumberEnum[MonthNumberEnum["SEPTEMBER"] = 8] = "SEPTEMBER";
2549
- MonthNumberEnum[MonthNumberEnum["OCTOBER"] = 9] = "OCTOBER";
2550
- MonthNumberEnum[MonthNumberEnum["NOVEMBER"] = 10] = "NOVEMBER";
2551
- MonthNumberEnum[MonthNumberEnum["DECEMBER"] = 11] = "DECEMBER";
2552
- MonthNumberEnum[MonthNumberEnum["JANUARY"] = 0] = "JANUARY";
2553
- MonthNumberEnum[MonthNumberEnum["FEBRUARY"] = 1] = "FEBRUARY";
2554
- MonthNumberEnum[MonthNumberEnum["MARCH"] = 2] = "MARCH";
2555
- MonthNumberEnum[MonthNumberEnum["APRIL"] = 3] = "APRIL";
2556
- MonthNumberEnum[MonthNumberEnum["MAY"] = 4] = "MAY";
2557
- MonthNumberEnum[MonthNumberEnum["JUNE"] = 5] = "JUNE";
2558
- })(MonthNumberEnum || (MonthNumberEnum = {}));
2559
-
2560
- const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan'];
2561
-
2562
2657
  class ChartAccountsValue extends ChartAccountsValue$1 {
2563
2658
  }
2564
2659
 
@@ -3122,7 +3217,7 @@ class ChartAccounts extends ChartAccounts$1 {
3122
3217
  * Check if chart accounts id is related for 'Motor Vehicles' category
3123
3218
  */
3124
3219
  isVehicles() {
3125
- return this.id === ChartAccountsListEnum.VEHICLES;
3220
+ return [ChartAccountsListEnum.WORK_VEHICLES, ChartAccountsListEnum.SOLE_VEHICLES].includes(this.id);
3126
3221
  }
3127
3222
  /**
3128
3223
  * Check if chart accounts id is related for 'Interest Earned' category
@@ -4265,15 +4360,6 @@ var PropertyShareStatusEnum;
4265
4360
  PropertyShareStatusEnum[PropertyShareStatusEnum["REJECTED"] = 3] = "REJECTED";
4266
4361
  })(PropertyShareStatusEnum || (PropertyShareStatusEnum = {}));
4267
4362
 
4268
- class RegistrationInvite extends RegistrationInvite$1 {
4269
- getPhotoPlaceholder() {
4270
- return `${this.firstName[0].toUpperCase()}${this.firstName[1]}`;
4271
- }
4272
- getPhoto() {
4273
- return null;
4274
- }
4275
- }
4276
-
4277
4363
  class PropertyShare extends PropertyShare$1 {
4278
4364
  isAccepted() {
4279
4365
  return this.status === PropertyShareStatusEnum.APPROVED;
@@ -7562,38 +7648,202 @@ __decorate([
7562
7648
  Expose()
7563
7649
  ], ServiceSubscription.prototype, "promoCodeId", null);
7564
7650
 
7565
- class User extends User$1 {
7566
- get fullName() {
7567
- return `${this.firstName} ${this.lastName}`;
7568
- }
7569
- get activeSubscription() {
7570
- return this.subscriptions.find((ss) => ss.isActive);
7571
- }
7572
- get lastSubscription() {
7573
- return this.subscriptions[this.subscriptions.length - 1];
7651
+ class ClientMovement extends ClientMovement$1 {
7652
+ }
7653
+ __decorate([
7654
+ Type(() => Firm)
7655
+ ], ClientMovement.prototype, "firm", void 0);
7656
+ __decorate([
7657
+ Type(() => User)
7658
+ ], ClientMovement.prototype, "client", void 0);
7659
+ __decorate([
7660
+ Type(() => User)
7661
+ ], ClientMovement.prototype, "employee", void 0);
7662
+ __decorate([
7663
+ Type(() => ServiceSubscription)
7664
+ ], ClientMovement.prototype, "subscription", void 0);
7665
+ __decorate([
7666
+ Type(() => Date)
7667
+ ], ClientMovement.prototype, "dateFrom", void 0);
7668
+ __decorate([
7669
+ Type(() => Date)
7670
+ ], ClientMovement.prototype, "dateTo", void 0);
7671
+
7672
+ /**
7673
+ * Client portfolio charts data based on ClientPortfolioReportCollection
7674
+ */
7675
+ class ClientPortfolioChartData {
7676
+ constructor(clientsPortfolioReportCollection) {
7677
+ this.clientsPortfolioReportCollection = clientsPortfolioReportCollection;
7574
7678
  }
7575
- /**
7576
- * @TODO refactor
7577
- *
7578
- */
7579
- get position() {
7580
- switch (true) {
7581
- case this.isFirmOwner():
7582
- return USER_WORK_POSITION[UserRolesEnum.FIRM_OWNER];
7583
- case this.isManager():
7584
- return USER_WORK_POSITION[UserRolesEnum.FIRM_MANAGER];
7585
- case this.isEmployee():
7586
- return USER_WORK_POSITION[UserRolesEnum.EMPLOYEE];
7587
- default:
7588
- return '';
7589
- }
7679
+ getPieChartData() {
7680
+ return this.clientsPortfolioReportCollection.items.map((clientPortfolioReport) => plainToClass(ChartData, {
7681
+ name: clientPortfolioReport.category,
7682
+ data: clientPortfolioReport.count
7683
+ }));
7590
7684
  }
7591
- /**
7592
- * search roles including hierarchy
7593
- */
7594
- hasRoles(roles) {
7595
- roles = roles instanceof Array ? roles : [roles];
7596
- if (!roles.length) {
7685
+ getBarChartData() {
7686
+ return [
7687
+ plainToClass(ChartData, {
7688
+ name: 'Total',
7689
+ data: [
7690
+ {
7691
+ label: 'Market value',
7692
+ value: this.clientsPortfolioReportCollection.marketValue
7693
+ },
7694
+ {
7695
+ label: 'Loan balance',
7696
+ value: this.clientsPortfolioReportCollection.loanBalance
7697
+ },
7698
+ {
7699
+ label: 'Equity position',
7700
+ value: this.clientsPortfolioReportCollection.equityPosition
7701
+ }
7702
+ ]
7703
+ }),
7704
+ plainToClass(ChartData, {
7705
+ name: 'Average',
7706
+ data: [
7707
+ {
7708
+ label: 'Market value',
7709
+ value: this.clientsPortfolioReportCollection.averageMarketValue
7710
+ },
7711
+ {
7712
+ label: 'Loan balance',
7713
+ value: this.clientsPortfolioReportCollection.averageLoanBalance
7714
+ },
7715
+ {
7716
+ label: 'Equity position',
7717
+ value: this.clientsPortfolioReportCollection.averageEquityPosition
7718
+ }
7719
+ ]
7720
+ })
7721
+ ];
7722
+ }
7723
+ }
7724
+
7725
+ /**
7726
+ * Class describes client's portfolio report information
7727
+ */
7728
+ class ClientPortfolioReport extends AbstractModel {
7729
+ }
7730
+
7731
+ class EmployeeDetails extends EmployeeDetails$1 {
7732
+ }
7733
+ __decorate([
7734
+ Type(() => Firm)
7735
+ ], EmployeeDetails.prototype, "firm", void 0);
7736
+
7737
+ class ServicePayment extends ServicePayment$1 {
7738
+ /**
7739
+ * Stripe stores actual links to payment invoices for 30 days.
7740
+ * Link expires after 30 days
7741
+ */
7742
+ isInvoiceLinkExpired() {
7743
+ const expirationDate = new Date(this.date.setDate(this.date.getDate() + ServicePayment.daysToInvoiceUrlExpired));
7744
+ return expirationDate.getTime() < new Date().getTime();
7745
+ }
7746
+ }
7747
+ ServicePayment.daysToInvoiceUrlExpired = 30;
7748
+ __decorate([
7749
+ Type(() => ServiceSubscription)
7750
+ ], ServicePayment.prototype, "subscription", void 0);
7751
+ __decorate([
7752
+ Type(() => Date)
7753
+ ], ServicePayment.prototype, "date", void 0);
7754
+
7755
+ let ServicePaymentMethod$1 = class ServicePaymentMethod extends AbstractModel {
7756
+ };
7757
+
7758
+ var PaymentMethodBrandEnum;
7759
+ (function (PaymentMethodBrandEnum) {
7760
+ PaymentMethodBrandEnum["UNKNOWN"] = "Unknown";
7761
+ PaymentMethodBrandEnum["AMEX"] = "American Express";
7762
+ PaymentMethodBrandEnum["DINERS"] = "Diners Club";
7763
+ PaymentMethodBrandEnum["DISCOVER"] = "Discover";
7764
+ PaymentMethodBrandEnum["JCB"] = "JCB";
7765
+ PaymentMethodBrandEnum["MASTERCARD"] = "Mastercard";
7766
+ PaymentMethodBrandEnum["UNIONPAY"] = "UnionPay";
7767
+ PaymentMethodBrandEnum["VISA"] = "Visa";
7768
+ })(PaymentMethodBrandEnum || (PaymentMethodBrandEnum = {}));
7769
+
7770
+ var ServicePaymentMethodCardBrandEnum;
7771
+ (function (ServicePaymentMethodCardBrandEnum) {
7772
+ ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["UNKNOWN"] = 0] = "UNKNOWN";
7773
+ ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["AMEX"] = 1] = "AMEX";
7774
+ ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["DINERS"] = 2] = "DINERS";
7775
+ ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["DISCOVER"] = 3] = "DISCOVER";
7776
+ ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["JCB"] = 4] = "JCB";
7777
+ ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["MASTERCARD"] = 5] = "MASTERCARD";
7778
+ ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["UNIONPAY"] = 6] = "UNIONPAY";
7779
+ ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["VISA"] = 7] = "VISA";
7780
+ })(ServicePaymentMethodCardBrandEnum || (ServicePaymentMethodCardBrandEnum = {}));
7781
+
7782
+ var ServicePaymentMethodTypeEnum;
7783
+ (function (ServicePaymentMethodTypeEnum) {
7784
+ ServicePaymentMethodTypeEnum[ServicePaymentMethodTypeEnum["AU_BECS_DEBIT"] = 1] = "AU_BECS_DEBIT";
7785
+ ServicePaymentMethodTypeEnum[ServicePaymentMethodTypeEnum["CARD"] = 2] = "CARD";
7786
+ })(ServicePaymentMethodTypeEnum || (ServicePaymentMethodTypeEnum = {}));
7787
+
7788
+ class ServicePaymentMethod extends ServicePaymentMethod$1 {
7789
+ get logo() {
7790
+ if (!this.isCard()) {
7791
+ return null;
7792
+ }
7793
+ return `/assets/img/payment-methods/${this.cardBrand}.svg`;
7794
+ }
7795
+ get brandName() {
7796
+ return this.isCard() ? PaymentMethodBrandEnum[ServicePaymentMethodCardBrandEnum[this.cardBrand]] : 'BECS Direct Debit (AU)';
7797
+ }
7798
+ /**
7799
+ * Get expiration date formatted string (MM/YY)
7800
+ */
7801
+ get expirationDate() {
7802
+ if (!this.isCard()) {
7803
+ return null;
7804
+ }
7805
+ return `${('0' + this.cardExpirationMonth).slice(-2)}/${this.cardExpirationYear.toString().slice(-2)}`;
7806
+ }
7807
+ get description() {
7808
+ return `${this.brandName} ***${this.lastFourDigits}`;
7809
+ }
7810
+ isCard() {
7811
+ return this.type === ServicePaymentMethodTypeEnum.CARD;
7812
+ }
7813
+ }
7814
+
7815
+ class User extends User$1 {
7816
+ get fullName() {
7817
+ return `${this.firstName} ${this.lastName}`;
7818
+ }
7819
+ get activeSubscription() {
7820
+ return this.subscriptions.find((ss) => ss.isActive);
7821
+ }
7822
+ get lastSubscription() {
7823
+ return this.subscriptions[this.subscriptions.length - 1];
7824
+ }
7825
+ /**
7826
+ * @TODO refactor
7827
+ *
7828
+ */
7829
+ get position() {
7830
+ switch (true) {
7831
+ case this.isFirmOwner():
7832
+ return USER_WORK_POSITION[UserRolesEnum.FIRM_OWNER];
7833
+ case this.isManager():
7834
+ return USER_WORK_POSITION[UserRolesEnum.FIRM_MANAGER];
7835
+ case this.isEmployee():
7836
+ return USER_WORK_POSITION[UserRolesEnum.EMPLOYEE];
7837
+ default:
7838
+ return '';
7839
+ }
7840
+ }
7841
+ /**
7842
+ * search roles including hierarchy
7843
+ */
7844
+ hasRoles(roles) {
7845
+ roles = roles instanceof Array ? roles : [roles];
7846
+ if (!roles.length) {
7597
7847
  return true;
7598
7848
  }
7599
7849
  roles = flatten(roles.map((role) => USER_ROLES[role]));
@@ -7677,6 +7927,13 @@ class User extends User$1 {
7677
7927
  isCurrentFinancialYear() {
7678
7928
  return new FinancialYear(new Date()).year === this.financialYear;
7679
7929
  }
7930
+ /**
7931
+ * financial years available in the app for user
7932
+ * starts from 2022 for new users and registeredYear - 1 for old users
7933
+ */
7934
+ get financialYears() {
7935
+ return range(Math.min(FinancialYear.toFinYear(this.createdAt) - 1, 2022), FinancialYear.toFinYear(new Date()) + 1);
7936
+ }
7680
7937
  }
7681
7938
  __decorate([
7682
7939
  Type(() => ServiceSubscription)
@@ -8561,84 +8818,6 @@ __decorate([
8561
8818
  })
8562
8819
  ], Notification.prototype, "redirectionLink", void 0);
8563
8820
 
8564
- class ServicePayment extends ServicePayment$1 {
8565
- /**
8566
- * Stripe stores actual links to payment invoices for 30 days.
8567
- * Link expires after 30 days
8568
- */
8569
- isInvoiceLinkExpired() {
8570
- const expirationDate = new Date(this.date.setDate(this.date.getDate() + ServicePayment.daysToInvoiceUrlExpired));
8571
- return expirationDate.getTime() < new Date().getTime();
8572
- }
8573
- }
8574
- ServicePayment.daysToInvoiceUrlExpired = 30;
8575
- __decorate([
8576
- Type(() => ServiceSubscription)
8577
- ], ServicePayment.prototype, "subscription", void 0);
8578
- __decorate([
8579
- Type(() => Date)
8580
- ], ServicePayment.prototype, "date", void 0);
8581
-
8582
- let ServicePaymentMethod$1 = class ServicePaymentMethod extends AbstractModel {
8583
- };
8584
-
8585
- var PaymentMethodBrandEnum;
8586
- (function (PaymentMethodBrandEnum) {
8587
- PaymentMethodBrandEnum["UNKNOWN"] = "Unknown";
8588
- PaymentMethodBrandEnum["AMEX"] = "American Express";
8589
- PaymentMethodBrandEnum["DINERS"] = "Diners Club";
8590
- PaymentMethodBrandEnum["DISCOVER"] = "Discover";
8591
- PaymentMethodBrandEnum["JCB"] = "JCB";
8592
- PaymentMethodBrandEnum["MASTERCARD"] = "Mastercard";
8593
- PaymentMethodBrandEnum["UNIONPAY"] = "UnionPay";
8594
- PaymentMethodBrandEnum["VISA"] = "Visa";
8595
- })(PaymentMethodBrandEnum || (PaymentMethodBrandEnum = {}));
8596
-
8597
- var ServicePaymentMethodCardBrandEnum;
8598
- (function (ServicePaymentMethodCardBrandEnum) {
8599
- ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["UNKNOWN"] = 0] = "UNKNOWN";
8600
- ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["AMEX"] = 1] = "AMEX";
8601
- ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["DINERS"] = 2] = "DINERS";
8602
- ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["DISCOVER"] = 3] = "DISCOVER";
8603
- ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["JCB"] = 4] = "JCB";
8604
- ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["MASTERCARD"] = 5] = "MASTERCARD";
8605
- ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["UNIONPAY"] = 6] = "UNIONPAY";
8606
- ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["VISA"] = 7] = "VISA";
8607
- })(ServicePaymentMethodCardBrandEnum || (ServicePaymentMethodCardBrandEnum = {}));
8608
-
8609
- var ServicePaymentMethodTypeEnum;
8610
- (function (ServicePaymentMethodTypeEnum) {
8611
- ServicePaymentMethodTypeEnum[ServicePaymentMethodTypeEnum["AU_BECS_DEBIT"] = 1] = "AU_BECS_DEBIT";
8612
- ServicePaymentMethodTypeEnum[ServicePaymentMethodTypeEnum["CARD"] = 2] = "CARD";
8613
- })(ServicePaymentMethodTypeEnum || (ServicePaymentMethodTypeEnum = {}));
8614
-
8615
- class ServicePaymentMethod extends ServicePaymentMethod$1 {
8616
- get logo() {
8617
- if (!this.isCard()) {
8618
- return null;
8619
- }
8620
- return `/assets/img/payment-methods/${this.cardBrand}.svg`;
8621
- }
8622
- get brandName() {
8623
- return this.isCard() ? PaymentMethodBrandEnum[ServicePaymentMethodCardBrandEnum[this.cardBrand]] : 'BECS Direct Debit (AU)';
8624
- }
8625
- /**
8626
- * Get expiration date formatted string (MM/YY)
8627
- */
8628
- get expirationDate() {
8629
- if (!this.isCard()) {
8630
- return null;
8631
- }
8632
- return `${('0' + this.cardExpirationMonth).slice(-2)}/${this.cardExpirationYear.toString().slice(-2)}`;
8633
- }
8634
- get description() {
8635
- return `${this.brandName} ***${this.lastFourDigits}`;
8636
- }
8637
- isCard() {
8638
- return this.type === ServicePaymentMethodTypeEnum.CARD;
8639
- }
8640
- }
8641
-
8642
8821
  /**
8643
8822
  * Enum with document types which used to API url prefix
8644
8823
  */
@@ -8875,176 +9054,6 @@ __decorate([
8875
9054
  Type(() => HoldingType)
8876
9055
  ], HoldingReinvest.prototype, "holdingType", void 0);
8877
9056
 
8878
- class AnnualClientDetails extends AbstractModel {
8879
- constructor() {
8880
- super(...arguments);
8881
- this.financialYear = new FinancialYear().year;
8882
- }
8883
- }
8884
- __decorate([
8885
- Type(() => ClientDetails)
8886
- ], AnnualClientDetails.prototype, "clientDetails", void 0);
8887
-
8888
- class ClientIncomeTypes extends ClientIncomeTypes$1 {
8889
- /**
8890
- * Get count of selected income types
8891
- */
8892
- get length() {
8893
- return Object.values(this).filter((value) => typeof value === 'boolean' && value).length;
8894
- }
8895
- }
8896
-
8897
- var ClientInviteStatusEnum;
8898
- (function (ClientInviteStatusEnum) {
8899
- ClientInviteStatusEnum[ClientInviteStatusEnum["PENDING"] = 1] = "PENDING";
8900
- ClientInviteStatusEnum[ClientInviteStatusEnum["REJECTED"] = 2] = "REJECTED";
8901
- })(ClientInviteStatusEnum || (ClientInviteStatusEnum = {}));
8902
-
8903
- var ClientInviteTypeEnum;
8904
- (function (ClientInviteTypeEnum) {
8905
- ClientInviteTypeEnum[ClientInviteTypeEnum["FROM_CLIENT"] = 1] = "FROM_CLIENT";
8906
- ClientInviteTypeEnum[ClientInviteTypeEnum["FROM_EMPLOYEE"] = 2] = "FROM_EMPLOYEE";
8907
- })(ClientInviteTypeEnum || (ClientInviteTypeEnum = {}));
8908
-
8909
- class ClientInvite extends ClientInvite$1 {
8910
- /**
8911
- * Check if client invite status is pending
8912
- */
8913
- isPending() {
8914
- return this.status === ClientInviteStatusEnum.PENDING;
8915
- }
8916
- /**
8917
- * Check if client invite status is accepted
8918
- */
8919
- isAccepted() {
8920
- return !this.isPending() && !this.isRejected();
8921
- }
8922
- /**
8923
- * Check if client invite status is rejected
8924
- */
8925
- isRejected() {
8926
- return this.status === ClientInviteStatusEnum.REJECTED;
8927
- }
8928
- /**
8929
- * Check if client invite initiated by firm
8930
- */
8931
- isFromEmployee() {
8932
- return this.type === ClientInviteTypeEnum.FROM_EMPLOYEE;
8933
- }
8934
- /**
8935
- * Check if client invite initiated by client
8936
- */
8937
- isFromClient() {
8938
- return this.type === ClientInviteTypeEnum.FROM_CLIENT;
8939
- }
8940
- get firstName() {
8941
- var _a;
8942
- return this.client ? this.client.firstName : (_a = this.registrationInvite) === null || _a === void 0 ? void 0 : _a.firstName;
8943
- }
8944
- get email() {
8945
- var _a;
8946
- return this.client ? this.client.email : (_a = this.registrationInvite) === null || _a === void 0 ? void 0 : _a.email;
8947
- }
8948
- }
8949
- __decorate([
8950
- Type(() => Date)
8951
- ], ClientInvite.prototype, "sentOn", void 0);
8952
- __decorate([
8953
- Type(() => Date)
8954
- ], ClientInvite.prototype, "updatedAt", void 0);
8955
- __decorate([
8956
- Type(() => Firm)
8957
- ], ClientInvite.prototype, "firm", void 0);
8958
- __decorate([
8959
- Type(() => User)
8960
- ], ClientInvite.prototype, "client", void 0);
8961
- __decorate([
8962
- Type(() => User)
8963
- ], ClientInvite.prototype, "employee", void 0);
8964
- __decorate([
8965
- Type(() => RegistrationInvite)
8966
- ], ClientInvite.prototype, "registrationInvite", void 0);
8967
-
8968
- class ClientMovement extends ClientMovement$1 {
8969
- }
8970
- __decorate([
8971
- Type(() => Firm)
8972
- ], ClientMovement.prototype, "firm", void 0);
8973
- __decorate([
8974
- Type(() => User)
8975
- ], ClientMovement.prototype, "client", void 0);
8976
- __decorate([
8977
- Type(() => User)
8978
- ], ClientMovement.prototype, "employee", void 0);
8979
- __decorate([
8980
- Type(() => ServiceSubscription)
8981
- ], ClientMovement.prototype, "subscription", void 0);
8982
- __decorate([
8983
- Type(() => Date)
8984
- ], ClientMovement.prototype, "dateFrom", void 0);
8985
- __decorate([
8986
- Type(() => Date)
8987
- ], ClientMovement.prototype, "dateTo", void 0);
8988
-
8989
- /**
8990
- * Client portfolio charts data based on ClientPortfolioReportCollection
8991
- */
8992
- class ClientPortfolioChartData {
8993
- constructor(clientsPortfolioReportCollection) {
8994
- this.clientsPortfolioReportCollection = clientsPortfolioReportCollection;
8995
- }
8996
- getPieChartData() {
8997
- return this.clientsPortfolioReportCollection.items.map((clientPortfolioReport) => plainToClass(ChartData, {
8998
- name: clientPortfolioReport.category,
8999
- data: clientPortfolioReport.count
9000
- }));
9001
- }
9002
- getBarChartData() {
9003
- return [
9004
- plainToClass(ChartData, {
9005
- name: 'Total',
9006
- data: [
9007
- {
9008
- label: 'Market value',
9009
- value: this.clientsPortfolioReportCollection.marketValue
9010
- },
9011
- {
9012
- label: 'Loan balance',
9013
- value: this.clientsPortfolioReportCollection.loanBalance
9014
- },
9015
- {
9016
- label: 'Equity position',
9017
- value: this.clientsPortfolioReportCollection.equityPosition
9018
- }
9019
- ]
9020
- }),
9021
- plainToClass(ChartData, {
9022
- name: 'Average',
9023
- data: [
9024
- {
9025
- label: 'Market value',
9026
- value: this.clientsPortfolioReportCollection.averageMarketValue
9027
- },
9028
- {
9029
- label: 'Loan balance',
9030
- value: this.clientsPortfolioReportCollection.averageLoanBalance
9031
- },
9032
- {
9033
- label: 'Equity position',
9034
- value: this.clientsPortfolioReportCollection.averageEquityPosition
9035
- }
9036
- ]
9037
- })
9038
- ];
9039
- }
9040
- }
9041
-
9042
- /**
9043
- * Class describes client's portfolio report information
9044
- */
9045
- class ClientPortfolioReport extends AbstractModel {
9046
- }
9047
-
9048
9057
  const NAME_TOKEN = 'token';
9049
9058
  const NAME_REFRESH_TOKEN = 'refreshToken';
9050
9059
  class JwtService extends JwtHelperService {