taxtank-core 0.33.48 → 0.33.51

Sign up to get free protection for your applications and to get access to all the features.
Files changed (23) hide show
  1. package/esm2022/src/lib/collections/sole/sole-invoice.collection.mjs +4 -2
  2. package/esm2022/src/lib/collections/vehicle/best-vehicle-logbook.collection.mjs +6 -2
  3. package/esm2022/src/lib/db/Enums/chart-accounts/business-chart-accounts.enum.mjs +2 -2
  4. package/esm2022/src/lib/db/Enums/chart-accounts/chart-accounts-list.enum.mjs +2 -2
  5. package/esm2022/src/lib/forms/home-office/home-office-calculator.form.mjs +9 -5
  6. package/esm2022/src/lib/forms/home-office/home-office-claim.form.mjs +4 -8
  7. package/esm2022/src/lib/models/home-office/home-office-claim.interface.mjs +1 -1
  8. package/esm2022/src/lib/models/home-office/home-office-claim.mjs +7 -7
  9. package/esm2022/src/lib/models/home-office/home-office-log.mjs +4 -3
  10. package/esm2022/src/lib/models/report/vehicle-expense/vehicle-expense.mjs +1 -1
  11. package/esm2022/src/lib/services/http/home-office/home-office-log.service.mjs +3 -3
  12. package/esm2022/src/lib/services/http/transaction/transaction.service.mjs +8 -2
  13. package/fesm2022/taxtank-core.mjs +35 -23
  14. package/fesm2022/taxtank-core.mjs.map +1 -1
  15. package/package.json +1 -1
  16. package/src/lib/collections/vehicle/best-vehicle-logbook.collection.d.ts +1 -0
  17. package/src/lib/db/Enums/chart-accounts/business-chart-accounts.enum.d.ts +1 -1
  18. package/src/lib/db/Enums/chart-accounts/chart-accounts-list.enum.d.ts +1 -1
  19. package/src/lib/models/home-office/home-office-claim.d.ts +2 -2
  20. package/src/lib/models/home-office/home-office-claim.interface.d.ts +3 -2
  21. package/src/lib/models/home-office/home-office-log.d.ts +3 -2
  22. package/src/lib/services/http/home-office/home-office-log.service.d.ts +3 -3
  23. package/src/lib/services/http/transaction/transaction.service.d.ts +1 -0
@@ -1036,7 +1036,7 @@ var ChartAccountsListEnum;
1036
1036
  ChartAccountsListEnum[ChartAccountsListEnum["INTERNET"] = 94] = "INTERNET";
1037
1037
  ChartAccountsListEnum[ChartAccountsListEnum["ELECTRICITY_AND_GAS"] = 234] = "ELECTRICITY_AND_GAS";
1038
1038
  ChartAccountsListEnum[ChartAccountsListEnum["TELEPHONE"] = 255] = "TELEPHONE";
1039
- ChartAccountsListEnum[ChartAccountsListEnum["HOME_OFFICE_CLEANING"] = 11861] = "HOME_OFFICE_CLEANING";
1039
+ ChartAccountsListEnum[ChartAccountsListEnum["HOME_OFFICE_CLEANING"] = 11871] = "HOME_OFFICE_CLEANING";
1040
1040
  })(ChartAccountsListEnum || (ChartAccountsListEnum = {}));
1041
1041
 
1042
1042
  var BusinessChartAccountsEnum;
@@ -1079,7 +1079,7 @@ var BusinessChartAccountsEnum;
1079
1079
  BusinessChartAccountsEnum[BusinessChartAccountsEnum["ELECTRICITY_AND_GAS"] = 892] = "ELECTRICITY_AND_GAS";
1080
1080
  BusinessChartAccountsEnum[BusinessChartAccountsEnum["HOME_OFFICE_CLEANING"] = 893] = "HOME_OFFICE_CLEANING";
1081
1081
  BusinessChartAccountsEnum[BusinessChartAccountsEnum["INTERNET"] = 705] = "INTERNET";
1082
- BusinessChartAccountsEnum[BusinessChartAccountsEnum["TELEPHONE"] = 11860] = "TELEPHONE";
1082
+ BusinessChartAccountsEnum[BusinessChartAccountsEnum["TELEPHONE"] = 11862] = "TELEPHONE";
1083
1083
  BusinessChartAccountsEnum[BusinessChartAccountsEnum["MOBILE_PHONE"] = 719] = "MOBILE_PHONE";
1084
1084
  BusinessChartAccountsEnum[BusinessChartAccountsEnum["HOME_OFFICE_RENT"] = 889] = "HOME_OFFICE_RENT";
1085
1085
  BusinessChartAccountsEnum[BusinessChartAccountsEnum["HOME_OFFICE_LOAN"] = 890] = "HOME_OFFICE_LOAN";
@@ -8308,8 +8308,9 @@ class SoleInvoiceCollection extends Collection {
8308
8308
  return this.filter((invoice) => invoice.isOverdue());
8309
8309
  }
