taxtank-core 0.32.126 → 0.32.128

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. package/esm2022/lib/db/Models/incomeSource/income-source-forecast.mjs +1 -1
  2. package/esm2022/lib/db/Models/incomeSource/salary-forecast.mjs +1 -1
  3. package/esm2022/lib/db/Models/property/property-forecast.mjs +1 -1
  4. package/esm2022/lib/db/Models/sole/sole-business-loss.mjs +1 -1
  5. package/esm2022/lib/db/Models/sole/sole-forecast.mjs +1 -1
  6. package/esm2022/lib/db/Models/vehicle/vehicle-claim-details.mjs +1 -1
  7. package/esm2022/lib/models/client/capital-loss.interface.mjs +1 -1
  8. package/esm2022/lib/models/client/capital-loss.mjs +1 -5
  9. package/esm2022/lib/models/income-source/salary-forecast.mjs +1 -5
  10. package/esm2022/lib/models/income-source/sole-forecast.mjs +1 -5
  11. package/esm2022/lib/models/property/property-forecast.mjs +2 -6
  12. package/esm2022/lib/models/property/property.mjs +4 -2
  13. package/esm2022/lib/models/sole/sole-business-loss.mjs +1 -5
  14. package/fesm2022/taxtank-core.mjs +1079 -1093
  15. package/fesm2022/taxtank-core.mjs.map +1 -1
  16. package/lib/db/Models/incomeSource/income-source-forecast.d.ts +1 -1
  17. package/lib/db/Models/incomeSource/salary-forecast.d.ts +1 -2
  18. package/lib/db/Models/property/property-forecast.d.ts +1 -2
  19. package/lib/db/Models/sole/sole-business-loss.d.ts +1 -2
  20. package/lib/db/Models/sole/sole-forecast.d.ts +1 -2
  21. package/lib/db/Models/vehicle/vehicle-claim-details.d.ts +1 -1
  22. package/lib/models/client/capital-loss.d.ts +0 -2
  23. package/lib/models/client/capital-loss.interface.d.ts +1 -1
  24. package/lib/models/income-source/salary-forecast.d.ts +0 -2
  25. package/lib/models/income-source/sole-forecast.d.ts +0 -2
  26. package/lib/models/property/property-forecast.d.ts +0 -2
  27. package/lib/models/sole/sole-business-loss.d.ts +0 -2
  28. package/package.json +1 -1
@@ -20,9 +20,9 @@ import orderBy from 'lodash/orderBy';
20
20
  import uniq from 'lodash/uniq';
21
21
  import moment from 'moment';
22
22
  import { DateRange } from 'moment-range';
23
- import { Validators, FormGroup, FormArray, UntypedFormControl, UntypedFormArray, UntypedFormGroup, FormControl } from '@angular/forms';
24
23
  import ceil from 'lodash/ceil';
25
24
  import range from 'lodash/range';
25
+ import { Validators, FormGroup, FormArray, UntypedFormControl, UntypedFormArray, UntypedFormGroup, FormControl } from '@angular/forms';
26
26
  import compact from 'lodash/compact';
27
27
  import concat from 'lodash/concat';
28
28
  import cloneDeep$1 from 'lodash/cloneDeep';
@@ -3728,400 +3728,796 @@ var SalaryForecastFrequencyEnum;
3728
3728
  SalaryForecastFrequencyEnum[SalaryForecastFrequencyEnum["WEEKLY"] = 52] = "WEEKLY";
3729
3729
  })(SalaryForecastFrequencyEnum || (SalaryForecastFrequencyEnum = {}));
3730
3730
 
3731
- var MyAccountHistoryInitiatedByEnum;
3732
- (function (MyAccountHistoryInitiatedByEnum) {
3733
- MyAccountHistoryInitiatedByEnum[MyAccountHistoryInitiatedByEnum["OWNER"] = 0] = "OWNER";
3734
- MyAccountHistoryInitiatedByEnum[MyAccountHistoryInitiatedByEnum["ACCOUNTANT"] = 1] = "ACCOUNTANT";
3735
- })(MyAccountHistoryInitiatedByEnum || (MyAccountHistoryInitiatedByEnum = {}));
3736
-
3737
- var MyAccountHistoryStatusEnum;
3738
- (function (MyAccountHistoryStatusEnum) {
3739
- MyAccountHistoryStatusEnum[MyAccountHistoryStatusEnum["SUCCESS"] = 0] = "SUCCESS";
3740
- MyAccountHistoryStatusEnum[MyAccountHistoryStatusEnum["ERROR"] = 1] = "ERROR";
3741
- })(MyAccountHistoryStatusEnum || (MyAccountHistoryStatusEnum = {}));
3742
-
3743
- var MyAccountHistoryTypeEnum;
3744
- (function (MyAccountHistoryTypeEnum) {
3745
- MyAccountHistoryTypeEnum[MyAccountHistoryTypeEnum["REVIEW"] = 0] = "REVIEW";
3746
- MyAccountHistoryTypeEnum[MyAccountHistoryTypeEnum["UPGRADE_PLAN"] = 1] = "UPGRADE_PLAN";
3747
- MyAccountHistoryTypeEnum[MyAccountHistoryTypeEnum["UPLOAD_DOCUMENT"] = 2] = "UPLOAD_DOCUMENT";
3748
- })(MyAccountHistoryTypeEnum || (MyAccountHistoryTypeEnum = {}));
3749
-
3750
- class MyAccountHistory {
3731
+ class SalaryForecast extends SalaryForecast$1 {
3732
+ get grossAmount() {
3733
+ return this.netPay + this.tax;
3734
+ }
3735
+ get taxWithheld() {
3736
+ return this.grossAmount - this.netPay;
3737
+ }
3738
+ get monthlyAmount() {
3739
+ switch (this.frequency) {
3740
+ case SalaryForecastFrequencyEnum.ANNUAL:
3741
+ return this.netPay / FinancialYear.monthsInYear;
3742
+ case SalaryForecastFrequencyEnum.FORTNIGHTLY:
3743
+ return this.netPay * FinancialYear.weeksInYear / FinancialYear.monthsInYear / 2;
3744
+ case SalaryForecastFrequencyEnum.WEEKLY:
3745
+ return this.netPay * FinancialYear.weeksInYear / FinancialYear.monthsInYear;
3746
+ default:
3747
+ return this.netPay;
3748
+ }
3749
+ }
3751
3750
  }
3751
+ __decorate([
3752
+ Type(() => Number)
3753
+ ], SalaryForecast.prototype, "tax", void 0);
3754
+ __decorate([
3755
+ Type(() => Number)
3756
+ ], SalaryForecast.prototype, "netPay", void 0);
3757
+ __decorate([
3758
+ Type(() => IncomeSource)
3759
+ ], SalaryForecast.prototype, "incomeSource", void 0);
3752
3760
 
3753
- class Occupation extends Occupation$1 {
3761
+ class SoleForecast extends SoleForecast$1 {
3762
+ get netPay() {
3763
+ return this.amount;
3764
+ }
3754
3765
  }
3766
+ __decorate([
3767
+ Type(() => IncomeSource)
3768
+ ], SoleForecast.prototype, "incomeSource", void 0);
3755
3769
 
3756
- var UserRolesEnum;
3757
- (function (UserRolesEnum) {
3758
- UserRolesEnum["FIRM_OWNER"] = "ROLE_FIRM_OWNER";
3759
- UserRolesEnum["FIRM_MANAGER"] = "ROLE_FIRM_MANAGER";
3760
- UserRolesEnum["FIRM_TOP_MANAGER"] = "ROLE_FIRM_TOP_MANAGER";
3761
- UserRolesEnum["CLIENT"] = "ROLE_CLIENT";
3762
- UserRolesEnum["EMPLOYEE"] = "ROLE_EMPLOYEE";
3763
- UserRolesEnum["ACCOUNTANT"] = "ROLE_ACCOUNTANT";
3764
- UserRolesEnum["ADVISOR"] = "ROLE_ADVISOR";
3765
- UserRolesEnum["USER"] = "ROLE_USER";
3766
- UserRolesEnum["SUBSCRIPTION"] = "ROLE_USER_SUBSCRIPTION";
3767
- UserRolesEnum["WORK_TANK"] = "ROLE_USER_WORK";
3768
- UserRolesEnum["PROPERTY_TANK"] = "ROLE_USER_PROPERTY";
3769
- UserRolesEnum["SOLE_TANK"] = "ROLE_USER_SOLE";
3770
- UserRolesEnum["HOLDING_TANK"] = "ROLE_USER_HOLDING";
3771
- UserRolesEnum["SWITCH_USER"] = "IS_IMPERSONATOR";
3772
- })(UserRolesEnum || (UserRolesEnum = {}));
3770
+ var IncomeSourceForecastTrustTypeEnum;
3771
+ (function (IncomeSourceForecastTrustTypeEnum) {
3772
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["SPECIAL_DISABILITY_TRUST"] = 1] = "SPECIAL_DISABILITY_TRUST";
3773
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["DECEASED_ESTATE"] = 2] = "DECEASED_ESTATE";
3774
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["FIXED_TRUST"] = 3] = "FIXED_TRUST";
3775
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["HYBRID_TRUST"] = 4] = "HYBRID_TRUST";
3776
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["DISCRETIONARY_SERVICE_TRUST"] = 5] = "DISCRETIONARY_SERVICE_TRUST";
3777
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["DISCRETIONARY_TRADING_TRUST"] = 6] = "DISCRETIONARY_TRADING_TRUST";
3778
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["DISCRETIONARY_INVESTMENT_TRUST"] = 7] = "DISCRETIONARY_INVESTMENT_TRUST";
3779
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["CASH_MANAGEMENT_UNIT_TRUST"] = 8] = "CASH_MANAGEMENT_UNIT_TRUST";
3780
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["PUBLIC_UNIT_TRUST_LISTED"] = 9] = "PUBLIC_UNIT_TRUST_LISTED";
3781
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["PUBLIC_UNIT_TRUST_UNLISTED"] = 10] = "PUBLIC_UNIT_TRUST_UNLISTED";
3782
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["TESTAMENTARY_TRUST"] = 11] = "TESTAMENTARY_TRUST";
3783
+ })(IncomeSourceForecastTrustTypeEnum || (IncomeSourceForecastTrustTypeEnum = {}));
3773
3784
 
3774
- /**
3775
- * role hierarchy
3776
- */
3777
- const USER_ROLES = {
3778
- ROLE_FIRM_OWNER: [UserRolesEnum.FIRM_OWNER, UserRolesEnum.FIRM_MANAGER, UserRolesEnum.ACCOUNTANT, UserRolesEnum.ADVISOR],
3779
- ROLE_FIRM_MANAGER: [UserRolesEnum.FIRM_MANAGER, UserRolesEnum.ACCOUNTANT, UserRolesEnum.ADVISOR],
3780
- ROLE_EMPLOYEE: [UserRolesEnum.ACCOUNTANT, UserRolesEnum.ADVISOR],
3781
- ROLE_ACCOUNTANT: [UserRolesEnum.ACCOUNTANT],
3782
- ROLE_ADVISOR: [UserRolesEnum.ADVISOR],
3783
- // @TODO makes no sense, these roles can't be hierarchical
3784
- ROLE_CLIENT: [UserRolesEnum.CLIENT],
3785
- ROLE_USER_SUBSCRIPTION: [UserRolesEnum.SUBSCRIPTION],
3786
- ROLE_USER_WORK: [UserRolesEnum.WORK_TANK],
3787
- ROLE_USER_PROPERTY: [UserRolesEnum.PROPERTY_TANK],
3788
- ROLE_USER_SOLE: [UserRolesEnum.SOLE_TANK],
3789
- ROLE_USER_HOLDING: [UserRolesEnum.HOLDING_TANK],
3790
- ROLE_PREVIOUS_ADMIN: [UserRolesEnum.SWITCH_USER],
3791
- };
3785
+ var IncomeSourceTypeListOtherEnum;
3786
+ (function (IncomeSourceTypeListOtherEnum) {
3787
+ IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["PSI"] = 6] = "PSI";
3788
+ IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
3789
+ IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["TRUSTS"] = 9] = "TRUSTS";
3790
+ IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["OTHER_INCOME"] = 10] = "OTHER_INCOME";
3791
+ IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["PARTNERSHIPS"] = 12] = "PARTNERSHIPS";
3792
+ })(IncomeSourceTypeListOtherEnum || (IncomeSourceTypeListOtherEnum = {}));
3792
3793
 
3793
- /**
3794
- * Class with basic information about registering user
3795
- */
3796
- class UserToRegister {
3797
- }
3794
+ var IncomeSourceTypeListSoleEnum;
3795
+ (function (IncomeSourceTypeListSoleEnum) {
3796
+ IncomeSourceTypeListSoleEnum[IncomeSourceTypeListSoleEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
3797
+ })(IncomeSourceTypeListSoleEnum || (IncomeSourceTypeListSoleEnum = {}));
3798
3798
 
3799
- const USER_WORK_POSITION = {
3800
- [UserRolesEnum.EMPLOYEE]: 'Employee',
3801
- [UserRolesEnum.FIRM_MANAGER]: 'Manager',
3802
- [UserRolesEnum.FIRM_OWNER]: 'Firm Owner'
3803
- };
3799
+ var IncomeSourceTypeListWorkEnum;
3800
+ (function (IncomeSourceTypeListWorkEnum) {
3801
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["BONUSES"] = 1] = "BONUSES";
3802
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["DIRECTOR_FEES"] = 2] = "DIRECTOR_FEES";
3803
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["INTEREST"] = 4] = "INTEREST";
3804
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["PENSIONS_AND_ALLOWANCES"] = 5] = "PENSIONS_AND_ALLOWANCES";
3805
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["SUPERANNUATION"] = 8] = "SUPERANNUATION";
3806
+ IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["ATTRIBUTED_P_S_I"] = 11] = "ATTRIBUTED_P_S_I";
3807
+ })(IncomeSourceTypeListWorkEnum || (IncomeSourceTypeListWorkEnum = {}));
3804
3808
 
3805
- var UserStatusEnum;
3806
- (function (UserStatusEnum) {
3807
- UserStatusEnum[UserStatusEnum["INACTIVE"] = 0] = "INACTIVE";
3808
- UserStatusEnum[UserStatusEnum["ON_BOARDING"] = 1] = "ON_BOARDING";
3809
- UserStatusEnum[UserStatusEnum["ACTIVE"] = 2] = "ACTIVE";
3810
- })(UserStatusEnum || (UserStatusEnum = {}));
3809
+ var IncomeSourceTypeListHoldingEnum;
3810
+ (function (IncomeSourceTypeListHoldingEnum) {
3811
+ IncomeSourceTypeListHoldingEnum[IncomeSourceTypeListHoldingEnum["DIVIDENDS"] = 3] = "DIVIDENDS";
3812
+ IncomeSourceTypeListHoldingEnum[IncomeSourceTypeListHoldingEnum["INTEREST"] = 4] = "INTEREST";
3813
+ IncomeSourceTypeListHoldingEnum[IncomeSourceTypeListHoldingEnum["TRUSTS"] = 9] = "TRUSTS";
3814
+ IncomeSourceTypeListHoldingEnum[IncomeSourceTypeListHoldingEnum["OTHER_INCOME"] = 10] = "OTHER_INCOME";
3815
+ IncomeSourceTypeListHoldingEnum[IncomeSourceTypeListHoldingEnum["PARTNERSHIPS"] = 12] = "PARTNERSHIPS";
3816
+ })(IncomeSourceTypeListHoldingEnum || (IncomeSourceTypeListHoldingEnum = {}));
3811
3817
 
