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';
@@ -1059,7 +1060,8 @@ var ChartAccountsListEnum;
1059
1060
  ChartAccountsListEnum[ChartAccountsListEnum["KLMS_TRAVELLED_FOR_WORK"] = 24] = "KLMS_TRAVELLED_FOR_WORK";
1060
1061
  ChartAccountsListEnum[ChartAccountsListEnum["DIRECTOR_FEES"] = 6] = "DIRECTOR_FEES";
1061
1062
  ChartAccountsListEnum[ChartAccountsListEnum["SALARY_OR_WAGES"] = 2] = "SALARY_OR_WAGES";
1062
- ChartAccountsListEnum[ChartAccountsListEnum["VEHICLES"] = 25] = "VEHICLES";
1063
+ ChartAccountsListEnum[ChartAccountsListEnum["WORK_VEHICLES"] = 25] = "WORK_VEHICLES";
1064
+ ChartAccountsListEnum[ChartAccountsListEnum["SOLE_VEHICLES"] = 721] = "SOLE_VEHICLES";
1063
1065
  ChartAccountsListEnum[ChartAccountsListEnum["COMMERCIAL_VEHICLES"] = 26] = "COMMERCIAL_VEHICLES";
1064
1066
  ChartAccountsListEnum[ChartAccountsListEnum["VEHICLE_LOAN_INTEREST"] = 37] = "VEHICLE_LOAN_INTEREST";
1065
1067
  ChartAccountsListEnum[ChartAccountsListEnum["VEHICLE_LOAN_PRINCIPAL"] = 38] = "VEHICLE_LOAN_PRINCIPAL";