8310
8310
  getPaid(transactions) {
8311
+ const amountPerInvoice = transactions.getAmountPerInvoice();
8311
8312
  return this.filter(invoice => invoice.grossPrice > 0
8312
- && transactions.getAmountPerInvoice().get(invoice.id) >= invoice.grossPrice);
8313
+ && round(amountPerInvoice.get(invoice.id), 2) >= invoice.grossPrice);
8313
8314
  }
8314
8315
  getUnpaid(transactions) {
8315
8316
  return this.getOpen().filter(invoice => transactions.getAmountPerInvoice().get(invoice.id) < invoice.grossPrice);
@@ -8731,9 +8732,10 @@ class BestVehicleLogbookCollection extends VehicleLogbookCollection {
8731
8732
  }
8732
8733
  /**
8733
8734
  * Best period may be calculated only when user has logbooks minimum for VehicleLogbook.bestPeriodWeeks
8735
+ * and has at least one work/business trip
8734
8736
  */
8735
8737
  static isBestPeriodExist(logbooks) {
8736
- if (logbooks.length < 2) {
8738
+ if (logbooks.length < 2 || !logbooks.getClaimable().length) {
8737
8739
  return false;
8738
8740
  }
8739
8741
  if (!(logbooks instanceof VehicleLogbookCollection)) {
@@ -8744,6 +8746,9 @@ class BestVehicleLogbookCollection extends VehicleLogbookCollection {
8744
8746
  // get list of date ranges for each of passed logbook
8745
8747
  static getPeriods(logbooks) {
8746
8748
  const claimable = logbooks.getClaimable();
8749
+ if (!claimable.length) {
8750
+ return [];
8751
+ }
8747
8752
  // get a list of date ranges that could potentially be the best
8748
8753
  const periods = claimable
8749
8754
  // skip logbooks whose range ends after the last logbook
@@ -10727,13 +10732,13 @@ __decorate([
10727
10732
  class HomeOfficeClaim extends ObservableModel {
10728
10733
  constructor() {
10729
10734
  super(...arguments);
10730
- this.hours = 0;
10731
10735
  this.electricityAndGas = 0;
10732
10736
  this.cleaning = 0;
10733
10737
  this.internet = 0;
10734
10738
  this.telephone = 0;
10735
10739
  this.mobile = 0;
10736
- this.officePercent = 0;
10740
+ this.occupancyPercent = 0;
10741
+ this.dedicatedOffice = true;
10737
10742
  }
10738
10743
  static { this.className = 'HomeOfficeClaim'; }
10739
10744
  getChartAccountsList() {
@@ -10748,10 +10753,10 @@ class HomeOfficeClaim extends ObservableModel {
10748
10753
  .add(list.TELEPHONE, this.telephone)
10749
10754
  .add(list.MOBILE_PHONE, this.mobile);
10750
10755
  if (this.method === HomeOfficeClaimMethodEnum.OCCUPANCY) {
10751
- claims.add(BusinessChartAccountsEnum.HOME_OFFICE_RENT, this.officePercent);
10752
- claims.add(BusinessChartAccountsEnum.HOME_OFFICE_LOAN, this.officePercent);
10753
- claims.add(BusinessChartAccountsEnum.HOME_OFFICE_RATES, this.officePercent);
10754
- claims.add(BusinessChartAccountsEnum.HOME_OFFICE_OTHER, this.officePercent);
10756
+ claims.add(BusinessChartAccountsEnum.HOME_OFFICE_RENT, this.occupancyPercent);
10757
+ claims.add(BusinessChartAccountsEnum.HOME_OFFICE_LOAN, this.occupancyPercent);
10758
+ claims.add(BusinessChartAccountsEnum.HOME_OFFICE_RATES, this.occupancyPercent);
10759
+ claims.add(BusinessChartAccountsEnum.HOME_OFFICE_OTHER, this.occupancyPercent);
10755
10760
  }
10756
10761
  return claims;
10757
10762
  }
@@ -10763,7 +10768,8 @@ __decorate([
10763
10768
  Type(() => SoleBusiness)
10764
10769
  ], HomeOfficeClaim.prototype, "business", void 0);
10765
10770
 
10766
- class HomeOfficeLog extends AbstractModel {
10771
+ class HomeOfficeLog extends ObservableModel {
10772
+ static { this.className = 'HomeOfficeLog'; }
10767
10773
  }
10768
10774
  __decorate([
10769
10775
  Type(() => HomeOfficeClaim)
@@ -15394,6 +15400,7 @@ class TransactionService extends RestService {
15394
15400
  this.listenDepreciationChange();
15395
15401
  this.listenVehicleClaimChanges();
15396
15402
  this.listenHomeOfficeClaim();
15403
+ this.listenHomeOfficeLog();
15397
15404
  this.listenPropertyForecastUpdate();
15398
15405
  this.listenNotifications();
15399
15406
  }
@@ -15583,6 +15590,11 @@ class TransactionService extends RestService {
15583
15590
  this.refreshCache();
15584
15591
  });
15585
15592
  }
15593
+ listenHomeOfficeLog() {
15594
+ this.eventDispatcherService.on2(...HomeOfficeLog.getEventNames('post', 'put', 'delete')).subscribe(() => {
15595
+ this.refreshCache();
15596
+ });
15597
+ }
15586
15598
  /**
15587
15599
  * property forecast includes claimPercent which affects property related expenses
15588
15600
  * @TODO Alex move to forecast api instead of property
@@ -16453,7 +16465,7 @@ class HomeOfficeLogService extends RestService$1 {
16453
16465
  constructor() {
16454
16466
  super(...arguments);
16455
16467
  this.endpointUri = 'home-office-logs';
16456
- this.modelClass = HomeOfficeClaim;
16468
+ this.modelClass = HomeOfficeLog;
16457
16469
  this.collectionClass = (Collection);
16458
16470
  this.disabledMethods = ['postBatch', 'putBatch', 'deleteBatch'];
16459
16471
  }
@@ -24590,13 +24602,12 @@ class HomeOfficeClaimForm extends AbstractForm {
24590
24602
  constructor(claim = plainToClass(HomeOfficeClaim, {})) {
24591
24603
  super({
24592
24604
  method: new FormControl(claim.method, Validators.required),
24593
- hours: new FormControl(claim.hours, [Validators.required, Validators.min(0), Validators.max(5000)]),
24594
24605
  electricityAndGas: new FormControl(claim.electricityAndGas, [Validators.required, Validators.min(0), Validators.max(100)]),
24595
24606
  cleaning: new FormControl(claim.cleaning, [Validators.required, Validators.min(0), Validators.max(100)]),
24596
24607
  internet: new FormControl(claim.internet, [Validators.required, Validators.min(0), Validators.max(100)]),
24597
24608
  telephone: new FormControl(claim.telephone, [Validators.required, Validators.min(0), Validators.max(100)]),
24598
24609
  mobile: new FormControl(claim.mobile, [Validators.required, Validators.min(0), Validators.max(100)]),
24599
- officePercent: new FormControl(claim.officePercent, [Validators.required, Validators.min(0), Validators.max(100)]),
24610
+ occupancyPercent: new FormControl(claim.occupancyPercent, [Validators.required, Validators.min(0), Validators.max(100)]),
24600
24611
  }, claim);
24601
24612
  this.listenEvents();
24602
24613
  this.switchMethod(claim.method);
@@ -24607,11 +24618,8 @@ class HomeOfficeClaimForm extends AbstractForm {
24607
24618
  });
24608
24619
  }
24609
24620
  switchMethod(method) {
24610
- this.disable({}, [...this.occupancyControls, this.controls.hours]);
24621
+ this.disable({}, this.occupancyControls);
24611
24622
  switch (method) {
24612
- case HomeOfficeClaimMethodEnum.FIXED:
24613
- this.controls.hours.enable();
24614
- break;
24615
24623
  case HomeOfficeClaimMethodEnum.ACTUAL:
24616
24624
  this.enable({}, this.actualControls);
24617
24625
  break;
@@ -24624,7 +24632,7 @@ class HomeOfficeClaimForm extends AbstractForm {
24624
24632
  return [this.controls.electricityAndGas, this.controls.cleaning, this.controls.internet, this.controls.telephone, this.controls.mobile];
24625
24633
  }
24626
24634
  get occupancyControls() {
24627
- return [...this.actualControls, this.controls.officePercent];
24635
+ return [...this.actualControls, this.controls.occupancyPercent];
24628
24636
  }
24629
24637
  }
24630
24638
 
@@ -24642,19 +24650,23 @@ class HomeOfficeCalculatorForm extends AbstractForm {
24642
24650
  constructor(claim = plainToClass(HomeOfficeClaim, {})) {
24643
24651
  super({
24644
24652
  homeArea: new FormControl(claim.homeArea, [Validators.required]),
24645
- officeArea: new FormControl({ value: claim.officeArea, disabled: !!claim.dedicatedOffice }, [Validators.required]),
24653
+ officeArea: new FormControl(claim.officeArea, [Validators.required]),
24646
24654
  dedicatedOffice: new FormControl(claim.dedicatedOffice, [Validators.required]),
24655
+ workUsage: new FormControl({ value: claim.workUsage, disabled: true }, [Validators.required])
24647
24656
  }, claim);
24648
24657
  this.listenEvents();
24649
24658
  }
24650
24659
  listenEvents() {
24651
24660
  this.get('dedicatedOffice').valueChanges.subscribe(() => {
24652
- this.toggleEnabledState(this.get('officeArea'));
24661
+ this.toggleEnabledState(this.get('workUsage'));
24653
24662
  });
24654
24663
  }
24655
24664
  submit() {
24656
- const officePercent = this.value.dedicatedOffice ? 100 : round(this.value.officeArea * 100 / this.value.homeArea, 2);
24657
- return super.submit({ officePercent });
24665
+ let occupancyPercent = this.value.officeArea * 100 / this.value.homeArea;
24666
+ if (!this.value.dedicatedOffice) {
24667
+ occupancyPercent *= this.value.workUsage / 100;
24668
+ }
24669
+ return super.submit({ occupancyPercent: round(occupancyPercent, 2) });
24658
24670
  }
24659
24671
  }
24660
24672