3812
- class ClientDetails extends ClientDetails$1 {
3813
- /**
3814
- * reminder to sign basiq consent after x days before the expiration
3815
- */
3816
- static { this.consentExpiryReminderDays = 30; }
3817
- get taxFileNumberMasked() {
3818
- const maskedLength = this.taxFileNumber.length - 4;
3819
- const maskedPart = '*'.repeat(maskedLength);
3820
- const lastFour = this.taxFileNumber.slice(-4);
3821
- return maskedPart + lastFour;
3818
+ class IncomeSourceType extends IncomeSourceType$1 {
3819
+ isBonuses() {
3820
+ return this.id === IncomeSourceTypeListWorkEnum.BONUSES;
3822
3821
  }
3823
- isBasiqConsentExpiring() {
3824
- if (!this.basiqConsentExpiryDate || this.isBasiqConsentExpired()) {
3825
- return false;
3826
- }
3827
- const reminderDate = new Date(this.basiqConsentExpiryDate);
3828
- reminderDate.setDate(this.basiqConsentExpiryDate.getDate() - ClientDetails.consentExpiryReminderDays);
3829
- return new Date() >= reminderDate;
3822
+ isWork() {
3823
+ return !!IncomeSourceTypeListWorkEnum[this.id];
3830
3824
  }
3831
- isBasiqConsentExpired() {
3832
- return this.basiqConsentExpiryDate && new Date() >= this.basiqConsentExpiryDate;
3825
+ isOther() {
3826
+ return !!IncomeSourceTypeListOtherEnum[this.id];
3827
+ }
3828
+ isHolding() {
3829
+ return !!IncomeSourceTypeListHoldingEnum[this.id];
3830
+ }
3831
+ isSole() {
3832
+ return !!IncomeSourceTypeListSoleEnum[this.id];
3833
3833
  }
3834
3834
  }
3835
- __decorate([
3836
- Type(() => Date)
3837
- ], ClientDetails.prototype, "basiqConsentExpiryDate", void 0);
3838
3835
 
3839
- class AnnualClientDetails extends AbstractModel {
3836
+ class IncomeSourceForecast extends IncomeSourceForecast$1 {
3840
3837
  constructor() {
3841
3838
  super(...arguments);
3842
- this.spouseAnnualIncome = 0;
3843
- this.financialYear = new FinancialYear().year;
3839
+ this.paygIncome = 0;
3840
+ this.frequency = SalaryForecastFrequencyEnum.ANNUAL;
3841
+ this.isTaxFree = false;
3844
3842
  }
3845
- get spouseMonthlyIncome() {
3846
- return this.spouseAnnualIncome / 12;
3843
+ /**
3844
+ * Sometimes Income source has Salary & Income source forecasts,
3845
+ * and we need these fields to work with Income source forecasts like with Salary Forecasts
3846
+ */
3847
+ get netPay() {
3848
+ return this.amount;
3847
3849
  }
3848
- }
3849
- __decorate([
3850
- Type(() => ClientDetails)
3851
- ], AnnualClientDetails.prototype, "clientDetails", void 0);
3852
-
3853
- var ClientInviteStatusEnum;
3854
- (function (ClientInviteStatusEnum) {
3855
- ClientInviteStatusEnum[ClientInviteStatusEnum["PENDING"] = 1] = "PENDING";
3856
- ClientInviteStatusEnum[ClientInviteStatusEnum["REJECTED"] = 2] = "REJECTED";
3857
- })(ClientInviteStatusEnum || (ClientInviteStatusEnum = {}));
3858
-
3859
- var ClientInviteTypeEnum;
3860
- (function (ClientInviteTypeEnum) {
3861
- ClientInviteTypeEnum[ClientInviteTypeEnum["FROM_CLIENT"] = 1] = "FROM_CLIENT";
3862
- ClientInviteTypeEnum[ClientInviteTypeEnum["FROM_EMPLOYEE"] = 2] = "FROM_EMPLOYEE";
3863
- })(ClientInviteTypeEnum || (ClientInviteTypeEnum = {}));
3864
-
3865
- class RegistrationInvite extends RegistrationInvite$1 {
3866
- get fullName() {
3867
- return `${this.firstName} ${this.lastName}`;
3850
+ get grossAmount() {
3851
+ return this.amount + this.tax + this.taxInstalments + this.frankingCredits;
3852
+ }
3853
+ get monthlyAmount() {
3854
+ return this.amount / 12;
3868
3855
  }
3869
3856
  }
3870
3857
  __decorate([
3871
- Type(() => AppFile)
3872
- ], RegistrationInvite.prototype, "file", void 0);
3858
+ Type(() => IncomeSourceType)
3859
+ ], IncomeSourceForecast.prototype, "incomeSourceType", void 0);
3873
3860
  __decorate([
3874
- Type(() => User)
3875
- ], RegistrationInvite.prototype, "user", void 0);
3876
-
3877
- var PhoneTypeEnum;
3878
- (function (PhoneTypeEnum) {
3879
- PhoneTypeEnum[PhoneTypeEnum["MOBILE"] = 1] = "MOBILE";
3880
- PhoneTypeEnum[PhoneTypeEnum["OFFICE"] = 2] = "OFFICE";
3881
- })(PhoneTypeEnum || (PhoneTypeEnum = {}));
3861
+ Type(() => IncomeSource)
3862
+ ], IncomeSourceForecast.prototype, "incomeSource", void 0);
3882
3863
 
3883
- class Phone extends Phone$1 {
3884
- constructor() {
3885
- super(...arguments);
3886
- this.country = Country.australia;
3887
- this.type = PhoneTypeEnum.MOBILE;
3864
+ class IncomeSource extends IncomeSource$1 {
3865
+ isSoleIncome() {
3866
+ return this.type === IncomeSourceTypeEnum.SOLE;
3888
3867
  }
3889
- toString() {
3890
- return `+${this.country.callingCode} ${this.number}`;
3868
+ isWorkIncome() {
3869
+ return this.type === IncomeSourceTypeEnum.WORK;
3891
3870
  }
3892
- }
3893
- __decorate([
3894
- Type(() => Country)
3895
- ], Phone.prototype, "country", void 0);
3896
-
3897
- class Firm extends Firm$1 {
3898
- isAccountant() {
3899
- return this.type === FirmTypeEnum.ACCOUNTANT;
3871
+ isOtherIncome() {
3872
+ return this.type === IncomeSourceTypeEnum.OTHER;
3873
+ }
3874
+ isHolding() {
3875
+ return this.type === IncomeSourceTypeEnum.HOLDING;
3876
+ }
3877
+ /**
3878
+ * Get salary and other income forecasts
3879
+ */
3880
+ get forecasts() {
3881
+ return [...this.salaryForecasts, ...this.incomeSourceForecasts, ...this.soleForecasts];
3882
+ }
3883
+ /**
3884
+ * Get actual (1st from the list) forecast
3885
+ */
3886
+ get actualForecast() {
3887
+ return this.forecasts[0];
3888
+ }
3889
+ /**
3890
+ * Check if user was working in month taken by the index
3891
+ * @param monthIndex by which month should be taken
3892
+ */
3893
+ isWorkedInMonth(monthIndex) {
3894
+ const monthDate = new FinancialYear().getMonthDate(monthIndex);
3895
+ return (!this.dateFrom || monthDate >= this.dateFrom) && (!this.dateTo || monthDate < this.dateTo);
3900
3896
  }
3901
3897
  }
3902
3898
  __decorate([
3903
- Type(() => User)
3904
- ], Firm.prototype, "owner", void 0);
3905
- __decorate([
3906
- Type(() => Address)
3907
- ], Firm.prototype, "address", void 0);
3908
- __decorate([
3909
- Type(() => Phone)
3910
- ], Firm.prototype, "phone", void 0);
3899
+ Type(() => SalaryForecast)
3900
+ ], IncomeSource.prototype, "salaryForecasts", void 0);
3911
3901
  __decorate([
3912
- Type(() => AppFile)
3913
- ], Firm.prototype, "file", void 0);
3914
-
3915
- class FirmBranch extends AbstractModel {
3916
- constructor() {
3917
- super(...arguments);
3918
- this.isMain = false;
3919
- }
3920
- }
3902
+ Type(() => SoleForecast)
3903
+ ], IncomeSource.prototype, "soleForecasts", void 0);
3921
3904
  __decorate([
3922
- Type(() => Firm)
3923
- ], FirmBranch.prototype, "firm", void 0);
3905
+ Type(() => IncomeSourceForecast)
3906
+ ], IncomeSource.prototype, "incomeSourceForecasts", void 0);
3924
3907
  __decorate([
3925
- Type(() => Address)
3926
- ], FirmBranch.prototype, "address", void 0);
3908
+ Type(() => Date)
3909
+ ], IncomeSource.prototype, "dateFrom", void 0);
3927
3910
  __decorate([
3928
- Type(() => Phone)
3929
- ], FirmBranch.prototype, "phone", void 0);
3911
+ Type(() => Date)
3912
+ ], IncomeSource.prototype, "dateTo", void 0);
3930
3913
 
3931
- class ClientInvite extends ClientInvite$1 {
3932
- /**
3933
- * Check if client invite status is pending
3934
- */
3935
- isPending() {
3936
- return this.status === ClientInviteStatusEnum.PENDING;
3914
+ /**
3915
+ * Income sources chart data
3916
+ */
3917
+ class IncomeSourceChartData {
3918
+ constructor(forecastedIncomeAmount, transactions) {
3919
+ this.forecastedIncomeAmount = forecastedIncomeAmount;
3920
+ this.transactions = transactions;
3937
3921
  }
3938
3922
  /**
3939
- * Check if client invite status is accepted
3923
+ * Get prepared data for income sources chart
3940
3924
  */
3941
- isAccepted() {
3942
- return !this.isPending() && !this.isRejected();
3925
+ get() {
3926
+ const chartData = [{
3927
+ id: 'actualIncome',
3928
+ name: 'Actual Income',
3929
+ data: [],
3930
+ // display future actual incomes with dash line and past actual incomes with solid line
3931
+ zones: [{
3932
+ // line style after current month
3933
+ value: new FinancialYear().getMonthDate(new Date().getMonth()).getTime(),
3934
+ dashStyle: 'Solid'
3935
+ }, {
3936
+ // default line style
3937
+ dashStyle: 'Dash'
3938
+ }]
3939
+ }, {
3940
+ id: 'forecastedIncome',
3941
+ name: 'Forecasted Income',
3942
+ data: [],
3943
+ }];
3944
+ for (const key in MonthNameShortEnum) {
3945
+ if (MonthNameShortEnum.hasOwnProperty(key)) {
3946
+ // transaction collection for provided month
3947
+ const monthTransactionCollection = this.transactions.getByMonth(+MonthNumberEnum[key]);
3948
+ chartData[0].data.push([new FinancialYear().getMonthDate(+MonthNumberEnum[key]).getTime(), monthTransactionCollection.amount]);
3949
+ chartData[1].data.push([new FinancialYear().getMonthDate(+MonthNumberEnum[key]).getTime(), this.forecastedIncomeAmount / 12]);
3950
+ }
3951
+ }
3952
+ return chartData;
3943
3953
  }
3944
- /**
3945
- * Check if client invite status is rejected
3946
- */
3947
- isRejected() {
3948
- return this.status === ClientInviteStatusEnum.REJECTED;
3954
+ }
3955
+
3956
+ var TransactionSourceEnum;
3957
+ (function (TransactionSourceEnum) {
3958
+ TransactionSourceEnum[TransactionSourceEnum["CASH"] = 1] = "CASH";
3959
+ TransactionSourceEnum[TransactionSourceEnum["BANK_TRANSACTION"] = 2] = "BANK_TRANSACTION";
3960
+ })(TransactionSourceEnum || (TransactionSourceEnum = {}));
3961
+
3962
+ class AllocationRuleTransaction extends AllocationRuleTransaction$1 {
3963
+ constructor() {
3964
+ super(...arguments);
3965
+ this.claimPercent = 100;
3966
+ this.tax = 0;
3967
+ this.amount = null;
3968
+ }
3969
+ get amountPercentCoefficient() {
3970
+ return this.amountPercent ? this.amountPercent / 100 : 1;
3971
+ }
3972
+ calculateClaimPercent() {
3973
+ if (!this.chartAccounts) {
3974
+ return null;
3975
+ }
3976
+ let claimPercent = this.chartAccounts.taxablePercent;
3977
+ // Property claim (ownership% x shared%) for property expenses, taxable percent for others
3978
+ if (this.chartAccounts?.isProperty() && this.property) {
3979
+ if (this.chartAccounts.isPropertyExpense() && this.chartAccounts.id !== ChartAccountsListEnum.PLATFORM_FEES) {
3980
+ claimPercent *= this.property?.claimCoefficient;
3981
+ }
3982
+ }
3983
+ return claimPercent;
3949
3984
  }
3950
3985
  /**
3951
- * Check if client invite initiated by firm
3986
+ * If rule transaction has amount then split enabled. There is 0 when split disabled
3952
3987
  */
3953
- isFromEmployee() {
3954
- return this.type === ClientInviteTypeEnum.FROM_EMPLOYEE;
3988
+ isSplit() {
3989
+ return !!this.amountPercent;
3955
3990
  }
3956
3991
  /**
3957
- * Check if client invite initiated by client
3992
+ * Create Transaction instance based on passed bank transaction and rule transaction
3958
3993
  */
3959
- isFromClient() {
3960
- return this.type === ClientInviteTypeEnum.FROM_CLIENT;
3961
- }
3962
- get firstName() {
3963
- return this.client ? this.client.firstName : this.registrationInvite?.firstName;
3964
- }
3965
- get fullName() {
3966
- return this.client ? this.client.fullName : this.registrationInvite?.fullName;
3967
- }
3968
- get email() {
3969
- return this.client ? this.client.email : this.registrationInvite?.email;
3994
+ toTransaction(bankTransaction = null) {
3995
+ const transaction = bankTransaction ? bankTransaction.toTransaction(this.isGST) : plainToClass(Transaction, {});
3996
+ Object.assign(transaction, {
3997
+ isGST: this.isGST,
3998
+ tax: this.tax,
3999
+ claimPercent: this.claimPercent,
4000
+ chartAccounts: this.chartAccounts,
4001
+ property: this.property,
4002
+ loan: this.loan,
4003
+ incomeSource: this.incomeSource,
4004
+ metaFields: this.metaFields,
4005
+ business: this.business,
4006
+ source: TransactionSourceEnum.BANK_TRANSACTION,
4007
+ operation: TransactionOperationEnum.ALLOCATE,
4008
+ transactions: [],
4009
+ });
4010
+ // split allocation
4011
+ if (this.amountPercent) {
4012
+ transaction.amount = bankTransaction.amount * this.amountPercentCoefficient / this.gstCoefficient;
4013
+ }
4014
+ // child transactions inherit most of the fields from parent transaction
4015
+ this.childTransactions.forEach((childRuleTransaction) => {
4016
+ const childTransaction = childRuleTransaction.toTransaction();
4017
+ childTransaction.amount = childRuleTransaction.amount;
4018
+ childTransaction.setParent(transaction);
4019
+ transaction.transactions.push(childTransaction);
4020
+ });
4021
+ return transaction;
3970
4022
  }
3971
4023
  }
3972
4024
  __decorate([
3973
- Type(() => Date)
3974
- ], ClientInvite.prototype, "sentOn", void 0);
4025
+ Type(() => ChartAccounts)
4026
+ // @TODO Alex: Create custom decorator for this transform
4027
+ ,
4028
+ Transform(({ value }) => ({ id: value.id }), { toPlainOnly: true })
4029
+ ], AllocationRuleTransaction.prototype, "chartAccounts", void 0);
3975
4030
  __decorate([
3976
- Type(() => Date)
3977
- ], ClientInvite.prototype, "updatedAt", void 0);
4031
+ Type(() => Property),
4032
+ Transform(({ value }) => value ? { id: value.id } : null, { toPlainOnly: true })
4033
+ ], AllocationRuleTransaction.prototype, "property", void 0);
3978
4034
  __decorate([
3979
- Type(() => User)
3980
- ], ClientInvite.prototype, "client", void 0);
4035
+ Type(() => Loan),
4036
+ Transform(({ value }) => value ? { id: value.id } : null, { toPlainOnly: true })
4037
+ ], AllocationRuleTransaction.prototype, "loan", void 0);
3981
4038
  __decorate([
3982
- Type(() => User)
3983
- ], ClientInvite.prototype, "employee", void 0);
4039
+ Type(() => IncomeSource),
4040
+ Transform(({ value }) => value ? { id: value.id } : null, { toPlainOnly: true })
4041
+ ], AllocationRuleTransaction.prototype, "incomeSource", void 0);
3984
4042
  __decorate([
3985
- Type(() => RegistrationInvite)
3986
- ], ClientInvite.prototype, "registrationInvite", void 0);
4043
+ Type(() => SoleBusiness),
4044
+ Transform(({ value }) => value ? { id: value.id } : null, { toPlainOnly: true })
4045
+ ], AllocationRuleTransaction.prototype, "business", void 0);
3987
4046
  __decorate([
3988
- Type(() => Firm)
3989
- ], ClientInvite.prototype, "firm", void 0);
4047
+ Type(() => AllocationRuleTransactionMetaField)
4048
+ ], AllocationRuleTransaction.prototype, "metaFields", void 0);
3990
4049
  __decorate([
3991
- Type(() => FirmBranch)
3992
- ], ClientInvite.prototype, "firmBranch", void 0);
4050
+ Type(() => AllocationRuleTransaction)
4051
+ ], AllocationRuleTransaction.prototype, "parentTransaction", void 0);
4052
+ __decorate([
4053
+ Type(() => AllocationRuleTransaction)
4054
+ ], AllocationRuleTransaction.prototype, "childTransactions", void 0);
4055
+ __decorate([
4056
+ Type(() => Number)
4057
+ ], AllocationRuleTransaction.prototype, "claimPercent", void 0);
4058
+ __decorate([
4059
+ Type(() => Number)
4060
+ ], AllocationRuleTransaction.prototype, "tax", void 0);
3993
4061
 