@@ -1825,6 +1827,90 @@ const USER_WORK_POSITION = {
1825
1827
  class ClientDetails extends ClientDetails$1 {
1826
1828
  }
1827
1829
 
1830
+ /**
1831
+ * @TODO move to pipe/translation
1832
+ * enum with months short names.
1833
+ * Order of items match with financial year months order
1834
+ */
1835
+ var MonthNameShortEnum;
1836
+ (function (MonthNameShortEnum) {
1837
+ MonthNameShortEnum["JULY"] = "Jul";
1838
+ MonthNameShortEnum["AUGUST"] = "Aug";
1839
+ MonthNameShortEnum["SEPTEMBER"] = "Sep";
1840
+ MonthNameShortEnum["OCTOBER"] = "Oct";
1841
+ MonthNameShortEnum["NOVEMBER"] = "Nov";
1842
+ MonthNameShortEnum["DECEMBER"] = "Dec";
1843
+ MonthNameShortEnum["JANUARY"] = "Jan";
1844
+ MonthNameShortEnum["FEBRUARY"] = "Feb";
1845
+ MonthNameShortEnum["MARCH"] = "Mar";
1846
+ MonthNameShortEnum["APRIL"] = "Apr";
1847
+ MonthNameShortEnum["MAY"] = "May";
1848
+ MonthNameShortEnum["JUNE"] = "Jun";
1849
+ })(MonthNameShortEnum || (MonthNameShortEnum = {}));
1850
+
1851
+ /**
1852
+ * enum with months indexes.
1853
+ * item value match with js Date month index from 0 to 11
1854
+ * Order of items match with financial year months order
1855
+ */
1856
+ var MonthNumberEnum;
1857
+ (function (MonthNumberEnum) {
1858
+ MonthNumberEnum[MonthNumberEnum["JULY"] = 6] = "JULY";
1859
+ MonthNumberEnum[MonthNumberEnum["AUGUST"] = 7] = "AUGUST";
1860
+ MonthNumberEnum[MonthNumberEnum["SEPTEMBER"] = 8] = "SEPTEMBER";
1861
+ MonthNumberEnum[MonthNumberEnum["OCTOBER"] = 9] = "OCTOBER";
1862
+ MonthNumberEnum[MonthNumberEnum["NOVEMBER"] = 10] = "NOVEMBER";
1863
+ MonthNumberEnum[MonthNumberEnum["DECEMBER"] = 11] = "DECEMBER";
1864
+ MonthNumberEnum[MonthNumberEnum["JANUARY"] = 0] = "JANUARY";
1865
+ MonthNumberEnum[MonthNumberEnum["FEBRUARY"] = 1] = "FEBRUARY";
1866
+ MonthNumberEnum[MonthNumberEnum["MARCH"] = 2] = "MARCH";
1867
+ MonthNumberEnum[MonthNumberEnum["APRIL"] = 3] = "APRIL";
1868
+ MonthNumberEnum[MonthNumberEnum["MAY"] = 4] = "MAY";
1869
+ MonthNumberEnum[MonthNumberEnum["JUNE"] = 5] = "JUNE";
1870
+ })(MonthNumberEnum || (MonthNumberEnum = {}));
1871
+
1872
+ const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan'];
1873
+
1874
+ class AnnualClientDetails extends AbstractModel {
1875
+ constructor() {
1876
+ super(...arguments);
1877
+ this.financialYear = new FinancialYear().year;
1878
+ }
1879
+ }
1880
+ __decorate([
1881
+ Type(() => ClientDetails)
1882
+ ], AnnualClientDetails.prototype, "clientDetails", void 0);
1883
+
1884
+ class ClientIncomeTypes extends ClientIncomeTypes$1 {
1885
+ /**
1886
+ * Get count of selected income types
1887
+ */
1888
+ get length() {
1889
+ return Object.values(this).filter((value) => typeof value === 'boolean' && value).length;
1890
+ }
1891
+ }
1892
+
1893
+ var ClientInviteStatusEnum;
1894
+ (function (ClientInviteStatusEnum) {
1895
+ ClientInviteStatusEnum[ClientInviteStatusEnum["PENDING"] = 1] = "PENDING";
1896
+ ClientInviteStatusEnum[ClientInviteStatusEnum["REJECTED"] = 2] = "REJECTED";
1897
+ })(ClientInviteStatusEnum || (ClientInviteStatusEnum = {}));
1898
+
1899
+ var ClientInviteTypeEnum;
1900
+ (function (ClientInviteTypeEnum) {
1901
+ ClientInviteTypeEnum[ClientInviteTypeEnum["FROM_CLIENT"] = 1] = "FROM_CLIENT";
1902
+ ClientInviteTypeEnum[ClientInviteTypeEnum["FROM_EMPLOYEE"] = 2] = "FROM_EMPLOYEE";
1903
+ })(ClientInviteTypeEnum || (ClientInviteTypeEnum = {}));
1904
+
1905
+ class RegistrationInvite extends RegistrationInvite$1 {
1906
+ getPhotoPlaceholder() {
1907
+ return `${this.firstName[0].toUpperCase()}${this.firstName[1]}`;
1908
+ }
1909
+ getPhoto() {
1910
+ return null;
1911
+ }
1912
+ }
1913
+
1828
1914
  var PhoneTypeEnum;
1829
1915
  (function (PhoneTypeEnum) {
1830
1916
  PhoneTypeEnum[PhoneTypeEnum["MOBILE"] = 1] = "MOBILE";
@@ -1869,11 +1955,62 @@ __decorate([
1869
1955
  Type(() => Phone)
1870
1956
  ], Firm.prototype, "phone", void 0);
1871
1957
 
1872
- class EmployeeDetails extends EmployeeDetails$1 {
1958
+ class ClientInvite extends ClientInvite$1 {
1959
+ /**
1960
+ * Check if client invite status is pending
1961
+ */
1962
+ isPending() {
1963
+ return this.status === ClientInviteStatusEnum.PENDING;
1964
+ }
1965
+ /**
1966
+ * Check if client invite status is accepted
1967
+ */
1968
+ isAccepted() {
1969
+ return !this.isPending() && !this.isRejected();
1970
+ }
1971
+ /**
1972
+ * Check if client invite status is rejected
1973
+ */
1974
+ isRejected() {
1975
+ return this.status === ClientInviteStatusEnum.REJECTED;
1976
+ }
1977
+ /**
1978
+ * Check if client invite initiated by firm
1979
+ */
1980
+ isFromEmployee() {
1981
+ return this.type === ClientInviteTypeEnum.FROM_EMPLOYEE;
1982
+ }
1983
+ /**
1984
+ * Check if client invite initiated by client
1985
+ */
1986
+ isFromClient() {
1987
+ return this.type === ClientInviteTypeEnum.FROM_CLIENT;
1988
+ }
1989
+ get firstName() {
1990
+ return this.client ? this.client.firstName : this.registrationInvite?.firstName;
1991
+ }
1992
+ get email() {
1993
+ return this.client ? this.client.email : this.registrationInvite?.email;
1994
+ }
1873
1995
  }
1996
+ __decorate([
1997
+ Type(() => Date)
1998
+ ], ClientInvite.prototype, "sentOn", void 0);
1999
+ __decorate([
2000
+ Type(() => Date)
2001
+ ], ClientInvite.prototype, "updatedAt", void 0);
1874
2002
  __decorate([
1875
2003
  Type(() => Firm)
1876
- ], EmployeeDetails.prototype, "firm", void 0);
2004
+ ], ClientInvite.prototype, "firm", void 0);
2005
+ __decorate([
2006
+ Type(() => User)
2007
+ ], ClientInvite.prototype, "client", void 0);
2008
+ __decorate([
2009
+ Type(() => User)
2010
+ ], ClientInvite.prototype, "employee", void 0);
2011
+ __decorate([
2012
+ Type(() => RegistrationInvite)
2013
+ ], ClientInvite.prototype, "registrationInvite", void 0);
1877
2014
 
1878
2015
  var ServiceProductStatusEnum;
1879
2016
  (function (ServiceProductStatusEnum) {
@@ -2502,50 +2639,6 @@ class ChartAccountsMetaField extends ChartAccountsMetaField$1 {
2502
2639
  }
2503
2640
  }
2504
2641
 
2505
- /**
2506
- * @TODO move to pipe/translation
2507
- * enum with months short names.
2508
- * Order of items match with financial year months order
2509
- */
2510
- var MonthNameShortEnum;
2511
- (function (MonthNameShortEnum) {
2512
- MonthNameShortEnum["JULY"] = "Jul";
2513
- MonthNameShortEnum["AUGUST"] = "Aug";
2514
- MonthNameShortEnum["SEPTEMBER"] = "Sep";
2515
- MonthNameShortEnum["OCTOBER"] = "Oct";
2516
- MonthNameShortEnum["NOVEMBER"] = "Nov";
2517
- MonthNameShortEnum["DECEMBER"] = "Dec";
2518
- MonthNameShortEnum["JANUARY"] = "Jan";
2519
- MonthNameShortEnum["FEBRUARY"] = "Feb";
2520
- MonthNameShortEnum["MARCH"] = "Mar";
2521
- MonthNameShortEnum["APRIL"] = "Apr";
2522
- MonthNameShortEnum["MAY"] = "May";
2523
- MonthNameShortEnum["JUNE"] = "Jun";
2524
- })(MonthNameShortEnum || (MonthNameShortEnum = {}));
2525
-
2526
- /**
2527
- * enum with months indexes.
2528
- * item value match with js Date month index from 0 to 11
2529
- * Order of items match with financial year months order
2530
- */
2531
- var MonthNumberEnum;
2532
- (function (MonthNumberEnum) {
2533
- MonthNumberEnum[MonthNumberEnum["JULY"] = 6] = "JULY";
2534
- MonthNumberEnum[MonthNumberEnum["AUGUST"] = 7] = "AUGUST";
2535
- MonthNumberEnum[MonthNumberEnum["SEPTEMBER"] = 8] = "SEPTEMBER";
2536
- MonthNumberEnum[MonthNumberEnum["OCTOBER"] = 9] = "OCTOBER";
2537
- MonthNumberEnum[MonthNumberEnum["NOVEMBER"] = 10] = "NOVEMBER";
2538
- MonthNumberEnum[MonthNumberEnum["DECEMBER"] = 11] = "DECEMBER";
2539
- MonthNumberEnum[MonthNumberEnum["JANUARY"] = 0] = "JANUARY";
2540
- MonthNumberEnum[MonthNumberEnum["FEBRUARY"] = 1] = "FEBRUARY";
2541
- MonthNumberEnum[MonthNumberEnum["MARCH"] = 2] = "MARCH";
2542
- MonthNumberEnum[MonthNumberEnum["APRIL"] = 3] = "APRIL";
2543
- MonthNumberEnum[MonthNumberEnum["MAY"] = 4] = "MAY";
2544
- MonthNumberEnum[MonthNumberEnum["JUNE"] = 5] = "JUNE";
2545
- })(MonthNumberEnum || (MonthNumberEnum = {}));
2546
-
2547
- const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan'];
2548
-
2549
2642
  class ChartAccountsValue extends ChartAccountsValue$1 {
2550
2643
  }
2551
2644
 
@@ -3109,7 +3202,7 @@ class ChartAccounts extends ChartAccounts$1 {
3109
3202
  * Check if chart accounts id is related for 'Motor Vehicles' category
3110
3203
  */
3111
3204
  isVehicles() {
3112
- return this.id === ChartAccountsListEnum.VEHICLES;
3205
+ return [ChartAccountsListEnum.WORK_VEHICLES, ChartAccountsListEnum.SOLE_VEHICLES].includes(this.id);
3113
3206
  }
3114
3207
  /**
3115
3208
  * Check if chart accounts id is related for 'Interest Earned' category
@@ -4246,15 +4339,6 @@ var PropertyShareStatusEnum;
4246
4339
  PropertyShareStatusEnum[PropertyShareStatusEnum["REJECTED"] = 3] = "REJECTED";
4247
4340
  })(PropertyShareStatusEnum || (PropertyShareStatusEnum = {}));
4248
4341
 
4249
- class RegistrationInvite extends RegistrationInvite$1 {
4250
- getPhotoPlaceholder() {
4251
- return `${this.firstName[0].toUpperCase()}${this.firstName[1]}`;
4252
- }
4253
- getPhoto() {
4254
- return null;
4255
- }
4256
- }
4257
-
4258
4342
  class PropertyShare extends PropertyShare$1 {
4259
4343
  isAccepted() {
4260
4344
  return this.status === PropertyShareStatusEnum.APPROVED;
@@ -7522,40 +7606,204 @@ __decorate([
7522
7606
  Expose()
7523
7607
  ], ServiceSubscription.prototype, "promoCodeId", null);
7524
7608
 
7525
- class User extends User$1 {
7526
- get fullName() {
7527
- return `${this.firstName} ${this.lastName}`;
7528
- }
7529
- get activeSubscription() {
7530
- return this.subscriptions.find((ss) => ss.isActive);
7531
- }
7532
- get lastSubscription() {
7533
- return this.subscriptions[this.subscriptions.length - 1];
7609
+ class ClientMovement extends ClientMovement$1 {
7610
+ }
7611
+ __decorate([
7612
+ Type(() => Firm)
7613
+ ], ClientMovement.prototype, "firm", void 0);
7614
+ __decorate([
7615
+ Type(() => User)
7616
+ ], ClientMovement.prototype, "client", void 0);
7617
+ __decorate([
7618
+ Type(() => User)
7619
+ ], ClientMovement.prototype, "employee", void 0);
7620
+ __decorate([
7621
+ Type(() => ServiceSubscription)
7622
+ ], ClientMovement.prototype, "subscription", void 0);
7623
+ __decorate([
7624
+ Type(() => Date)
7625
+ ], ClientMovement.prototype, "dateFrom", void 0);
7626
+ __decorate([
7627
+ Type(() => Date)
7628
+ ], ClientMovement.prototype, "dateTo", void 0);
7629
+
7630
+ /**
7631
+ * Client portfolio charts data based on ClientPortfolioReportCollection
7632
+ */
7633
+ class ClientPortfolioChartData {
7634
+ constructor(clientsPortfolioReportCollection) {
7635
+ this.clientsPortfolioReportCollection = clientsPortfolioReportCollection;
7534
7636
  }
7535
- /**
7536
- * @TODO refactor
7537
- *
7538
- */
7539
- get position() {
7540
- switch (true) {
7541
- case this.isFirmOwner():
7542
- return USER_WORK_POSITION[UserRolesEnum.FIRM_OWNER];
7543
- case this.isManager():
7544
- return USER_WORK_POSITION[UserRolesEnum.FIRM_MANAGER];
7545
- case this.isEmployee():
7546
- return USER_WORK_POSITION[UserRolesEnum.EMPLOYEE];
7547
- default:
7548
- return '';
7549
- }
7637
+ getPieChartData() {
7638
+ return this.clientsPortfolioReportCollection.items.map((clientPortfolioReport) => plainToClass(ChartData, {
7639
+ name: clientPortfolioReport.category,
7640
+ data: clientPortfolioReport.count
7641
+ }));
7550
7642
  }
7551
- /**
7552
- * search roles including hierarchy
7553
- */
7554
- hasRoles(roles) {
7555
- roles = roles instanceof Array ? roles : [roles];
7556
- if (!roles.length) {
7557
- return true;
7558
- }
7643
+ getBarChartData() {
7644
+ return [
7645
+ plainToClass(ChartData, {
7646
+ name: 'Total',
7647
+ data: [
7648
+ {
7649
+ label: 'Market value',
7650
+ value: this.clientsPortfolioReportCollection.marketValue
7651
+ },
7652
+ {
7653
+ label: 'Loan balance',
7654
+ value: this.clientsPortfolioReportCollection.loanBalance
7655
+ },
7656
+ {
7657
+ label: 'Equity position',
7658
+ value: this.clientsPortfolioReportCollection.equityPosition
7659
+ }
7660
+ ]
7661
+ }),
7662
+ plainToClass(ChartData, {
7663
+ name: 'Average',
7664
+ data: [
7665
+ {
7666
+ label: 'Market value',
7667
+ value: this.clientsPortfolioReportCollection.averageMarketValue
7668
+ },
7669
+ {
7670
+ label: 'Loan balance',
7671
+ value: this.clientsPortfolioReportCollection.averageLoanBalance
7672
+ },
7673
+ {
7674
+ label: 'Equity position',
7675
+ value: this.clientsPortfolioReportCollection.averageEquityPosition
7676
+ }
7677
+ ]
7678
+ })
7679
+ ];
7680
+ }
7681
+ }
7682
+
7683
+ /**
7684
+ * Class describes client's portfolio report information
7685
+ */
7686
+ class ClientPortfolioReport extends AbstractModel {
7687
+ }
7688
+
7689
+ class EmployeeDetails extends EmployeeDetails$1 {
7690
+ }
7691
+ __decorate([
7692
+ Type(() => Firm)
7693
+ ], EmployeeDetails.prototype, "firm", void 0);
7694
+
7695
+ class ServicePayment extends ServicePayment$1 {
7696
+ /**
7697
+ * Stripe stores actual links to payment invoices for 30 days.
7698
+ * Link expires after 30 days
7699
+ */
7700
+ isInvoiceLinkExpired() {
7701
+ const expirationDate = new Date(this.date.setDate(this.date.getDate() + ServicePayment.daysToInvoiceUrlExpired));
7702
+ return expirationDate.getTime() < new Date().getTime();
7703
+ }
7704
+ }
7705
+ ServicePayment.daysToInvoiceUrlExpired = 30;
7706
+ __decorate([
7707
+ Type(() => ServiceSubscription)
7708
+ ], ServicePayment.prototype, "subscription", void 0);
7709
+ __decorate([
7710
+ Type(() => Date)
7711
+ ], ServicePayment.prototype, "date", void 0);
7712
+
7713
+ let ServicePaymentMethod$1 = class ServicePaymentMethod extends AbstractModel {
7714
+ };
7715
+
7716
+ var PaymentMethodBrandEnum;
7717
+ (function (PaymentMethodBrandEnum) {
7718
+ PaymentMethodBrandEnum["UNKNOWN"] = "Unknown";
7719
+ PaymentMethodBrandEnum["AMEX"] = "American Express";
7720
+ PaymentMethodBrandEnum["DINERS"] = "Diners Club";
7721
+ PaymentMethodBrandEnum["DISCOVER"] = "Discover";
7722
+ PaymentMethodBrandEnum["JCB"] = "JCB";
7723
+ PaymentMethodBrandEnum["MASTERCARD"] = "Mastercard";
7724
+ PaymentMethodBrandEnum["UNIONPAY"] = "UnionPay";
7725
+ PaymentMethodBrandEnum["VISA"] = "Visa";
7726
+ })(PaymentMethodBrandEnum || (PaymentMethodBrandEnum = {}));
7727
+
7728
+ var ServicePaymentMethodCardBrandEnum;
7729
+ (function (ServicePaymentMethodCardBrandEnum) {
7730
+ ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["UNKNOWN"] = 0] = "UNKNOWN";
7731
+ ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["AMEX"] = 1] = "AMEX";
7732
+ ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["DINERS"] = 2] = "DINERS";
7733
+ ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["DISCOVER"] = 3] = "DISCOVER";
7734
+ ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["JCB"] = 4] = "JCB";
7735
+ ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["MASTERCARD"] = 5] = "MASTERCARD";
7736
+ ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["UNIONPAY"] = 6] = "UNIONPAY";
7737
+ ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["VISA"] = 7] = "VISA";
7738
+ })(ServicePaymentMethodCardBrandEnum || (ServicePaymentMethodCardBrandEnum = {}));
7739
+
7740
+ var ServicePaymentMethodTypeEnum;
7741
+ (function (ServicePaymentMethodTypeEnum) {
7742
+ ServicePaymentMethodTypeEnum[ServicePaymentMethodTypeEnum["AU_BECS_DEBIT"] = 1] = "AU_BECS_DEBIT";
7743
+ ServicePaymentMethodTypeEnum[ServicePaymentMethodTypeEnum["CARD"] = 2] = "CARD";
7744
+ })(ServicePaymentMethodTypeEnum || (ServicePaymentMethodTypeEnum = {}));
7745
+
7746
+ class ServicePaymentMethod extends ServicePaymentMethod$1 {
7747
+ get logo() {
7748
+ if (!this.isCard()) {
7749
+ return null;
7750
+ }
7751
+ return `/assets/img/payment-methods/${this.cardBrand}.svg`;
7752
+ }
7753
+ get brandName() {
7754
+ return this.isCard() ? PaymentMethodBrandEnum[ServicePaymentMethodCardBrandEnum[this.cardBrand]] : 'BECS Direct Debit (AU)';
7755
+ }
7756
+ /**
7757
+ * Get expiration date formatted string (MM/YY)
7758
+ */
7759
+ get expirationDate() {
7760
+ if (!this.isCard()) {
7761
+ return null;
7762
+ }
7763
+ return `${('0' + this.cardExpirationMonth).slice(-2)}/${this.cardExpirationYear.toString().slice(-2)}`;
7764
+ }
7765
+ get description() {
7766
+ return `${this.brandName} ***${this.lastFourDigits}`;
7767
+ }
7768
+ isCard() {
7769
+ return this.type === ServicePaymentMethodTypeEnum.CARD;
7770
+ }
7771
+ }
7772
+
7773
+ class User extends User$1 {
7774
+ get fullName() {
7775
+ return `${this.firstName} ${this.lastName}`;
7776
+ }
7777
+ get activeSubscription() {
7778
+ return this.subscriptions.find((ss) => ss.isActive);
7779
+ }
7780
+ get lastSubscription() {
7781
+ return this.subscriptions[this.subscriptions.length - 1];
7782
+ }
7783
+ /**
7784
+ * @TODO refactor
7785
+ *
7786
+ */
7787
+ get position() {
7788
+ switch (true) {
7789
+ case this.isFirmOwner():
7790
+ return USER_WORK_POSITION[UserRolesEnum.FIRM_OWNER];
7791
+ case this.isManager():
7792
+ return USER_WORK_POSITION[UserRolesEnum.FIRM_MANAGER];
7793
+ case this.isEmployee():
7794
+ return USER_WORK_POSITION[UserRolesEnum.EMPLOYEE];
7795
+ default:
7796
+ return '';
7797
+ }
7798
+ }
7799
+ /**
7800
+ * search roles including hierarchy
7801
+ */
7802
+ hasRoles(roles) {
7803
+ roles = roles instanceof Array ? roles : [roles];
7804
+ if (!roles.length) {
7805
+ return true;
7806
+ }
7559
7807
  roles = flatten(roles.map((role) => USER_ROLES[role]));
7560
7808
  return !!intersection(this.roles, roles).length;
7561
7809
  }
@@ -7637,6 +7885,13 @@ class User extends User$1 {
7637
7885
  isCurrentFinancialYear() {
7638
7886
  return new FinancialYear(new Date()).year === this.financialYear;
7639
7887
  }
7888
+ /**
7889
+ * financial years available in the app for user
7890
+ * starts from 2022 for new users and registeredYear - 1 for old users
7891
+ */
7892
+ get financialYears() {
7893
+ return range(Math.min(FinancialYear.toFinYear(this.createdAt) - 1, 2022), FinancialYear.toFinYear(new Date()) + 1);
7894
+ }
7640
7895
  }
7641
7896
  __decorate([
7642
7897
  Type(() => ServiceSubscription)
@@ -8509,84 +8764,6 @@ __decorate([
8509
8764
  })
8510
8765
  ], Notification.prototype, "redirectionLink", void 0);
8511
8766
 
8512
- class ServicePayment extends ServicePayment$1 {
8513
- /**
8514
- * Stripe stores actual links to payment invoices for 30 days.
8515
- * Link expires after 30 days
8516
- */
8517
- isInvoiceLinkExpired() {
8518
- const expirationDate = new Date(this.date.setDate(this.date.getDate() + ServicePayment.daysToInvoiceUrlExpired));
8519
- return expirationDate.getTime() < new Date().getTime();
8520
- }
8521
- }
8522
- ServicePayment.daysToInvoiceUrlExpired = 30;
8523
- __decorate([
8524
- Type(() => ServiceSubscription)
8525
- ], ServicePayment.prototype, "subscription", void 0);
8526
- __decorate([
8527
- Type(() => Date)
8528
- ], ServicePayment.prototype, "date", void 0);
8529
-
8530
- let ServicePaymentMethod$1 = class ServicePaymentMethod extends AbstractModel {
8531
- };
8532
-
8533
- var PaymentMethodBrandEnum;
8534
- (function (PaymentMethodBrandEnum) {
8535
- PaymentMethodBrandEnum["UNKNOWN"] = "Unknown";
8536
- PaymentMethodBrandEnum["AMEX"] = "American Express";
8537
- PaymentMethodBrandEnum["DINERS"] = "Diners Club";
8538
- PaymentMethodBrandEnum["DISCOVER"] = "Discover";
8539
- PaymentMethodBrandEnum["JCB"] = "JCB";
8540
- PaymentMethodBrandEnum["MASTERCARD"] = "Mastercard";
8541
- PaymentMethodBrandEnum["UNIONPAY"] = "UnionPay";
8542
- PaymentMethodBrandEnum["VISA"] = "Visa";
8543
- })(PaymentMethodBrandEnum || (PaymentMethodBrandEnum = {}));
8544
-
8545
- var ServicePaymentMethodCardBrandEnum;
8546
- (function (ServicePaymentMethodCardBrandEnum) {
8547
- ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["UNKNOWN"] = 0] = "UNKNOWN";
8548
- ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["AMEX"] = 1] = "AMEX";
8549
- ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["DINERS"] = 2] = "DINERS";
8550
- ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["DISCOVER"] = 3] = "DISCOVER";
8551
- ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["JCB"] = 4] = "JCB";
8552
- ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["MASTERCARD"] = 5] = "MASTERCARD";
8553
- ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["UNIONPAY"] = 6] = "UNIONPAY";
8554
- ServicePaymentMethodCardBrandEnum[ServicePaymentMethodCardBrandEnum["VISA"] = 7] = "VISA";
8555
- })(ServicePaymentMethodCardBrandEnum || (ServicePaymentMethodCardBrandEnum = {}));
8556
-
8557
- var ServicePaymentMethodTypeEnum;
8558
- (function (ServicePaymentMethodTypeEnum) {
8559
- ServicePaymentMethodTypeEnum[ServicePaymentMethodTypeEnum["AU_BECS_DEBIT"] = 1] = "AU_BECS_DEBIT";
8560
- ServicePaymentMethodTypeEnum[ServicePaymentMethodTypeEnum["CARD"] = 2] = "CARD";
8561
- })(ServicePaymentMethodTypeEnum || (ServicePaymentMethodTypeEnum = {}));
8562
-
8563
- class ServicePaymentMethod extends ServicePaymentMethod$1 {
8564
- get logo() {
8565
- if (!this.isCard()) {
8566
- return null;
8567
- }
8568
- return `/assets/img/payment-methods/${this.cardBrand}.svg`;
8569
- }
8570
- get brandName() {
8571
- return this.isCard() ? PaymentMethodBrandEnum[ServicePaymentMethodCardBrandEnum[this.cardBrand]] : 'BECS Direct Debit (AU)';
8572
- }
8573
- /**
8574
- * Get expiration date formatted string (MM/YY)
8575
- */
8576
- get expirationDate() {
8577
- if (!this.isCard()) {
8578
- return null;
8579
- }
8580
- return `${('0' + this.cardExpirationMonth).slice(-2)}/${this.cardExpirationYear.toString().slice(-2)}`;
8581
- }
8582
- get description() {
8583
- return `${this.brandName} ***${this.lastFourDigits}`;
8584
- }
8585
- isCard() {
8586
- return this.type === ServicePaymentMethodTypeEnum.CARD;
8587
- }
8588
- }
8589
-
8590
8767
  /**
8591
8768
  * Enum with document types which used to API url prefix
8592
8769
  */