3994
- class ClientMovement extends ClientMovement$1 {
3995
- get firm() {
3996
- return this.firmBranch.firm;
4062
+ var TransactionTypeEnum;
4063
+ (function (TransactionTypeEnum) {
4064
+ TransactionTypeEnum[TransactionTypeEnum["DEBIT"] = 1] = "DEBIT";
4065
+ TransactionTypeEnum[TransactionTypeEnum["CREDIT"] = 2] = "CREDIT";
4066
+ })(TransactionTypeEnum || (TransactionTypeEnum = {}));
4067
+
4068
+ class TaxExemption extends TaxExemption$1 {
4069
+ isPartial() {
4070
+ return [TaxExemptionEnum.INVESTMENT_TO_PPR, TaxExemptionEnum.PPR_TO_INVESTMENT].includes(this.id);
3997
4071
  }
3998
4072
  }
3999
- __decorate([
4000
- Type(() => User)
4001
- ], ClientMovement.prototype, "client", void 0);
4002
- __decorate([
4003
- Type(() => User)
4004
- ], ClientMovement.prototype, "employee", void 0);
4073
+
4074
+ class AssetSale extends ObservableModel {
4075
+ static { this.className = 'AssetSale'; }
4076
+ }
4005
4077
  __decorate([
4006
4078
  Type(() => Date)
4007
- ], ClientMovement.prototype, "dateFrom", void 0);
4079
+ ], AssetSale.prototype, "date", void 0);
4080
+
4081
+ class PropertySale extends AssetSale {
4082
+ get saleCostsTotalAmount() {
4083
+ return this.commission + this.legalFees + this.otherCost;
4084
+ }
4085
+ /**
4086
+ * CGT is not applicable for sales with "Principle place of residence" exemption type.
4087
+ * https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/4644110466/Tax+Return+MyTax+-+Online+Form ("Capital gains or losses" section)
4088
+ */
4089
+ isCGTApplicable() {
4090
+ return this.taxExemption?.id !== TaxExemptionEnum.PPR;
4091
+ }
4092
+ get netPrice() {
4093
+ return this.price - this.saleCostsTotalAmount;
4094
+ }
4095
+ }
4096
+ __decorate([
4097
+ Type(() => Number)
4098
+ ], PropertySale.prototype, "holdingCosts", void 0);
4099
+ __decorate([
4100
+ Type(() => Number)
4101
+ ], PropertySale.prototype, "structuralImprovementsWDV", void 0);
4102
+ __decorate([
4103
+ Type(() => Number)
4104
+ ], PropertySale.prototype, "buildingAtCostClaimed", void 0);
4105
+ __decorate([
4106
+ Type(() => Number)
4107
+ ], PropertySale.prototype, "price", void 0);
4108
+ __decorate([
4109
+ Type(() => Number)
4110
+ ], PropertySale.prototype, "commission", void 0);
4111
+ __decorate([
4112
+ Type(() => Number)
4113
+ ], PropertySale.prototype, "legalFees", void 0);
4114
+ __decorate([
4115
+ Type(() => Number)
4116
+ ], PropertySale.prototype, "otherCost", void 0);
4008
4117
  __decorate([
4009
4118
  Type(() => Date)
4010
- ], ClientMovement.prototype, "dateTo", void 0);
4119
+ ], PropertySale.prototype, "settlementDate", void 0);
4011
4120
  __decorate([
4012
- Type(() => FirmBranch)
4013
- ], ClientMovement.prototype, "firmBranch", void 0);
4121
+ Type(() => Date)
4122
+ ], PropertySale.prototype, "date", void 0);
4123
+ __decorate([
4124
+ Type(() => TaxExemption)
4125
+ ], PropertySale.prototype, "taxExemption", void 0);
4126
+ __decorate([
4127
+ Type(() => PropertySaleTaxExemptionMetaField$1)
4128
+ ], PropertySale.prototype, "taxExemptionMetaFields", void 0);
4014
4129
 
4015
- /**
4016
- * Chart serie class: chart data item
4017
- * @TODO consider rename to ChartSerieData
4018
- */
4019
- class ChartSerie {
4130
+ var MyAccountHistoryInitiatedByEnum;
4131
+ (function (MyAccountHistoryInitiatedByEnum) {
4132
+ MyAccountHistoryInitiatedByEnum[MyAccountHistoryInitiatedByEnum["OWNER"] = 0] = "OWNER";
4133
+ MyAccountHistoryInitiatedByEnum[MyAccountHistoryInitiatedByEnum["ACCOUNTANT"] = 1] = "ACCOUNTANT";
4134
+ })(MyAccountHistoryInitiatedByEnum || (MyAccountHistoryInitiatedByEnum = {}));
4135
+
4136
+ var MyAccountHistoryStatusEnum;
4137
+ (function (MyAccountHistoryStatusEnum) {
4138
+ MyAccountHistoryStatusEnum[MyAccountHistoryStatusEnum["SUCCESS"] = 0] = "SUCCESS";
4139
+ MyAccountHistoryStatusEnum[MyAccountHistoryStatusEnum["ERROR"] = 1] = "ERROR";
4140
+ })(MyAccountHistoryStatusEnum || (MyAccountHistoryStatusEnum = {}));
4141
+
4142
+ var MyAccountHistoryTypeEnum;
4143
+ (function (MyAccountHistoryTypeEnum) {
4144
+ MyAccountHistoryTypeEnum[MyAccountHistoryTypeEnum["REVIEW"] = 0] = "REVIEW";
4145
+ MyAccountHistoryTypeEnum[MyAccountHistoryTypeEnum["UPGRADE_PLAN"] = 1] = "UPGRADE_PLAN";
4146
+ MyAccountHistoryTypeEnum[MyAccountHistoryTypeEnum["UPLOAD_DOCUMENT"] = 2] = "UPLOAD_DOCUMENT";
4147
+ })(MyAccountHistoryTypeEnum || (MyAccountHistoryTypeEnum = {}));
4148
+
4149
+ class MyAccountHistory {
4020
4150
  }
4021
4151
 
4152
+ class Occupation extends Occupation$1 {
4153
+ }
4154
+
4155
+ var UserRolesEnum;
4156
+ (function (UserRolesEnum) {
4157
+ UserRolesEnum["FIRM_OWNER"] = "ROLE_FIRM_OWNER";
4158
+ UserRolesEnum["FIRM_MANAGER"] = "ROLE_FIRM_MANAGER";
4159
+ UserRolesEnum["FIRM_TOP_MANAGER"] = "ROLE_FIRM_TOP_MANAGER";
4160
+ UserRolesEnum["CLIENT"] = "ROLE_CLIENT";
4161
+ UserRolesEnum["EMPLOYEE"] = "ROLE_EMPLOYEE";
4162
+ UserRolesEnum["ACCOUNTANT"] = "ROLE_ACCOUNTANT";
4163
+ UserRolesEnum["ADVISOR"] = "ROLE_ADVISOR";
4164
+ UserRolesEnum["USER"] = "ROLE_USER";
4165
+ UserRolesEnum["SUBSCRIPTION"] = "ROLE_USER_SUBSCRIPTION";
4166
+ UserRolesEnum["WORK_TANK"] = "ROLE_USER_WORK";
4167
+ UserRolesEnum["PROPERTY_TANK"] = "ROLE_USER_PROPERTY";
4168
+ UserRolesEnum["SOLE_TANK"] = "ROLE_USER_SOLE";
4169
+ UserRolesEnum["HOLDING_TANK"] = "ROLE_USER_HOLDING";
4170
+ UserRolesEnum["SWITCH_USER"] = "IS_IMPERSONATOR";
4171
+ })(UserRolesEnum || (UserRolesEnum = {}));
4172
+
4022
4173
  /**
4023
- * Chart data class
4024
- * @TODO consider rename to ChartSerie
4174
+ * role hierarchy
4025
4175
  */
4026
- class ChartData {
4027
- }
4028
- __decorate([
4029
- Type(() => ChartSerie)
4030
- ], ChartData.prototype, "data", void 0);
4176
+ const USER_ROLES = {
4177
+ ROLE_FIRM_OWNER: [UserRolesEnum.FIRM_OWNER, UserRolesEnum.FIRM_MANAGER, UserRolesEnum.ACCOUNTANT, UserRolesEnum.ADVISOR],
4178
+ ROLE_FIRM_MANAGER: [UserRolesEnum.FIRM_MANAGER, UserRolesEnum.ACCOUNTANT, UserRolesEnum.ADVISOR],
4179
+ ROLE_EMPLOYEE: [UserRolesEnum.ACCOUNTANT, UserRolesEnum.ADVISOR],
4180
+ ROLE_ACCOUNTANT: [UserRolesEnum.ACCOUNTANT],
4181
+ ROLE_ADVISOR: [UserRolesEnum.ADVISOR],
4182
+ // @TODO makes no sense, these roles can't be hierarchical
4183
+ ROLE_CLIENT: [UserRolesEnum.CLIENT],
4184
+ ROLE_USER_SUBSCRIPTION: [UserRolesEnum.SUBSCRIPTION],
4185
+ ROLE_USER_WORK: [UserRolesEnum.WORK_TANK],
4186
+ ROLE_USER_PROPERTY: [UserRolesEnum.PROPERTY_TANK],
4187
+ ROLE_USER_SOLE: [UserRolesEnum.SOLE_TANK],
4188
+ ROLE_USER_HOLDING: [UserRolesEnum.HOLDING_TANK],
4189
+ ROLE_PREVIOUS_ADMIN: [UserRolesEnum.SWITCH_USER],
4190
+ };
4031
4191
 
4032
4192
  /**
4033
- * Client portfolio charts data based on ClientPortfolioReportCollection
4193
+ * Class with basic information about registering user
4034
4194
  */
4035
- class ClientPortfolioChartData {
4036
- constructor(clientsPortfolioReportCollection) {
4037
- this.clientsPortfolioReportCollection = clientsPortfolioReportCollection;
4195
+ class UserToRegister {
4196
+ }
4197
+
4198
+ const USER_WORK_POSITION = {
4199
+ [UserRolesEnum.EMPLOYEE]: 'Employee',
4200
+ [UserRolesEnum.FIRM_MANAGER]: 'Manager',
4201
+ [UserRolesEnum.FIRM_OWNER]: 'Firm Owner'
4202
+ };
4203
+
4204
+ var UserStatusEnum;
4205
+ (function (UserStatusEnum) {
4206
+ UserStatusEnum[UserStatusEnum["INACTIVE"] = 0] = "INACTIVE";
4207
+ UserStatusEnum[UserStatusEnum["ON_BOARDING"] = 1] = "ON_BOARDING";
4208
+ UserStatusEnum[UserStatusEnum["ACTIVE"] = 2] = "ACTIVE";
4209
+ })(UserStatusEnum || (UserStatusEnum = {}));
4210
+
4211
+ class ClientDetails extends ClientDetails$1 {
4212
+ /**
4213
+ * reminder to sign basiq consent after x days before the expiration
4214
+ */
4215
+ static { this.consentExpiryReminderDays = 30; }
4216
+ get taxFileNumberMasked() {
4217
+ const maskedLength = this.taxFileNumber.length - 4;
4218
+ const maskedPart = '*'.repeat(maskedLength);
4219
+ const lastFour = this.taxFileNumber.slice(-4);
4220
+ return maskedPart + lastFour;
4038
4221
  }
4039
- getPieChartData() {
4040
- return this.clientsPortfolioReportCollection.items.map((clientPortfolioReport) => plainToClass(ChartData, {
4041
- name: clientPortfolioReport.category,
4042
- data: clientPortfolioReport.count
4043
- }));
4222
+ isBasiqConsentExpiring() {
4223
+ if (!this.basiqConsentExpiryDate || this.isBasiqConsentExpired()) {
4224
+ return false;
4225
+ }
4226
+ const reminderDate = new Date(this.basiqConsentExpiryDate);
4227
+ reminderDate.setDate(this.basiqConsentExpiryDate.getDate() - ClientDetails.consentExpiryReminderDays);
4228
+ return new Date() >= reminderDate;
4044
4229
  }
4045
- getBarChartData() {
4046
- return [
4047
- plainToClass(ChartData, {
4048
- name: 'Total',
4049
- data: [
4050
- {
4051
- label: 'Market value',
4052
- value: this.clientsPortfolioReportCollection.marketValue
4053
- },
4054
- {
4055
- label: 'Loan balance',
4056
- value: this.clientsPortfolioReportCollection.loanBalance
4057
- },
4058
- {
4059
- label: 'Equity position',
4060
- value: this.clientsPortfolioReportCollection.equityPosition
4061
- }
4062
- ]
4063
- }),
4064
- plainToClass(ChartData, {
4065
- name: 'Average',
4066
- data: [
4067
- {
4068
- label: 'Market value',
4069
- value: this.clientsPortfolioReportCollection.averageMarketValue
4070
- },
4071
- {
4072
- label: 'Loan balance',
4073
- value: this.clientsPortfolioReportCollection.averageLoanBalance
4074
- },
4075
- {
4076
- label: 'Equity position',
4077
- value: this.clientsPortfolioReportCollection.averageEquityPosition
4078
- }
4079
- ]
4080
- })
4081
- ];
4230
+ isBasiqConsentExpired() {
4231
+ return this.basiqConsentExpiryDate && new Date() >= this.basiqConsentExpiryDate;
4082
4232
  }
4083
4233
  }
4234
+ __decorate([
4235
+ Type(() => Date)
4236
+ ], ClientDetails.prototype, "basiqConsentExpiryDate", void 0);
4084
4237
 
4085
- /**
4086
- * Class describes client's portfolio report information
4087
- */
4088
- class ClientPortfolioReport extends AbstractModel {
4089
- }
4090
-
4091
- class CapitalLoss extends AbstractModel {
4238
+ class AnnualClientDetails extends AbstractModel {
4092
4239
  constructor() {
4093
4240
  super(...arguments);
4241
+ this.spouseAnnualIncome = 0;
4094
4242
  this.financialYear = new FinancialYear().year;
4095
4243
  }
4244
+ get spouseMonthlyIncome() {
4245
+ return this.spouseAnnualIncome / 12;
4246
+ }
4096
4247
  }
4097
4248
  __decorate([
4098
4249
  Type(() => ClientDetails)
4099
- ], CapitalLoss.prototype, "clientDetails", void 0);
4100
- __decorate([
4101
- Type(() => User)
4102
- ], CapitalLoss.prototype, "updatedBy", void 0);
4250
+ ], AnnualClientDetails.prototype, "clientDetails", void 0);
4103
4251
 
4104
- class EmployeeDetails extends EmployeeDetails$1 {
4105
- get firmBranchNames() {
4106
- return this.firmBranches.map(branch => branch.name).join(', ');
4252
+ var ClientInviteStatusEnum;
4253
+ (function (ClientInviteStatusEnum) {
4254
+ ClientInviteStatusEnum[ClientInviteStatusEnum["PENDING"] = 1] = "PENDING";
4255
+ ClientInviteStatusEnum[ClientInviteStatusEnum["REJECTED"] = 2] = "REJECTED";
4256
+ })(ClientInviteStatusEnum || (ClientInviteStatusEnum = {}));
4257
+
4258
+ var ClientInviteTypeEnum;
4259
+ (function (ClientInviteTypeEnum) {
4260
+ ClientInviteTypeEnum[ClientInviteTypeEnum["FROM_CLIENT"] = 1] = "FROM_CLIENT";
4261
+ ClientInviteTypeEnum[ClientInviteTypeEnum["FROM_EMPLOYEE"] = 2] = "FROM_EMPLOYEE";
4262
+ })(ClientInviteTypeEnum || (ClientInviteTypeEnum = {}));
4263
+
4264
+ class RegistrationInvite extends RegistrationInvite$1 {
4265
+ get fullName() {
4266
+ return `${this.firstName} ${this.lastName}`;
4107
4267
  }
4108
4268
  }
4109
4269
  __decorate([
4110
- Type(() => Firm)
4111
- ], EmployeeDetails.prototype, "firm", void 0);
4270
+ Type(() => AppFile)
4271
+ ], RegistrationInvite.prototype, "file", void 0);
4112
4272
  __decorate([
4113
- Type(() => FirmBranch)
4114
- ], EmployeeDetails.prototype, "firmBranches", void 0);
4115
-
4116
- var ServiceProductStatusEnum;
4117
- (function (ServiceProductStatusEnum) {
4118
- ServiceProductStatusEnum[ServiceProductStatusEnum["ARCHIVED"] = 0] = "ARCHIVED";
4119
- ServiceProductStatusEnum[ServiceProductStatusEnum["ACTIVE"] = 1] = "ACTIVE";
4120
- })(ServiceProductStatusEnum || (ServiceProductStatusEnum = {}));
4273
+ Type(() => User)
4274
+ ], RegistrationInvite.prototype, "user", void 0);
4121
4275
 
4122
- var ServiceProductIdEnum;
4123
- (function (ServiceProductIdEnum) {
4124
- ServiceProductIdEnum[ServiceProductIdEnum["WORK_TANK_OLD"] = 1] = "WORK_TANK_OLD";
4276
+ var PhoneTypeEnum;
4277
+ (function (PhoneTypeEnum) {
4278
+ PhoneTypeEnum[PhoneTypeEnum["MOBILE"] = 1] = "MOBILE";
4279
+ PhoneTypeEnum[PhoneTypeEnum["OFFICE"] = 2] = "OFFICE";
4280
+ })(PhoneTypeEnum || (PhoneTypeEnum = {}));
4281
+
4282
+ class Phone extends Phone$1 {
4283
+ constructor() {
4284
+ super(...arguments);
4285
+ this.country = Country.australia;
4286
+ this.type = PhoneTypeEnum.MOBILE;
4287
+ }
4288
+ toString() {
4289
+ return `+${this.country.callingCode} ${this.number}`;
4290
+ }
4291
+ }
4292
+ __decorate([
4293
+ Type(() => Country)
4294
+ ], Phone.prototype, "country", void 0);
4295
+
4296
+ class Firm extends Firm$1 {
4297
+ isAccountant() {
4298
+ return this.type === FirmTypeEnum.ACCOUNTANT;
4299
+ }
4300
+ }
4301
+ __decorate([
4302
+ Type(() => User)
4303
+ ], Firm.prototype, "owner", void 0);
4304
+ __decorate([
4305
+ Type(() => Address)
4306
+ ], Firm.prototype, "address", void 0);
4307
+ __decorate([
4308
+ Type(() => Phone)
4309
+ ], Firm.prototype, "phone", void 0);
4310
+ __decorate([
4311
+ Type(() => AppFile)
4312
+ ], Firm.prototype, "file", void 0);
4313
+
4314
+ class FirmBranch extends AbstractModel {
4315
+ constructor() {
4316
+ super(...arguments);
4317
+ this.isMain = false;
4318
+ }
4319
+ }
4320
+ __decorate([
4321
+ Type(() => Firm)
4322
+ ], FirmBranch.prototype, "firm", void 0);
4323
+ __decorate([
4324
+ Type(() => Address)
4325
+ ], FirmBranch.prototype, "address", void 0);
4326
+ __decorate([
4327
+ Type(() => Phone)
4328
+ ], FirmBranch.prototype, "phone", void 0);
4329
+
4330
+ class ClientInvite extends ClientInvite$1 {
4331
+ /**
4332
+ * Check if client invite status is pending
4333
+ */
4334
+ isPending() {
4335
+ return this.status === ClientInviteStatusEnum.PENDING;
4336
+ }
4337
+ /**
4338
+ * Check if client invite status is accepted
4339
+ */
4340
+ isAccepted() {
4341
+ return !this.isPending() && !this.isRejected();
4342
+ }
4343
+ /**
4344
+ * Check if client invite status is rejected
4345
+ */
4346
+ isRejected() {
4347
+ return this.status === ClientInviteStatusEnum.REJECTED;
4348
+ }
4349
+ /**
4350
+ * Check if client invite initiated by firm
4351
+ */
4352
+ isFromEmployee() {
4353
+ return this.type === ClientInviteTypeEnum.FROM_EMPLOYEE;
4354
+ }
4355
+ /**
4356
+ * Check if client invite initiated by client
4357
+ */
4358
+ isFromClient() {
4359
+ return this.type === ClientInviteTypeEnum.FROM_CLIENT;
4360
+ }
4361
+ get firstName() {
4362
+ return this.client ? this.client.firstName : this.registrationInvite?.firstName;
4363
+ }
4364
+ get fullName() {
4365
+ return this.client ? this.client.fullName : this.registrationInvite?.fullName;
4366
+ }
4367
+ get email() {
4368
+ return this.client ? this.client.email : this.registrationInvite?.email;
4369
+ }
4370
+ }
4371
+ __decorate([
4372
+ Type(() => Date)
4373
+ ], ClientInvite.prototype, "sentOn", void 0);
4374
+ __decorate([
4375
+ Type(() => Date)
4376
+ ], ClientInvite.prototype, "updatedAt", void 0);
4377
+ __decorate([
4378
+ Type(() => User)
4379
+ ], ClientInvite.prototype, "client", void 0);
4380
+ __decorate([
4381
+ Type(() => User)
4382
+ ], ClientInvite.prototype, "employee", void 0);
4383
+ __decorate([
4384
+ Type(() => RegistrationInvite)
4385
+ ], ClientInvite.prototype, "registrationInvite", void 0);
4386
+ __decorate([
4387
+ Type(() => Firm)
4388
+ ], ClientInvite.prototype, "firm", void 0);
4389
+ __decorate([
4390
+ Type(() => FirmBranch)
4391
+ ], ClientInvite.prototype, "firmBranch", void 0);
4392
+
4393
+ class ClientMovement extends ClientMovement$1 {
4394
+ get firm() {
4395
+ return this.firmBranch.firm;
4396
+ }
4397
+ }
4398
+ __decorate([
4399
+ Type(() => User)
4400
+ ], ClientMovement.prototype, "client", void 0);
4401
+ __decorate([
4402
+ Type(() => User)
4403
+ ], ClientMovement.prototype, "employee", void 0);
4404
+ __decorate([
4405
+ Type(() => Date)
4406
+ ], ClientMovement.prototype, "dateFrom", void 0);
4407
+ __decorate([
4408
+ Type(() => Date)
4409
+ ], ClientMovement.prototype, "dateTo", void 0);
4410
+ __decorate([
4411
+ Type(() => FirmBranch)
4412
+ ], ClientMovement.prototype, "firmBranch", void 0);
4413
+
4414
+ /**
4415
+ * Chart serie class: chart data item
4416
+ * @TODO consider rename to ChartSerieData
4417
+ */
4418
+ class ChartSerie {
4419
+ }
4420
+
4421
+ /**
4422
+ * Chart data class
4423
+ * @TODO consider rename to ChartSerie
4424
+ */
4425
+ class ChartData {
4426
+ }
4427
+ __decorate([
4428
+ Type(() => ChartSerie)
4429
+ ], ChartData.prototype, "data", void 0);
4430
+
4431
+ /**
4432
+ * Client portfolio charts data based on ClientPortfolioReportCollection
4433
+ */
4434
+ class ClientPortfolioChartData {
4435
+ constructor(clientsPortfolioReportCollection) {
4436
+ this.clientsPortfolioReportCollection = clientsPortfolioReportCollection;
4437
+ }
4438
+ getPieChartData() {
4439
+ return this.clientsPortfolioReportCollection.items.map((clientPortfolioReport) => plainToClass(ChartData, {
4440
+ name: clientPortfolioReport.category,
4441
+ data: clientPortfolioReport.count
4442
+ }));
4443
+ }
4444
+ getBarChartData() {
4445
+ return [
4446
+ plainToClass(ChartData, {
4447
+ name: 'Total',
4448
+ data: [
4449
+ {
4450
+ label: 'Market value',
4451
+ value: this.clientsPortfolioReportCollection.marketValue
4452
+ },
4453
+ {
4454
+ label: 'Loan balance',
4455
+ value: this.clientsPortfolioReportCollection.loanBalance
4456
+ },
4457
+ {
4458
+ label: 'Equity position',
4459
+ value: this.clientsPortfolioReportCollection.equityPosition
4460
+ }
4461
+ ]
4462
+ }),
4463
+ plainToClass(ChartData, {
4464
+ name: 'Average',
4465
+ data: [
4466
+ {
4467
+ label: 'Market value',
4468
+ value: this.clientsPortfolioReportCollection.averageMarketValue
4469
+ },
4470
+ {
4471
+ label: 'Loan balance',
4472
+ value: this.clientsPortfolioReportCollection.averageLoanBalance
4473
+ },
4474
+ {
4475
+ label: 'Equity position',
4476
+ value: this.clientsPortfolioReportCollection.averageEquityPosition
4477
+ }
4478
+ ]
4479
+ })
4480
+ ];
4481
+ }
4482
+ }
4483
+
4484
+ /**
4485
+ * Class describes client's portfolio report information
4486
+ */
4487
+ class ClientPortfolioReport extends AbstractModel {
4488
+ }
4489
+
4490
+ class CapitalLoss extends AbstractModel {
4491
+ constructor() {
4492
+ super(...arguments);
4493
+ this.financialYear = new FinancialYear().year;
4494
+ }
4495
+ }
4496
+ __decorate([
4497
+ Type(() => ClientDetails)
4498
+ ], CapitalLoss.prototype, "clientDetails", void 0);
4499
+
4500
+ class EmployeeDetails extends EmployeeDetails$1 {
4501
+ get firmBranchNames() {
4502
+ return this.firmBranches.map(branch => branch.name).join(', ');
4503
+ }
4504
+ }
4505
+ __decorate([
4506
+ Type(() => Firm)
4507
+ ], EmployeeDetails.prototype, "firm", void 0);
4508
+ __decorate([
4509
+ Type(() => FirmBranch)
4510
+ ], EmployeeDetails.prototype, "firmBranches", void 0);
4511
+
4512
+ var ServiceProductStatusEnum;
4513
+ (function (ServiceProductStatusEnum) {
4514
+ ServiceProductStatusEnum[ServiceProductStatusEnum["ARCHIVED"] = 0] = "ARCHIVED";
4515
+ ServiceProductStatusEnum[ServiceProductStatusEnum["ACTIVE"] = 1] = "ACTIVE";
4516
+ })(ServiceProductStatusEnum || (ServiceProductStatusEnum = {}));
4517
+
4518
+ var ServiceProductIdEnum;
4519
+ (function (ServiceProductIdEnum) {
4520
+ ServiceProductIdEnum[ServiceProductIdEnum["WORK_TANK_OLD"] = 1] = "WORK_TANK_OLD";
4125
4521
  ServiceProductIdEnum[ServiceProductIdEnum["PROPERTY_OLD"] = 2] = "PROPERTY_OLD";
4126
4522
  ServiceProductIdEnum[ServiceProductIdEnum["PROPERTY_TANK"] = 3] = "PROPERTY_TANK";
4127
4523
  ServiceProductIdEnum[ServiceProductIdEnum["WORK_TANK"] = 4] = "WORK_TANK";
@@ -4536,15 +4932,6 @@ __decorate([
4536
4932
  __decorate([
4537
4933
  Type(() => SoleBusinessLossOffsetRule)
4538
4934
  ], SoleBusinessLoss.prototype, "offsetRule", void 0);
4539
- __decorate([
4540
- Type(() => User)
4541
- ], SoleBusinessLoss.prototype, "updatedBy", void 0);
4542
-
4543
- var TransactionSourceEnum;
4544
- (function (TransactionSourceEnum) {
4545
- TransactionSourceEnum[TransactionSourceEnum["CASH"] = 1] = "CASH";
4546
- TransactionSourceEnum[TransactionSourceEnum["BANK_TRANSACTION"] = 2] = "BANK_TRANSACTION";
4547
- })(TransactionSourceEnum || (TransactionSourceEnum = {}));
4548
4935
 
4549
4936
  var SoleInvoiceTaxTypeEnum;
4550
4937
  (function (SoleInvoiceTaxTypeEnum) {
@@ -4828,871 +5215,472 @@ class VehicleClaimDetails extends VehicleClaimDetails$1 {
4828
5215
  this.financialYear = new FinancialYear().year;
4829
5216
  }
4830
5217
  isLogbookMethod() {
4831
- return this.method === VehicleClaimDetailsMethodEnum.LOGBOOK;
4832
- }
4833
- isKmsMethod() {
4834
- return this.method === VehicleClaimDetailsMethodEnum.KMS;
4835
- }
4836
- }
4837
- __decorate([
4838
- Type(() => User)
4839
- ], VehicleClaimDetails.prototype, "user", void 0);
4840
-
4841
- class VehicleClaim extends VehicleClaim$1 {
4842
- constructor() {
4843
- super(...arguments);
4844
- this.kilometers = 0;
4845
- this.workUsage = 0;
4846
- }
4847
- /**
4848
- * limit for kms claim method
4849
- */
4850
- static { this.totalKmsLimit = 5000; }
4851
- /**
4852
- * limit for work usage claim method
4853
- */
4854
- static { this.totalWorkUsagePercent = 100; }
4855
- isWorkTank() {
4856
- return !this.business;
4857
- }
4858
- isSoleTank() {
4859
- return !!this.business;
4860
- }
4861
- get tankType() {
4862
- return this.isSoleTank() ? TankTypeEnum.SOLE : TankTypeEnum.WORK;
4863
- }
4864
- /**
4865
- * Claim amount for KMs method. Exists only for KMs method.
4866
- */
4867
- getKMSClaimAmount(vehicleClaimRate) {
4868
- return round(this.kilometers * vehicleClaimRate, 2);
4869
- }
4870
- /**
4871
- * Get logbook claim amount. Exists only for logbook method.
4872
- * ClaimAmount = WorkUsage * transaction/depreciation amount
4873
- */
4874
- getLogbookClaimAmount(transactions) {
4875
- const transactionsAmount = transactions
4876
- .getByVehicleClaim(this)
4877
- .getLogbookTransactions()
4878
- .sumBy('amount');
4879
- // Math.abs because amount will be negative (because we sum expenses), but we don't want negative percent value
4880
- return Math.abs(transactionsAmount) * this.workUsage / 100;
4881
- }
4882
- getAverageWeeklyKMS() {
4883
- return this.kilometers / FinancialYear.weeksInYear;
4884
- }
4885
- }
4886
- __decorate([
4887
- Type(() => VehicleClaimDetails)
4888
- ], VehicleClaim.prototype, "details", void 0);
4889
- __decorate([
4890
- Type(() => SoleBusiness)
4891
- ], VehicleClaim.prototype, "business", void 0);
4892
-
4893
- /**
4894
- * Depreciation Nested Tree node with depreciations group
4895
- */
4896
- class DepreciationGroup {
4897
- constructor(label, description, icon, children, totalCost, openingValue) {
4898
- this.label = label;
4899
- this.description = description;
4900
- this.icon = icon;
4901
- this.children = children;
4902
- this.totalCost = totalCost;
4903
- this.openingValue = openingValue;
4904
- }
4905
- getClaimAmount() {
4906
- return this.children.reduce((sum, child) => sum + child.getClaimAmount(), 0);
4907
- }
4908
- getAmount() {
4909
- return this.children.reduce((sum, child) => sum + child.getAmount(), 0);
4910
- }
4911
- }
4912
-
4913
- /**
4914
- * @TODO Alex useless class, use parent instead
4915
- * Depreciation Tree node with depreciation details
4916
- */
4917
- class DepreciationGroupItem extends DepreciationGroup {
4918
- constructor(depreciation) {
4919
- super(depreciation.chartAccounts.name, depreciation.description, 'property');
4920
- this.depreciation = depreciation;
4921
- }
4922
- getClaimAmount() {
4923
- return this.depreciation.currentYearForecast.claimAmount;
4924
- }
4925
- getAmount() {
4926
- return this.depreciation.currentYearForecast.amount;
4927
- }
4928
- }
4929
-
4930
- var DepreciationGroupEnum;
4931
- (function (DepreciationGroupEnum) {
4932
- DepreciationGroupEnum[DepreciationGroupEnum["BUILDING_IMPROVEMENTS"] = 0] = "BUILDING_IMPROVEMENTS";
4933
- DepreciationGroupEnum[DepreciationGroupEnum["PLANT_EQUIPMENT"] = 1] = "PLANT_EQUIPMENT";
4934
- DepreciationGroupEnum[DepreciationGroupEnum["LOW_VALUE_POOL"] = 2] = "LOW_VALUE_POOL";
4935
- DepreciationGroupEnum[DepreciationGroupEnum["WRITTEN_OFF_ITEMS"] = 3] = "WRITTEN_OFF_ITEMS";
4936
- DepreciationGroupEnum[DepreciationGroupEnum["BORROWING_EXPENSES"] = 4] = "BORROWING_EXPENSES";
4937
- DepreciationGroupEnum[DepreciationGroupEnum["SMALL_BUSINESS_POOL"] = 5] = "SMALL_BUSINESS_POOL";
4938
- })(DepreciationGroupEnum || (DepreciationGroupEnum = {}));
4939
-
4940
- const DEPRECIATION_GROUPS = {
4941
- [DepreciationGroupEnum.BORROWING_EXPENSES]: {
4942
- label: 'Borrowing Expenses',
4943
- description: 'Borrowing expenses on loans are deductible over 1826 days (5 years) starting from the date of a loan',
4944
- icon: 'loan'
4945
- },
4946
- [DepreciationGroupEnum.BUILDING_IMPROVEMENTS]: {
4947
- label: 'Building & Improvements',
4948
- description: 'Construction costs, renovations and capital improvements which depreciate at 2.5%',
4949
- icon: 'building-improvements'
4950
- },
4951
- [DepreciationGroupEnum.PLANT_EQUIPMENT]: {
4952
- label: 'Plant & Equipment',
4953
- description: 'Assets which decline in value over their useful life (as prescribed by the ATO)',
4954
- icon: 'plant-equipment'
4955
- },
4956
- [DepreciationGroupEnum.LOW_VALUE_POOL]: {
4957
- label: 'Low Value Pool',
4958
- description: 'Items under $1,000 are added to the pool to maximise depreciation',
4959
- icon: 'lvp'
4960
- },
4961
- [DepreciationGroupEnum.WRITTEN_OFF_ITEMS]: {
4962
- label: 'Written Off Items',
4963
- description: 'Items below $300, replaced or obsolete are fully deductible',
4964
- icon: 'cart'
4965
- },
4966
- [DepreciationGroupEnum.SMALL_BUSINESS_POOL]: {
4967
- label: 'Small business pool',
4968
- description: 'The small business pool allows business owners to claim depreciation on plant and equipment items at an accelerated rate.',
4969
- icon: 'portfolio'
4970
- },
4971
- };
4972
-
4973
- /**
4974
- * Depreciation Low Value Pool rate based on asset financial year (current or subsequent years).
4975
- */
4976
- var DepreciationLvpRateEnum;
4977
- (function (DepreciationLvpRateEnum) {
4978
- DepreciationLvpRateEnum[DepreciationLvpRateEnum["FIRST_YEAR"] = 0.1875] = "FIRST_YEAR";
4979
- DepreciationLvpRateEnum[DepreciationLvpRateEnum["DEFAULT"] = 0.375] = "DEFAULT";
4980
- })(DepreciationLvpRateEnum || (DepreciationLvpRateEnum = {}));
4981
-
4982
- class SoleBusiness extends SoleBusiness$1 {
4983
- /**
4984
- * Maximum number of businesses that a person can have, according to the ATO
4985
- */
4986
- static { this.businessesLimit = 6; }
4987
- }
4988
- __decorate([
4989
- Type(() => User)
4990
- ], SoleBusiness.prototype, "user", void 0);
4991
- __decorate([
4992
- Type(() => SoleBusinessAllocation)
4993
- ], SoleBusiness.prototype, "allocations", void 0);
4994
- __decorate([
4995
- Type(() => SoleBusinessLoss)
4996
- ], SoleBusiness.prototype, "losses", void 0);
4997
- __decorate([
4998
- Type(() => SoleInvoice)
4999
- ], SoleBusiness.prototype, "invoices", void 0);
5000
- __decorate([
5001
- Type(() => SoleInvoiceTemplate)
5002
- ], SoleBusiness.prototype, "invoiceTemplates", void 0);
5003
- __decorate([
5004
- Type(() => VehicleClaim)
5005
- ], SoleBusiness.prototype, "vehicleClaims", void 0);
5006
- __decorate([
5007
- Type(() => Transaction)
5008
- ], SoleBusiness.prototype, "transactions", void 0);
5009
- __decorate([
5010
- Type(() => Depreciation)
5011
- ], SoleBusiness.prototype, "depreciations", void 0);
5012
- __decorate([
5013
- Type(() => SoleBusinessActivity$1)
5014
- ], SoleBusiness.prototype, "activity", void 0);
5015
- __decorate([
5016
- Type(() => IncomeSource)
5017
- ], SoleBusiness.prototype, "incomeSource", void 0);
5018
- __decorate([
5019
- Transform(({ value }) => value || false)
5020
- ], SoleBusiness.prototype, "isPrimaryProduction", void 0);
5021
- __decorate([
5022
- Type(() => AppFile)
5023
- ], SoleBusiness.prototype, "file", void 0);
5024
-
5025
- class SoleBusinessActivity extends SoleBusinessActivity$1 {
5026
- }
5027
-
5028
- var SoleDepreciationMethodEnum;
5029
- (function (SoleDepreciationMethodEnum) {
5030
- SoleDepreciationMethodEnum[SoleDepreciationMethodEnum["SBP"] = 1] = "SBP";
5031
- SoleDepreciationMethodEnum[SoleDepreciationMethodEnum["DEPRECIATION"] = 2] = "DEPRECIATION";
5032
- })(SoleDepreciationMethodEnum || (SoleDepreciationMethodEnum = {}));
5033
-
5034
- class SoleDepreciationMethod extends SoleDepreciationMethod$1 {
5035
- isSBP() {
5036
- return this.method === SoleDepreciationMethodEnum.SBP;
5037
- }
5038
- }
5039
-
5040
- class SoleDetails extends SoleDetails$1 {
5041
- }
5042
- __decorate([
5043
- Type(() => User)
5044
- ], SoleDetails.prototype, "user", void 0);
5045
-
5046
- class BasReport extends BasReport$1 {
5047
- get taxWithheldTotal() {
5048
- return this.taxWithheldSalary + this.taxWithheldNoABN;
5049
- }
5050
- get paygTaxInstalmentOwedToATO() {
5051
- return this.paygTaxInstalment > 0 ? this.paygTaxInstalment : 0;
5052
- }
5053
- get paygTaxInstalmentOwedByATO() {
5054
- return this.paygTaxInstalment < 0 ? Math.abs(this.paygTaxInstalment) : 0;
5055
- }
5056
- get fuelTaxCreditOwedToATO() {
5057
- return this.fuelTaxCredit < 0 ? this.fuelTaxCredit : 0;
5058
- }
5059
- get fuelTaxCreditOwedByATO() {
5060
- return this.fuelTaxCredit > 0 ? Math.abs(this.fuelTaxCredit) : 0;
5061
- }
5062
- get owesToATO() {
5063
- return this.incomeGST + this.taxWithheldTotal + this.paygTaxInstalmentOwedToATO + this.fuelTaxCreditOwedToATO;
5064
- }
5065
- get owedByATO() {
5066
- return this.expenseGST + this.paygTaxInstalmentOwedByATO + this.fuelTaxCreditOwedByATO;
5067
- }
5068
- /**
5069
- * GST payable to the ATO, or refundable from the ATO in case it's negative
5070
- */
5071
- get gst() {
5072
- if (!this.id) {
5073
- return 0;
5074
- }
5075
- return this.incomeGST + this.expenseGST + this.taxWithheldTotal + this.paygTaxInstalment - this.fuelTaxCredit;
5076
- }
5077
- }
5078
- __decorate([
5079
- Type(() => Date)
5080
- ], BasReport.prototype, "dateFrom", void 0);
5081
- __decorate([
5082
- Type(() => Date)
5083
- ], BasReport.prototype, "dateTo", void 0);
5084
-
5085
- class SetupItem extends AbstractModel {
5086
- }
5087
-
5088
- /**
5089
- * Enum list of all possible account setup items ids. Using with [ACCOUNT_SETUP_ITEMS]{@link ACCOUNT_SETUP_ITEMS}
5090
- * @TODO Vik/Nikita: Do we need to generate it from backend? If some ids changed?
5091
- */
5092
- var AccountSetupItemsEnum;
5093
- (function (AccountSetupItemsEnum) {
5094
- AccountSetupItemsEnum[AccountSetupItemsEnum["SALARY"] = 1] = "SALARY";
5095
- AccountSetupItemsEnum[AccountSetupItemsEnum["OTHER_INCOME"] = 2] = "OTHER_INCOME";
5096
- AccountSetupItemsEnum[AccountSetupItemsEnum["PROPERTY"] = 3] = "PROPERTY";
5097
- AccountSetupItemsEnum[AccountSetupItemsEnum["BANK_FEEDS"] = 4] = "BANK_FEEDS";
5098
- AccountSetupItemsEnum[AccountSetupItemsEnum["WORK_LOGBOOK"] = 5] = "WORK_LOGBOOK";
5099
- AccountSetupItemsEnum[AccountSetupItemsEnum["TRANSACTION_ALLOCATE"] = 6] = "TRANSACTION_ALLOCATE";
5100
- AccountSetupItemsEnum[AccountSetupItemsEnum["SOLE_BUSINESS"] = 7] = "SOLE_BUSINESS";
5101
- AccountSetupItemsEnum[AccountSetupItemsEnum["HOLDINGS"] = 8] = "HOLDINGS";
5102
- AccountSetupItemsEnum[AccountSetupItemsEnum["FIRM_DETAILS"] = 9] = "FIRM_DETAILS";
5103
- AccountSetupItemsEnum[AccountSetupItemsEnum["INVITE_TEAM"] = 10] = "INVITE_TEAM";
5104
- AccountSetupItemsEnum[AccountSetupItemsEnum["INVITE_CLIENTS"] = 11] = "INVITE_CLIENTS";
5105
- })(AccountSetupItemsEnum || (AccountSetupItemsEnum = {}));
5106
-
5107
- class AccountSetupItem extends SetupItem {
5108
- get isSalary() {
5109
- return this.id === AccountSetupItemsEnum.SALARY;
5110
- }
5111
- get isOtherIncome() {
5112
- return this.id === AccountSetupItemsEnum.OTHER_INCOME;
5113
- }
5114
- get isProperty() {
5115
- return this.id === AccountSetupItemsEnum.PROPERTY;
5116
- }
5117
- get isBankFeeds() {
5118
- return this.id === AccountSetupItemsEnum.BANK_FEEDS;
5119
- }
5120
- get isWorkLogbook() {
5121
- return this.id === AccountSetupItemsEnum.WORK_LOGBOOK;
5122
- }
5123
- get isTransactionAllocate() {
5124
- return this.id === AccountSetupItemsEnum.TRANSACTION_ALLOCATE;
5125
- }
5126
- get isSoleBusiness() {
5127
- return this.id === AccountSetupItemsEnum.SOLE_BUSINESS;
5128
- }
5129
- get isHoldings() {
5130
- return this.id === AccountSetupItemsEnum.HOLDINGS;
5131
- }
5132
- get isFirmDetails() {
5133
- return this.id === AccountSetupItemsEnum.FIRM_DETAILS;
5134
- }
5135
- get isInviteTeam() {
5136
- return this.id === AccountSetupItemsEnum.INVITE_TEAM;
5137
- }
5138
- get isInviteClients() {
5139
- return this.id === AccountSetupItemsEnum.INVITE_CLIENTS;
5140
- }
5141
- }
5142
-
5143
- class User extends User$1 {
5144
- constructor() {
5145
- super(...arguments);
5146
- this.blacklistSetupItems = [];
5147
- }
5148
- get fullName() {
5149
- return `${this.firstName} ${this.lastName}`;
5150
- }
5151
- get photo() {
5152
- return this.file?.publicUrl;
5153
- }
5154
- get activeSubscription() {
5155
- return this.subscriptions.find((ss) => ss.isActive);
5156
- }
5157
- get lastSubscription() {
5158
- return this.subscriptions[this.subscriptions.length - 1];
5159
- }
5160
- /**
5161
- * @TODO refactor
5162
- *
5163
- */
5164
- get position() {
5165
- switch (true) {
5166
- case this.isFirmOwner():
5167
- return USER_WORK_POSITION[UserRolesEnum.FIRM_OWNER];
5168
- case this.isManager():
5169
- return USER_WORK_POSITION[UserRolesEnum.FIRM_MANAGER];
5170
- case this.isEmployee():
5171
- return USER_WORK_POSITION[UserRolesEnum.EMPLOYEE];
5172
- default:
5173
- return '';
5174
- }
5175
- }
5176
- /**
5177
- * search roles including hierarchy
5178
- */
5179
- hasRoles(roles) {
5180
- roles = roles instanceof Array ? roles : [roles];
5181
- if (!roles.length) {
5182
- return true;
5183
- }
5184
- roles = flatten(roles.map((role) => USER_ROLES[role]));
5185
- return !!intersection(this.roles, roles).length;
5186
- }
5187
- isOnboarding() {
5188
- return this.status === UserStatusEnum.ON_BOARDING;
5189
- }
5190
- isInactive() {
5191
- return this.status === UserStatusEnum.INACTIVE;
5192
- }
5193
- hasSubscription() {
5194
- return this.roles.includes(UserRolesEnum.SUBSCRIPTION);
5195
- }
5196
- isLoggedIn() {
5197
- return this.id === +localStorage.getItem('userId');
5198
- }
5199
- isClient() {
5200
- return this.roles.includes(UserRolesEnum.CLIENT);
5201
- }
5202
- isEmployee() {
5203
- return this.isAccountant() || this.isAdvisor();
5204
- }
5205
- isAccountant() {
5206
- return this.roles.includes(UserRolesEnum.ACCOUNTANT);
5218
+ return this.method === VehicleClaimDetailsMethodEnum.LOGBOOK;
5207
5219
  }
5208
- isAdvisor() {
5209
- return this.roles.includes(UserRolesEnum.ADVISOR);
5220
+ isKmsMethod() {
5221
+ return this.method === VehicleClaimDetailsMethodEnum.KMS;
5210
5222
  }
5211
- isImpersonator() {
5212
- return this.roles.includes(UserRolesEnum.SWITCH_USER);
5223
+ }
5224
+ __decorate([
5225
+ Type(() => User)
5226
+ ], VehicleClaimDetails.prototype, "user", void 0);
5227
+
5228
+ class VehicleClaim extends VehicleClaim$1 {
5229
+ constructor() {
5230
+ super(...arguments);
5231
+ this.kilometers = 0;
5232
+ this.workUsage = 0;
5213
5233
  }
5214
5234
  /**
5215
- * Check if current user is firm owner
5235
+ * limit for kms claim method
5216
5236
  */
5217
- isFirmOwner() {
5218
- return this.roles.includes(UserRolesEnum.FIRM_OWNER);
5237
+ static { this.totalKmsLimit = 5000; }
5238
+ /**
5239
+ * limit for work usage claim method
5240
+ */
5241
+ static { this.totalWorkUsagePercent = 100; }
5242
+ isWorkTank() {
5243
+ return !this.business;
5219
5244
  }
5220
- isTopManager() {
5221
- return this.roles.includes(UserRolesEnum.FIRM_TOP_MANAGER) || this.roles.includes(UserRolesEnum.FIRM_OWNER);
5245
+ isSoleTank() {
5246
+ return !!this.business;
5222
5247
  }
5223
- isManager() {
5224
- return this.roles.includes(UserRolesEnum.FIRM_MANAGER) || this.roles.includes(UserRolesEnum.FIRM_TOP_MANAGER) || this.roles.includes(UserRolesEnum.FIRM_OWNER);
5248
+ get tankType() {
5249
+ return this.isSoleTank() ? TankTypeEnum.SOLE : TankTypeEnum.WORK;
5225
5250
  }
5226
5251
  /**
5227
- * check if user has property tank access
5252
+ * Claim amount for KMs method. Exists only for KMs method.
5228
5253
  */
5229
- hasPropertyTank() {
5230
- return this.roles ?
5231
- this.roles.includes(UserRolesEnum.PROPERTY_TANK) :
5232
- !!this.getSubscriptionRole(UserRolesEnum.PROPERTY_TANK);
5254
+ getKMSClaimAmount(vehicleClaimRate) {
5255
+ return round(this.kilometers * vehicleClaimRate, 2);
5233
5256
  }
5234
5257
  /**
5235
- * check if user has property tank access
5258
+ * Get logbook claim amount. Exists only for logbook method.
5259
+ * ClaimAmount = WorkUsage * transaction/depreciation amount
5236
5260
  */
5237
- hasWorkTank() {
5238
- return this.roles ?
5239
- this.roles.includes(UserRolesEnum.WORK_TANK) :
5240
- !!this.getSubscriptionRole(UserRolesEnum.WORK_TANK);
5261
+ getLogbookClaimAmount(transactions) {
5262
+ const transactionsAmount = transactions
5263
+ .getByVehicleClaim(this)
5264
+ .getLogbookTransactions()
5265
+ .sumBy('amount');
5266
+ // Math.abs because amount will be negative (because we sum expenses), but we don't want negative percent value
5267
+ return Math.abs(transactionsAmount) * this.workUsage / 100;
5241
5268
  }
5242
- /**
5243
- * Get user subscription role by provided role type
5244
- * @param roleType by which role should be returned
5245
- */
5246
- getSubscriptionRole(roleType) {
5247
- /**
5248
- * Add @TODO for Alex to check if we should use getLastSubscription here
5249
- */
5250
- return this.activeSubscription?.items
5251
- .find((subscriptionItem) => subscriptionItem.price.product.role.includes(roleType));
5269
+ getAverageWeeklyKMS() {
5270
+ return this.kilometers / FinancialYear.weeksInYear;
5252
5271
  }
5253
- isCurrentFinancialYear() {
5254
- return new FinancialYear(new Date()).year === this.financialYear;
5272
+ }
5273
+ __decorate([
5274
+ Type(() => VehicleClaimDetails)
5275
+ ], VehicleClaim.prototype, "details", void 0);
5276
+ __decorate([
5277
+ Type(() => SoleBusiness)
5278
+ ], VehicleClaim.prototype, "business", void 0);
5279
+
5280
+ /**
5281
+ * Depreciation Nested Tree node with depreciations group
5282
+ */
5283
+ class DepreciationGroup {
5284
+ constructor(label, description, icon, children, totalCost, openingValue) {
5285
+ this.label = label;
5286
+ this.description = description;
5287
+ this.icon = icon;
5288
+ this.children = children;
5289
+ this.totalCost = totalCost;
5290
+ this.openingValue = openingValue;
5255
5291
  }
5256
- /**
5257
- * financial years available in the app for user
5258
- * starts from 2022 for new users and registeredYear - 1 for old users
5259
- */
5260
- get financialYears() {
5261
- return range(Math.min(FinancialYear.toFinYear(this.createdAt) - 1, 2022), FinancialYear.toFinYear(new Date()) + 1);
5292
+ getClaimAmount() {
5293
+ return this.children.reduce((sum, child) => sum + child.getClaimAmount(), 0);
5262
5294
  }
5263
- get firmBranchNames() {
5264
- return this.employeeDetails.firmBranchNames;
5295
+ getAmount() {
5296
+ return this.children.reduce((sum, child) => sum + child.getAmount(), 0);
5297
+ }
5298
+ }
5299
+
5300
+ /**
5301
+ * @TODO Alex useless class, use parent instead
5302
+ * Depreciation Tree node with depreciation details
5303
+ */
5304
+ class DepreciationGroupItem extends DepreciationGroup {
5305
+ constructor(depreciation) {
5306
+ super(depreciation.chartAccounts.name, depreciation.description, 'property');
5307
+ this.depreciation = depreciation;
5308
+ }
5309
+ getClaimAmount() {
5310
+ return this.depreciation.currentYearForecast.claimAmount;
5311
+ }
5312
+ getAmount() {
5313
+ return this.depreciation.currentYearForecast.amount;
5265
5314
  }
5266
5315
  }
5316
+
5317
+ var DepreciationGroupEnum;
5318
+ (function (DepreciationGroupEnum) {
5319
+ DepreciationGroupEnum[DepreciationGroupEnum["BUILDING_IMPROVEMENTS"] = 0] = "BUILDING_IMPROVEMENTS";
5320
+ DepreciationGroupEnum[DepreciationGroupEnum["PLANT_EQUIPMENT"] = 1] = "PLANT_EQUIPMENT";
5321
+ DepreciationGroupEnum[DepreciationGroupEnum["LOW_VALUE_POOL"] = 2] = "LOW_VALUE_POOL";
5322
+ DepreciationGroupEnum[DepreciationGroupEnum["WRITTEN_OFF_ITEMS"] = 3] = "WRITTEN_OFF_ITEMS";
5323
+ DepreciationGroupEnum[DepreciationGroupEnum["BORROWING_EXPENSES"] = 4] = "BORROWING_EXPENSES";
5324
+ DepreciationGroupEnum[DepreciationGroupEnum["SMALL_BUSINESS_POOL"] = 5] = "SMALL_BUSINESS_POOL";
5325
+ })(DepreciationGroupEnum || (DepreciationGroupEnum = {}));
5326
+
5327
+ const DEPRECIATION_GROUPS = {
5328
+ [DepreciationGroupEnum.BORROWING_EXPENSES]: {
5329
+ label: 'Borrowing Expenses',
5330
+ description: 'Borrowing expenses on loans are deductible over 1826 days (5 years) starting from the date of a loan',
5331
+ icon: 'loan'
5332
+ },
5333
+ [DepreciationGroupEnum.BUILDING_IMPROVEMENTS]: {
5334
+ label: 'Building & Improvements',
5335
+ description: 'Construction costs, renovations and capital improvements which depreciate at 2.5%',
5336
+ icon: 'building-improvements'
5337
+ },
5338
+ [DepreciationGroupEnum.PLANT_EQUIPMENT]: {
5339
+ label: 'Plant & Equipment',
5340
+ description: 'Assets which decline in value over their useful life (as prescribed by the ATO)',
5341
+ icon: 'plant-equipment'
5342
+ },
5343
+ [DepreciationGroupEnum.LOW_VALUE_POOL]: {
5344
+ label: 'Low Value Pool',
5345
+ description: 'Items under $1,000 are added to the pool to maximise depreciation',
5346
+ icon: 'lvp'
5347
+ },
5348
+ [DepreciationGroupEnum.WRITTEN_OFF_ITEMS]: {
5349
+ label: 'Written Off Items',
5350
+ description: 'Items below $300, replaced or obsolete are fully deductible',
5351
+ icon: 'cart'
5352
+ },
5353
+ [DepreciationGroupEnum.SMALL_BUSINESS_POOL]: {
5354
+ label: 'Small business pool',
5355
+ description: 'The small business pool allows business owners to claim depreciation on plant and equipment items at an accelerated rate.',
5356
+ icon: 'portfolio'
5357
+ },
5358
+ };
5359
+
5360
+ /**
5361
+ * Depreciation Low Value Pool rate based on asset financial year (current or subsequent years).
5362
+ */
5363
+ var DepreciationLvpRateEnum;
5364
+ (function (DepreciationLvpRateEnum) {
5365
+ DepreciationLvpRateEnum[DepreciationLvpRateEnum["FIRST_YEAR"] = 0.1875] = "FIRST_YEAR";
5366
+ DepreciationLvpRateEnum[DepreciationLvpRateEnum["DEFAULT"] = 0.375] = "DEFAULT";
5367
+ })(DepreciationLvpRateEnum || (DepreciationLvpRateEnum = {}));
5368
+
5369
+ class SoleBusiness extends SoleBusiness$1 {
5370
+ /**
5371
+ * Maximum number of businesses that a person can have, according to the ATO
5372
+ */
5373
+ static { this.businessesLimit = 6; }
5374
+ }
5267
5375
  __decorate([
5268
- Type(() => ServiceSubscription)
5269
- ], User.prototype, "subscriptions", void 0);
5376
+ Type(() => User)
5377
+ ], SoleBusiness.prototype, "user", void 0);
5270
5378
  __decorate([
5271
- Type(() => ClientDetails)
5272
- ], User.prototype, "clientDetails", void 0);
5379
+ Type(() => SoleBusinessAllocation)
5380
+ ], SoleBusiness.prototype, "allocations", void 0);
5273
5381
  __decorate([
5274
- Type(() => EmployeeDetails)
5275
- ], User.prototype, "employeeDetails", void 0);
5382
+ Type(() => SoleBusinessLoss)
5383
+ ], SoleBusiness.prototype, "losses", void 0);
5276
5384
  __decorate([
5277
- Type(() => SoleDetails)
5278
- ], User.prototype, "soleDetails", void 0);
5385
+ Type(() => SoleInvoice)
5386
+ ], SoleBusiness.prototype, "invoices", void 0);
5279
5387
  __decorate([
5280
- Type(() => Address)
5281
- ], User.prototype, "address", void 0);
5388
+ Type(() => SoleInvoiceTemplate)
5389
+ ], SoleBusiness.prototype, "invoiceTemplates", void 0);
5282
5390
  __decorate([
5283
- Type(() => Phone)
5284
- ], User.prototype, "phone", void 0);
5391
+ Type(() => VehicleClaim)
5392
+ ], SoleBusiness.prototype, "vehicleClaims", void 0);
5285
5393
  __decorate([
5286
- Type(() => Date)
5287
- ], User.prototype, "createdAt", void 0);
5394
+ Type(() => Transaction)
5395
+ ], SoleBusiness.prototype, "transactions", void 0);
5288
5396
  __decorate([
5289
- Type(() => User)
5290
- ], User.prototype, "clients", void 0);
5397
+ Type(() => Depreciation)
5398
+ ], SoleBusiness.prototype, "depreciations", void 0);
5291
5399
  __decorate([
5292
- Type(() => AppFile)
5293
- ], User.prototype, "file", void 0);
5400
+ Type(() => SoleBusinessActivity$1)
5401
+ ], SoleBusiness.prototype, "activity", void 0);
5294
5402
  __decorate([
5295
- Type(() => AccountSetupItem)
5296
- ], User.prototype, "blacklistSetupItems", void 0);
5403
+ Type(() => IncomeSource)
5404
+ ], SoleBusiness.prototype, "incomeSource", void 0);
5405
+ __decorate([
5406
+ Transform(({ value }) => value || false)
5407
+ ], SoleBusiness.prototype, "isPrimaryProduction", void 0);
5408
+ __decorate([
5409
+ Type(() => AppFile)
5410
+ ], SoleBusiness.prototype, "file", void 0);
5297
5411
 