@@ -8823,174 +9000,6 @@ __decorate([
8823
9000
  Type(() => HoldingType)
8824
9001
  ], HoldingReinvest.prototype, "holdingType", void 0);
8825
9002
 
8826
- class AnnualClientDetails extends AbstractModel {
8827
- constructor() {
8828
- super(...arguments);
8829
- this.financialYear = new FinancialYear().year;
8830
- }
8831
- }
8832
- __decorate([
8833
- Type(() => ClientDetails)
8834
- ], AnnualClientDetails.prototype, "clientDetails", void 0);
8835
-
8836
- class ClientIncomeTypes extends ClientIncomeTypes$1 {
8837
- /**
8838
- * Get count of selected income types
8839
- */
8840
- get length() {
8841
- return Object.values(this).filter((value) => typeof value === 'boolean' && value).length;
8842
- }
8843
- }
8844
-
8845
- var ClientInviteStatusEnum;
8846
- (function (ClientInviteStatusEnum) {
8847
- ClientInviteStatusEnum[ClientInviteStatusEnum["PENDING"] = 1] = "PENDING";
8848
- ClientInviteStatusEnum[ClientInviteStatusEnum["REJECTED"] = 2] = "REJECTED";
8849
- })(ClientInviteStatusEnum || (ClientInviteStatusEnum = {}));
8850
-
8851
- var ClientInviteTypeEnum;
8852
- (function (ClientInviteTypeEnum) {
8853
- ClientInviteTypeEnum[ClientInviteTypeEnum["FROM_CLIENT"] = 1] = "FROM_CLIENT";
8854
- ClientInviteTypeEnum[ClientInviteTypeEnum["FROM_EMPLOYEE"] = 2] = "FROM_EMPLOYEE";
8855
- })(ClientInviteTypeEnum || (ClientInviteTypeEnum = {}));
8856
-
8857
- class ClientInvite extends ClientInvite$1 {
8858
- /**
8859
- * Check if client invite status is pending
8860
- */
8861
- isPending() {
8862
- return this.status === ClientInviteStatusEnum.PENDING;
8863
- }
8864
- /**
8865
- * Check if client invite status is accepted
8866
- */
8867
- isAccepted() {
8868
- return !this.isPending() && !this.isRejected();
8869
- }
8870
- /**
8871
- * Check if client invite status is rejected
8872
- */
8873
- isRejected() {
8874
- return this.status === ClientInviteStatusEnum.REJECTED;
8875
- }
8876
- /**
8877
- * Check if client invite initiated by firm
8878
- */
8879
- isFromEmployee() {
8880
- return this.type === ClientInviteTypeEnum.FROM_EMPLOYEE;
8881
- }
8882
- /**
8883
- * Check if client invite initiated by client
8884
- */
8885
- isFromClient() {
8886
- return this.type === ClientInviteTypeEnum.FROM_CLIENT;
8887
- }
8888
- get firstName() {
8889
- return this.client ? this.client.firstName : this.registrationInvite?.firstName;
8890
- }
8891
- get email() {
8892
- return this.client ? this.client.email : this.registrationInvite?.email;
8893
- }
8894
- }
8895
- __decorate([
8896
- Type(() => Date)
8897
- ], ClientInvite.prototype, "sentOn", void 0);
8898
- __decorate([
8899
- Type(() => Date)
8900
- ], ClientInvite.prototype, "updatedAt", void 0);
8901
- __decorate([
8902
- Type(() => Firm)
8903
- ], ClientInvite.prototype, "firm", void 0);
8904
- __decorate([
8905
- Type(() => User)
8906
- ], ClientInvite.prototype, "client", void 0);
8907
- __decorate([
8908
- Type(() => User)
8909
- ], ClientInvite.prototype, "employee", void 0);
8910
- __decorate([
8911
- Type(() => RegistrationInvite)
8912
- ], ClientInvite.prototype, "registrationInvite", void 0);
8913
-
8914
- class ClientMovement extends ClientMovement$1 {
8915
- }
8916
- __decorate([
8917
- Type(() => Firm)
8918
- ], ClientMovement.prototype, "firm", void 0);
8919
- __decorate([
8920
- Type(() => User)
8921
- ], ClientMovement.prototype, "client", void 0);
8922
- __decorate([
8923
- Type(() => User)
8924
- ], ClientMovement.prototype, "employee", void 0);
8925
- __decorate([
8926
- Type(() => ServiceSubscription)
8927
- ], ClientMovement.prototype, "subscription", void 0);
8928
- __decorate([
8929
- Type(() => Date)
8930
- ], ClientMovement.prototype, "dateFrom", void 0);
8931
- __decorate([
8932
- Type(() => Date)
8933
- ], ClientMovement.prototype, "dateTo", void 0);
8934
-
8935
- /**
8936
- * Client portfolio charts data based on ClientPortfolioReportCollection
8937
- */
8938
- class ClientPortfolioChartData {
8939
- constructor(clientsPortfolioReportCollection) {
8940
- this.clientsPortfolioReportCollection = clientsPortfolioReportCollection;
8941
- }
8942
- getPieChartData() {
8943
- return this.clientsPortfolioReportCollection.items.map((clientPortfolioReport) => plainToClass(ChartData, {
8944
- name: clientPortfolioReport.category,
8945
- data: clientPortfolioReport.count
8946
- }));
8947
- }
8948
- getBarChartData() {
8949
- return [
8950
- plainToClass(ChartData, {
8951
- name: 'Total',
8952
- data: [
8953
- {
8954
- label: 'Market value',
8955
- value: this.clientsPortfolioReportCollection.marketValue
8956
- },
8957
- {
8958
- label: 'Loan balance',
8959
- value: this.clientsPortfolioReportCollection.loanBalance
8960
- },
8961
- {
8962
- label: 'Equity position',
8963
- value: this.clientsPortfolioReportCollection.equityPosition
8964
- }
8965
- ]
8966
- }),
8967
- plainToClass(ChartData, {
8968
- name: 'Average',
8969
- data: [
8970
- {
8971
- label: 'Market value',
8972
- value: this.clientsPortfolioReportCollection.averageMarketValue
8973
- },
8974
- {
8975
- label: 'Loan balance',
8976
- value: this.clientsPortfolioReportCollection.averageLoanBalance
8977
- },
8978
- {
8979
- label: 'Equity position',
8980
- value: this.clientsPortfolioReportCollection.averageEquityPosition
8981
- }
8982
- ]
8983
- })
8984
- ];
8985
- }
8986
- }
8987
-
8988
- /**
8989
- * Class describes client's portfolio report information
8990
- */
8991
- class ClientPortfolioReport extends AbstractModel {
8992
- }
8993
-
8994
9003
  const NAME_TOKEN = 'token';
8995
9004
  const NAME_REFRESH_TOKEN = 'refreshToken';
8996
9005
  class JwtService extends JwtHelperService {