5298
- class SalaryForecast extends SalaryForecast$1 {
5299
- get grossAmount() {
5300
- return this.netPay + this.tax;
5301
- }
5302
- get taxWithheld() {
5303
- return this.grossAmount - this.netPay;
5304
- }
5305
- get monthlyAmount() {
5306
- switch (this.frequency) {
5307
- case SalaryForecastFrequencyEnum.ANNUAL:
5308
- return this.netPay / FinancialYear.monthsInYear;
5309
- case SalaryForecastFrequencyEnum.FORTNIGHTLY:
5310
- return this.netPay * FinancialYear.weeksInYear / FinancialYear.monthsInYear / 2;
5311
- case SalaryForecastFrequencyEnum.WEEKLY:
5312
- return this.netPay * FinancialYear.weeksInYear / FinancialYear.monthsInYear;
5313
- default:
5314
- return this.netPay;
5315
- }
5412
+ class SoleBusinessActivity extends SoleBusinessActivity$1 {
5413
+ }
5414
+
5415
+ var SoleDepreciationMethodEnum;
5416
+ (function (SoleDepreciationMethodEnum) {
5417
+ SoleDepreciationMethodEnum[SoleDepreciationMethodEnum["SBP"] = 1] = "SBP";
5418
+ SoleDepreciationMethodEnum[SoleDepreciationMethodEnum["DEPRECIATION"] = 2] = "DEPRECIATION";
5419
+ })(SoleDepreciationMethodEnum || (SoleDepreciationMethodEnum = {}));
5420
+
5421
+ class SoleDepreciationMethod extends SoleDepreciationMethod$1 {
5422
+ isSBP() {
5423
+ return this.method === SoleDepreciationMethodEnum.SBP;
5316
5424
  }
5317
5425
  }
5318
- __decorate([
5319
- Type(() => Number)
5320
- ], SalaryForecast.prototype, "tax", void 0);
5321
- __decorate([
5322
- Type(() => Number)
5323
- ], SalaryForecast.prototype, "netPay", void 0);
5324
- __decorate([
5325
- Type(() => IncomeSource)
5326
- ], SalaryForecast.prototype, "incomeSource", void 0);
5426
+
5427
+ class SoleDetails extends SoleDetails$1 {
5428
+ }
5327
5429
  __decorate([
5328
5430
  Type(() => User)
5329
- ], SalaryForecast.prototype, "updatedBy", void 0);
5431
+ ], SoleDetails.prototype, "user", void 0);
5330
5432
 
5331
- class SoleForecast extends SoleForecast$1 {
5332
- get netPay() {
5333
- return this.amount;
5433
+ class BasReport extends BasReport$1 {
5434
+ get taxWithheldTotal() {
5435
+ return this.taxWithheldSalary + this.taxWithheldNoABN;
5436
+ }
5437
+ get paygTaxInstalmentOwedToATO() {
5438
+ return this.paygTaxInstalment > 0 ? this.paygTaxInstalment : 0;
5439
+ }
5440
+ get paygTaxInstalmentOwedByATO() {
5441
+ return this.paygTaxInstalment < 0 ? Math.abs(this.paygTaxInstalment) : 0;
5442
+ }
5443
+ get fuelTaxCreditOwedToATO() {
5444
+ return this.fuelTaxCredit < 0 ? this.fuelTaxCredit : 0;
5445
+ }
5446
+ get fuelTaxCreditOwedByATO() {
5447
+ return this.fuelTaxCredit > 0 ? Math.abs(this.fuelTaxCredit) : 0;
5448
+ }
5449
+ get owesToATO() {
5450
+ return this.incomeGST + this.taxWithheldTotal + this.paygTaxInstalmentOwedToATO + this.fuelTaxCreditOwedToATO;
5451
+ }
5452
+ get owedByATO() {
5453
+ return this.expenseGST + this.paygTaxInstalmentOwedByATO + this.fuelTaxCreditOwedByATO;
5454
+ }
5455
+ /**
5456
+ * GST payable to the ATO, or refundable from the ATO in case it's negative
5457
+ */
5458
+ get gst() {
5459
+ if (!this.id) {
5460
+ return 0;
5461
+ }
5462
+ return this.incomeGST + this.expenseGST + this.taxWithheldTotal + this.paygTaxInstalment - this.fuelTaxCredit;
5334
5463
  }
5335
5464
  }
5336
5465
  __decorate([
5337
- Type(() => IncomeSource)
5338
- ], SoleForecast.prototype, "incomeSource", void 0);
5466
+ Type(() => Date)
5467
+ ], BasReport.prototype, "dateFrom", void 0);
5339
5468
  __decorate([
5340
- Type(() => User)
5341
- ], SoleForecast.prototype, "updatedBy", void 0);
5342
-
5343
- var IncomeSourceForecastTrustTypeEnum;
5344
- (function (IncomeSourceForecastTrustTypeEnum) {
5345
- IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["SPECIAL_DISABILITY_TRUST"] = 1] = "SPECIAL_DISABILITY_TRUST";
5346
- IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["DECEASED_ESTATE"] = 2] = "DECEASED_ESTATE";
5347
- IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["FIXED_TRUST"] = 3] = "FIXED_TRUST";
5348
- IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["HYBRID_TRUST"] = 4] = "HYBRID_TRUST";
5349
- IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["DISCRETIONARY_SERVICE_TRUST"] = 5] = "DISCRETIONARY_SERVICE_TRUST";
5350
- IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["DISCRETIONARY_TRADING_TRUST"] = 6] = "DISCRETIONARY_TRADING_TRUST";
5351
- IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["DISCRETIONARY_INVESTMENT_TRUST"] = 7] = "DISCRETIONARY_INVESTMENT_TRUST";
5352
- IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["CASH_MANAGEMENT_UNIT_TRUST"] = 8] = "CASH_MANAGEMENT_UNIT_TRUST";
5353
- IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["PUBLIC_UNIT_TRUST_LISTED"] = 9] = "PUBLIC_UNIT_TRUST_LISTED";
5354
- IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["PUBLIC_UNIT_TRUST_UNLISTED"] = 10] = "PUBLIC_UNIT_TRUST_UNLISTED";
5355
- IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["TESTAMENTARY_TRUST"] = 11] = "TESTAMENTARY_TRUST";
5356
- })(IncomeSourceForecastTrustTypeEnum || (IncomeSourceForecastTrustTypeEnum = {}));
5357
-
5358
- var IncomeSourceTypeListOtherEnum;
5359
- (function (IncomeSourceTypeListOtherEnum) {
5360
- IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["PSI"] = 6] = "PSI";
5361
- IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
5362
- IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["TRUSTS"] = 9] = "TRUSTS";
5363
- IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["OTHER_INCOME"] = 10] = "OTHER_INCOME";
5364
- IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["PARTNERSHIPS"] = 12] = "PARTNERSHIPS";
5365
- })(IncomeSourceTypeListOtherEnum || (IncomeSourceTypeListOtherEnum = {}));
5366
-
5367
- var IncomeSourceTypeListSoleEnum;
5368
- (function (IncomeSourceTypeListSoleEnum) {
5369
- IncomeSourceTypeListSoleEnum[IncomeSourceTypeListSoleEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
5370
- })(IncomeSourceTypeListSoleEnum || (IncomeSourceTypeListSoleEnum = {}));
5469
+ Type(() => Date)
5470
+ ], BasReport.prototype, "dateTo", void 0);
5371
5471
 
5372
- var IncomeSourceTypeListWorkEnum;
5373
- (function (IncomeSourceTypeListWorkEnum) {
5374
- IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["BONUSES"] = 1] = "BONUSES";
5375
- IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["DIRECTOR_FEES"] = 2] = "DIRECTOR_FEES";
5376
- IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["INTEREST"] = 4] = "INTEREST";
5377
- IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["PENSIONS_AND_ALLOWANCES"] = 5] = "PENSIONS_AND_ALLOWANCES";
5378
- IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["SUPERANNUATION"] = 8] = "SUPERANNUATION";
5379
- IncomeSourceTypeListWorkEnum[IncomeSourceTypeListWorkEnum["ATTRIBUTED_P_S_I"] = 11] = "ATTRIBUTED_P_S_I";
5380
- })(IncomeSourceTypeListWorkEnum || (IncomeSourceTypeListWorkEnum = {}));
5472
+ class SetupItem extends AbstractModel {
5473
+ }
5381
5474
 
5382
- var IncomeSourceTypeListHoldingEnum;
5383
- (function (IncomeSourceTypeListHoldingEnum) {
5384
- IncomeSourceTypeListHoldingEnum[IncomeSourceTypeListHoldingEnum["DIVIDENDS"] = 3] = "DIVIDENDS";
5385
- IncomeSourceTypeListHoldingEnum[IncomeSourceTypeListHoldingEnum["INTEREST"] = 4] = "INTEREST";
5386
- IncomeSourceTypeListHoldingEnum[IncomeSourceTypeListHoldingEnum["TRUSTS"] = 9] = "TRUSTS";
5387
- IncomeSourceTypeListHoldingEnum[IncomeSourceTypeListHoldingEnum["OTHER_INCOME"] = 10] = "OTHER_INCOME";
5388
- IncomeSourceTypeListHoldingEnum[IncomeSourceTypeListHoldingEnum["PARTNERSHIPS"] = 12] = "PARTNERSHIPS";
5389
- })(IncomeSourceTypeListHoldingEnum || (IncomeSourceTypeListHoldingEnum = {}));
5475
+ /**
5476
+ * Enum list of all possible account setup items ids. Using with [ACCOUNT_SETUP_ITEMS]{@link ACCOUNT_SETUP_ITEMS}
5477
+ * @TODO Vik/Nikita: Do we need to generate it from backend? If some ids changed?
5478
+ */
5479
+ var AccountSetupItemsEnum;
5480
+ (function (AccountSetupItemsEnum) {
5481
+ AccountSetupItemsEnum[AccountSetupItemsEnum["SALARY"] = 1] = "SALARY";
5482
+ AccountSetupItemsEnum[AccountSetupItemsEnum["OTHER_INCOME"] = 2] = "OTHER_INCOME";
5483
+ AccountSetupItemsEnum[AccountSetupItemsEnum["PROPERTY"] = 3] = "PROPERTY";
5484
+ AccountSetupItemsEnum[AccountSetupItemsEnum["BANK_FEEDS"] = 4] = "BANK_FEEDS";
5485
+ AccountSetupItemsEnum[AccountSetupItemsEnum["WORK_LOGBOOK"] = 5] = "WORK_LOGBOOK";
5486
+ AccountSetupItemsEnum[AccountSetupItemsEnum["TRANSACTION_ALLOCATE"] = 6] = "TRANSACTION_ALLOCATE";
5487
+ AccountSetupItemsEnum[AccountSetupItemsEnum["SOLE_BUSINESS"] = 7] = "SOLE_BUSINESS";
5488
+ AccountSetupItemsEnum[AccountSetupItemsEnum["HOLDINGS"] = 8] = "HOLDINGS";
5489
+ AccountSetupItemsEnum[AccountSetupItemsEnum["FIRM_DETAILS"] = 9] = "FIRM_DETAILS";
5490
+ AccountSetupItemsEnum[AccountSetupItemsEnum["INVITE_TEAM"] = 10] = "INVITE_TEAM";
5491
+ AccountSetupItemsEnum[AccountSetupItemsEnum["INVITE_CLIENTS"] = 11] = "INVITE_CLIENTS";
5492
+ })(AccountSetupItemsEnum || (AccountSetupItemsEnum = {}));
5390
5493
 
5391
- class IncomeSourceType extends IncomeSourceType$1 {
5392
- isBonuses() {
5393
- return this.id === IncomeSourceTypeListWorkEnum.BONUSES;
5494
+ class AccountSetupItem extends SetupItem {
5495
+ get isSalary() {
5496
+ return this.id === AccountSetupItemsEnum.SALARY;
5394
5497
  }
5395
- isWork() {
5396
- return !!IncomeSourceTypeListWorkEnum[this.id];
5498
+ get isOtherIncome() {
5499
+ return this.id === AccountSetupItemsEnum.OTHER_INCOME;
5397
5500
  }
5398
- isOther() {
5399
- return !!IncomeSourceTypeListOtherEnum[this.id];
5501
+ get isProperty() {
5502
+ return this.id === AccountSetupItemsEnum.PROPERTY;
5400
5503
  }
5401
- isHolding() {
5402
- return !!IncomeSourceTypeListHoldingEnum[this.id];
5504
+ get isBankFeeds() {
5505
+ return this.id === AccountSetupItemsEnum.BANK_FEEDS;
5403
5506
  }
5404
- isSole() {
5405
- return !!IncomeSourceTypeListSoleEnum[this.id];
5507
+ get isWorkLogbook() {
5508
+ return this.id === AccountSetupItemsEnum.WORK_LOGBOOK;
5406
5509
  }
5407
- }
5408
-
5409
- class IncomeSourceForecast extends IncomeSourceForecast$1 {
5410
- constructor() {
5411
- super(...arguments);
5412
- this.paygIncome = 0;
5413
- this.frequency = SalaryForecastFrequencyEnum.ANNUAL;
5414
- this.isTaxFree = false;
5510
+ get isTransactionAllocate() {
5511
+ return this.id === AccountSetupItemsEnum.TRANSACTION_ALLOCATE;
5415
5512
  }
5416
- /**
5417
- * Sometimes Income source has Salary & Income source forecasts,
5418
- * and we need these fields to work with Income source forecasts like with Salary Forecasts
5419
- */
5420
- get netPay() {
5421
- return this.amount;
5513
+ get isSoleBusiness() {
5514
+ return this.id === AccountSetupItemsEnum.SOLE_BUSINESS;
5422
5515
  }
5423
- get grossAmount() {
5424
- return this.amount + this.tax + this.taxInstalments + this.frankingCredits;
5516
+ get isHoldings() {
5517
+ return this.id === AccountSetupItemsEnum.HOLDINGS;
5425
5518
  }
5426
- get monthlyAmount() {
5427
- return this.amount / 12;
5519
+ get isFirmDetails() {
5520
+ return this.id === AccountSetupItemsEnum.FIRM_DETAILS;
5521
+ }
5522
+ get isInviteTeam() {
5523
+ return this.id === AccountSetupItemsEnum.INVITE_TEAM;
5524
+ }
5525
+ get isInviteClients() {
5526
+ return this.id === AccountSetupItemsEnum.INVITE_CLIENTS;
5428
5527
  }
5429
5528
  }
5430
- __decorate([
5431
- Type(() => IncomeSourceType)
5432
- ], IncomeSourceForecast.prototype, "incomeSourceType", void 0);
5433
- __decorate([
5434
- Type(() => IncomeSource)
5435
- ], IncomeSourceForecast.prototype, "incomeSource", void 0);
5436
5529
 
5437
- class IncomeSource extends IncomeSource$1 {
5438
- isSoleIncome() {
5439
- return this.type === IncomeSourceTypeEnum.SOLE;
5530
+ class User extends User$1 {
5531
+ constructor() {
5532
+ super(...arguments);
5533
+ this.blacklistSetupItems = [];
5440
5534
  }
5441
- isWorkIncome() {
5442
- return this.type === IncomeSourceTypeEnum.WORK;
5535
+ get fullName() {
5536
+ return `${this.firstName} ${this.lastName}`;
5443
5537
  }
5444
- isOtherIncome() {
5445
- return this.type === IncomeSourceTypeEnum.OTHER;
5538
+ get photo() {
5539
+ return this.file?.publicUrl;
5446
5540
  }
5447
- isHolding() {
5448
- return this.type === IncomeSourceTypeEnum.HOLDING;
5541
+ get activeSubscription() {
5542
+ return this.subscriptions.find((ss) => ss.isActive);
5449
5543
  }
5450
- /**
5451
- * Get salary and other income forecasts
5452
- */
5453
- get forecasts() {
5454
- return [...this.salaryForecasts, ...this.incomeSourceForecasts, ...this.soleForecasts];
5544
+ get lastSubscription() {
5545
+ return this.subscriptions[this.subscriptions.length - 1];
5455
5546
  }
5456
5547
  /**
5457
- * Get actual (1st from the list) forecast
5548
+ * @TODO refactor
5549
+ *
5458
5550
  */
5459
- get actualForecast() {
5460
- return this.forecasts[0];
5551
+ get position() {
5552
+ switch (true) {
5553
+ case this.isFirmOwner():
5554
+ return USER_WORK_POSITION[UserRolesEnum.FIRM_OWNER];
5555
+ case this.isManager():
5556
+ return USER_WORK_POSITION[UserRolesEnum.FIRM_MANAGER];
5557
+ case this.isEmployee():
5558
+ return USER_WORK_POSITION[UserRolesEnum.EMPLOYEE];
5559
+ default:
5560
+ return '';
5561
+ }
5461
5562
  }
5462
5563
  /**
5463
- * Check if user was working in month taken by the index
5464
- * @param monthIndex by which month should be taken
5564
+ * search roles including hierarchy
5465
5565
  */
5466
- isWorkedInMonth(monthIndex) {
5467
- const monthDate = new FinancialYear().getMonthDate(monthIndex);
5468
- return (!this.dateFrom || monthDate >= this.dateFrom) && (!this.dateTo || monthDate < this.dateTo);
5566
+ hasRoles(roles) {
5567
+ roles = roles instanceof Array ? roles : [roles];
5568
+ if (!roles.length) {
5569
+ return true;
5570
+ }
5571
+ roles = flatten(roles.map((role) => USER_ROLES[role]));
5572
+ return !!intersection(this.roles, roles).length;
5573
+ }
5574
+ isOnboarding() {
5575
+ return this.status === UserStatusEnum.ON_BOARDING;
5576
+ }
5577
+ isInactive() {
5578
+ return this.status === UserStatusEnum.INACTIVE;
5579
+ }
5580
+ hasSubscription() {
5581
+ return this.roles.includes(UserRolesEnum.SUBSCRIPTION);
5582
+ }
5583
+ isLoggedIn() {
5584
+ return this.id === +localStorage.getItem('userId');
5585
+ }
5586
+ isClient() {
5587
+ return this.roles.includes(UserRolesEnum.CLIENT);
5588
+ }
5589
+ isEmployee() {
5590
+ return this.isAccountant() || this.isAdvisor();
5591
+ }
5592
+ isAccountant() {
5593
+ return this.roles.includes(UserRolesEnum.ACCOUNTANT);
5594
+ }
5595
+ isAdvisor() {
5596
+ return this.roles.includes(UserRolesEnum.ADVISOR);
5469
5597
  }
5470
- }
5471
- __decorate([
5472
- Type(() => SalaryForecast)
5473
- ], IncomeSource.prototype, "salaryForecasts", void 0);
5474
- __decorate([
5475
- Type(() => SoleForecast)
5476
- ], IncomeSource.prototype, "soleForecasts", void 0);
5477
- __decorate([
5478
- Type(() => IncomeSourceForecast)
5479
- ], IncomeSource.prototype, "incomeSourceForecasts", void 0);
5480
- __decorate([
5481
- Type(() => Date)
5482
- ], IncomeSource.prototype, "dateFrom", void 0);
5483
- __decorate([
5484
- Type(() => Date)
5485
- ], IncomeSource.prototype, "dateTo", void 0);
5486
-
5487
- /**
5488
- * Income sources chart data
5489
- */
5490
- class IncomeSourceChartData {
5491
- constructor(forecastedIncomeAmount, transactions) {
5492
- this.forecastedIncomeAmount = forecastedIncomeAmount;
5493
- this.transactions = transactions;
5598
+ isImpersonator() {
5599
+ return this.roles.includes(UserRolesEnum.SWITCH_USER);
5494
5600
  }
5495
5601
  /**
5496
- * Get prepared data for income sources chart
5602
+ * Check if current user is firm owner
5497
5603
  */
5498
- get() {
5499
- const chartData = [{
5500
- id: 'actualIncome',
5501
- name: 'Actual Income',
5502
- data: [],
5503
- // display future actual incomes with dash line and past actual incomes with solid line
5504
- zones: [{
5505
- // line style after current month
5506
- value: new FinancialYear().getMonthDate(new Date().getMonth()).getTime(),
5507
- dashStyle: 'Solid'
5508
- }, {
5509
- // default line style
5510
- dashStyle: 'Dash'
5511
- }]
5512
- }, {
5513
- id: 'forecastedIncome',
5514
- name: 'Forecasted Income',
5515
- data: [],
5516
- }];
5517
- for (const key in MonthNameShortEnum) {
5518
- if (MonthNameShortEnum.hasOwnProperty(key)) {
5519
- // transaction collection for provided month
5520
- const monthTransactionCollection = this.transactions.getByMonth(+MonthNumberEnum[key]);
5521
- chartData[0].data.push([new FinancialYear().getMonthDate(+MonthNumberEnum[key]).getTime(), monthTransactionCollection.amount]);
5522
- chartData[1].data.push([new FinancialYear().getMonthDate(+MonthNumberEnum[key]).getTime(), this.forecastedIncomeAmount / 12]);
5523
- }
5524
- }
5525
- return chartData;
5526
- }
5527
- }
5528
-
5529
- class AllocationRuleTransaction extends AllocationRuleTransaction$1 {
5530
- constructor() {
5531
- super(...arguments);
5532
- this.claimPercent = 100;
5533
- this.tax = 0;
5534
- this.amount = null;
5604
+ isFirmOwner() {
5605
+ return this.roles.includes(UserRolesEnum.FIRM_OWNER);
5535
5606
  }
5536
- get amountPercentCoefficient() {
5537
- return this.amountPercent ? this.amountPercent / 100 : 1;
5607
+ isTopManager() {
5608
+ return this.roles.includes(UserRolesEnum.FIRM_TOP_MANAGER) || this.roles.includes(UserRolesEnum.FIRM_OWNER);
5538
5609
  }
5539
- calculateClaimPercent() {
5540
- if (!this.chartAccounts) {
5541
- return null;
5542
- }
5543
- let claimPercent = this.chartAccounts.taxablePercent;
5544
- // Property claim (ownership% x shared%) for property expenses, taxable percent for others
5545
- if (this.chartAccounts?.isProperty() && this.property) {
5546
- if (this.chartAccounts.isPropertyExpense() && this.chartAccounts.id !== ChartAccountsListEnum.PLATFORM_FEES) {
5547
- claimPercent *= this.property?.claimCoefficient;
5548
- }
5549
- }
5550
- return claimPercent;
5610
+ isManager() {
5611
+ return this.roles.includes(UserRolesEnum.FIRM_MANAGER) || this.roles.includes(UserRolesEnum.FIRM_TOP_MANAGER) || this.roles.includes(UserRolesEnum.FIRM_OWNER);
5551
5612
  }
5552
5613
  /**
5553
- * If rule transaction has amount then split enabled. There is 0 when split disabled
5614
+ * check if user has property tank access
5554
5615
  */
5555
- isSplit() {
5556
- return !!this.amountPercent;
5616
+ hasPropertyTank() {
5617
+ return this.roles ?
5618
+ this.roles.includes(UserRolesEnum.PROPERTY_TANK) :
5619
+ !!this.getSubscriptionRole(UserRolesEnum.PROPERTY_TANK);
5557
5620
  }
5558
5621
  /**
5559
- * Create Transaction instance based on passed bank transaction and rule transaction
5622
+ * check if user has property tank access
5560
5623
  */
5561
- toTransaction(bankTransaction = null) {
5562
- const transaction = bankTransaction ? bankTransaction.toTransaction(this.isGST) : plainToClass(Transaction, {});
5563
- Object.assign(transaction, {
5564
- isGST: this.isGST,
5565
- tax: this.tax,
5566
- claimPercent: this.claimPercent,
5567
- chartAccounts: this.chartAccounts,
5568
- property: this.property,
5569
- loan: this.loan,
5570
- incomeSource: this.incomeSource,
5571
- metaFields: this.metaFields,
5572
- business: this.business,
5573
- source: TransactionSourceEnum.BANK_TRANSACTION,
5574
- operation: TransactionOperationEnum.ALLOCATE,
5575
- transactions: [],
5576
- });
5577
- // split allocation
5578
- if (this.amountPercent) {
5579
- transaction.amount = bankTransaction.amount * this.amountPercentCoefficient / this.gstCoefficient;
5580
- }
5581
- // child transactions inherit most of the fields from parent transaction
5582
- this.childTransactions.forEach((childRuleTransaction) => {
5583
- const childTransaction = childRuleTransaction.toTransaction();
5584
- childTransaction.amount = childRuleTransaction.amount;
5585
- childTransaction.setParent(transaction);
5586
- transaction.transactions.push(childTransaction);
5587
- });
5588
- return transaction;
5624
+ hasWorkTank() {
5625
+ return this.roles ?
5626
+ this.roles.includes(UserRolesEnum.WORK_TANK) :
5627
+ !!this.getSubscriptionRole(UserRolesEnum.WORK_TANK);
5589
5628
  }
5590
- }
5591
- __decorate([
5592
- Type(() => ChartAccounts)
5593
- // @TODO Alex: Create custom decorator for this transform
5594
- ,
5595
- Transform(({ value }) => ({ id: value.id }), { toPlainOnly: true })
5596
- ], AllocationRuleTransaction.prototype, "chartAccounts", void 0);
5597
- __decorate([
5598
- Type(() => Property),
5599
- Transform(({ value }) => value ? { id: value.id } : null, { toPlainOnly: true })
5600
- ], AllocationRuleTransaction.prototype, "property", void 0);
5601
- __decorate([
5602
- Type(() => Loan),
5603
- Transform(({ value }) => value ? { id: value.id } : null, { toPlainOnly: true })
5604
- ], AllocationRuleTransaction.prototype, "loan", void 0);
5605
- __decorate([
5606
- Type(() => IncomeSource),
5607
- Transform(({ value }) => value ? { id: value.id } : null, { toPlainOnly: true })
5608
- ], AllocationRuleTransaction.prototype, "incomeSource", void 0);
5609
- __decorate([
5610
- Type(() => SoleBusiness),
5611
- Transform(({ value }) => value ? { id: value.id } : null, { toPlainOnly: true })
5612
- ], AllocationRuleTransaction.prototype, "business", void 0);
5613
- __decorate([
5614
- Type(() => AllocationRuleTransactionMetaField)
5615
- ], AllocationRuleTransaction.prototype, "metaFields", void 0);
5616
- __decorate([
5617
- Type(() => AllocationRuleTransaction)
5618
- ], AllocationRuleTransaction.prototype, "parentTransaction", void 0);
5619
- __decorate([
5620
- Type(() => AllocationRuleTransaction)
5621
- ], AllocationRuleTransaction.prototype, "childTransactions", void 0);
5622
- __decorate([
5623
- Type(() => Number)
5624
- ], AllocationRuleTransaction.prototype, "claimPercent", void 0);
5625
- __decorate([
5626
- Type(() => Number)
5627
- ], AllocationRuleTransaction.prototype, "tax", void 0);
5628
-
5629
- var TransactionTypeEnum;
5630
- (function (TransactionTypeEnum) {
5631
- TransactionTypeEnum[TransactionTypeEnum["DEBIT"] = 1] = "DEBIT";
5632
- TransactionTypeEnum[TransactionTypeEnum["CREDIT"] = 2] = "CREDIT";
5633
- })(TransactionTypeEnum || (TransactionTypeEnum = {}));
5634
-
5635
- class TaxExemption extends TaxExemption$1 {
5636
- isPartial() {
5637
- return [TaxExemptionEnum.INVESTMENT_TO_PPR, TaxExemptionEnum.PPR_TO_INVESTMENT].includes(this.id);
5629
+ /**
5630
+ * Get user subscription role by provided role type
5631
+ * @param roleType by which role should be returned
5632
+ */
5633
+ getSubscriptionRole(roleType) {
5634
+ /**
5635
+ * Add @TODO for Alex to check if we should use getLastSubscription here
5636
+ */
5637
+ return this.activeSubscription?.items
5638
+ .find((subscriptionItem) => subscriptionItem.price.product.role.includes(roleType));
5638
5639
  }
5639
- }
5640
-
5641
- class AssetSale extends ObservableModel {
5642
- static { this.className = 'AssetSale'; }
5643
- }
5644
- __decorate([
5645
- Type(() => Date)
5646
- ], AssetSale.prototype, "date", void 0);
5647
-
5648
- class PropertySale extends AssetSale {
5649
- get saleCostsTotalAmount() {
5650
- return this.commission + this.legalFees + this.otherCost;
5640
+ isCurrentFinancialYear() {
5641
+ return new FinancialYear(new Date()).year === this.financialYear;
5651
5642
  }
5652
5643
  /**
5653
- * CGT is not applicable for sales with "Principle place of residence" exemption type.
5654
- * https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/4644110466/Tax+Return+MyTax+-+Online+Form ("Capital gains or losses" section)
5644
+ * financial years available in the app for user
5645
+ * starts from 2022 for new users and registeredYear - 1 for old users
5655
5646
  */
5656
- isCGTApplicable() {
5657
- return this.taxExemption?.id !== TaxExemptionEnum.PPR;
5647
+ get financialYears() {
5648
+ return range(Math.min(FinancialYear.toFinYear(this.createdAt) - 1, 2022), FinancialYear.toFinYear(new Date()) + 1);
5658
5649
  }
5659
- get netPrice() {
5660
- return this.price - this.saleCostsTotalAmount;
5650
+ get firmBranchNames() {
5651
+ return this.employeeDetails.firmBranchNames;
5661
5652
  }
5662
5653
  }
5663
5654
  __decorate([
5664
- Type(() => Number)
5665
- ], PropertySale.prototype, "holdingCosts", void 0);
5666
- __decorate([
5667
- Type(() => Number)
5668
- ], PropertySale.prototype, "structuralImprovementsWDV", void 0);
5655
+ Type(() => ServiceSubscription)
5656
+ ], User.prototype, "subscriptions", void 0);
5669
5657
  __decorate([
5670
- Type(() => Number)
5671
- ], PropertySale.prototype, "buildingAtCostClaimed", void 0);
5658
+ Type(() => ClientDetails)
5659
+ ], User.prototype, "clientDetails", void 0);
5672
5660
  __decorate([
5673
- Type(() => Number)
5674
- ], PropertySale.prototype, "price", void 0);
5661
+ Type(() => EmployeeDetails)
5662
+ ], User.prototype, "employeeDetails", void 0);
5675
5663
  __decorate([
5676
- Type(() => Number)
5677
- ], PropertySale.prototype, "commission", void 0);
5664
+ Type(() => SoleDetails)
5665
+ ], User.prototype, "soleDetails", void 0);
5678
5666
  __decorate([
5679
- Type(() => Number)
5680
- ], PropertySale.prototype, "legalFees", void 0);
5667
+ Type(() => Address)
5668
+ ], User.prototype, "address", void 0);
5681
5669
  __decorate([
5682
- Type(() => Number)
5683
- ], PropertySale.prototype, "otherCost", void 0);
5670
+ Type(() => Phone)
5671
+ ], User.prototype, "phone", void 0);
5684
5672
  __decorate([
5685
5673
  Type(() => Date)
5686
- ], PropertySale.prototype, "settlementDate", void 0);
5674
+ ], User.prototype, "createdAt", void 0);
5687
5675
  __decorate([
5688
- Type(() => Date)
5689
- ], PropertySale.prototype, "date", void 0);
5676
+ Type(() => User)
5677
+ ], User.prototype, "clients", void 0);
5690
5678
  __decorate([
5691
- Type(() => TaxExemption)
5692
- ], PropertySale.prototype, "taxExemption", void 0);
5679
+ Type(() => AppFile)
5680
+ ], User.prototype, "file", void 0);
5693
5681
  __decorate([
5694
- Type(() => PropertySaleTaxExemptionMetaField$1)
5695
- ], PropertySale.prototype, "taxExemptionMetaFields", void 0);
5682
+ Type(() => AccountSetupItem)
5683
+ ], User.prototype, "blacklistSetupItems", void 0);
5696
5684
 
5697
5685
  class PropertySubscription extends PropertySubscription$1 {
5698
5686
  }
@@ -5816,9 +5804,6 @@ __decorate([
5816
5804
  __decorate([
5817
5805
  Transform(({ value }) => +value)
5818
5806
  ], PropertyForecast.prototype, "marketValue", void 0);
5819
- __decorate([
5820
- Type(() => User)
5821
- ], PropertyForecast.prototype, "updatedBy", void 0);
5822
5807
 
5823
5808
  /**
5824
5809
  * propertySale docs - https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/4209508353/Property+Sold+button
@@ -5852,7 +5837,8 @@ class Property extends Property$1 {
5852
5837
  }
5853
5838
  get currentYearForecast() {
5854
5839
  const year = new FinancialYear().year;
5855
- return this.forecasts.find((forecast) => forecast.financialYear === year);
5840
+ return this.forecasts.find((forecast) => forecast.financialYear === year)
5841
+ ?? plainToClass(PropertyForecast, {});
5856
5842
  }
5857
5843
  get forecastedRentalReturn() {
5858
5844
  return this.currentYearForecast?.rentalReturn || 0;