taxtank-core 0.23.0 → 0.23.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2862,22 +2862,33 @@
2862
2862
  * Check if current tank is Property
2863
2863
  */
2864
2864
  TransactionBase.prototype.isPropertyTank = function () {
2865
- var _a;
2866
- return CHART_ACCOUNTS_CATEGORIES.property.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
2865
+ // chart accounts may be empty for new instances
2866
+ if (this.chartAccounts) {
2867
+ return CHART_ACCOUNTS_CATEGORIES.property.includes(this.chartAccounts.category);
2868
+ }
2869
+ return !!this.property;
2867
2870
  };
2868
2871
  /**
2869
2872
  * Check if current tank is Work
2870
2873
  */
2871
2874
  TransactionBase.prototype.isWorkTank = function () {
2872
2875
  var _a;
2873
- return CHART_ACCOUNTS_CATEGORIES.work.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
2876
+ // chart accounts may be empty for new instances
2877
+ if (this.chartAccounts) {
2878
+ return CHART_ACCOUNTS_CATEGORIES.work.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
2879
+ }
2880
+ return !this.isPropertyTank() && !this.isSoleTank();
2874
2881
  };
2875
2882
  /**
2876
2883
  * Check if current tank is Sole
2877
2884
  */
2878
2885
  TransactionBase.prototype.isSoleTank = function () {
2879
2886
  var _a;
2880
- return CHART_ACCOUNTS_CATEGORIES.sole.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
2887
+ // chart accounts may be empty for new instances
2888
+ if (this.chartAccounts) {
2889
+ return CHART_ACCOUNTS_CATEGORIES.sole.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
2890
+ }
2891
+ return !!this.business;
2881
2892
  };
2882
2893
  return TransactionBase;
2883
2894
  }(AbstractModel));
@@ -8268,6 +8279,56 @@
8268
8279
  classTransformer.Type(function () { return ChartSerie; })
8269
8280
  ], ChartData.prototype, "data", void 0);
8270
8281
 
8282
+ /**
8283
+ * @TODO Alex/Vik: think and create some new collection type
8284
+ * @TODO Alex: research all constants and make the same structure
8285
+ */
8286
+ var ChartAccountsCategoryECollection = /** @class */ (function () {
8287
+ function ChartAccountsCategoryECollection(items) {
8288
+ this.items = items || [
8289
+ exports.ChartAccountsCategoryEnum.PROPERTY_INCOME,
8290
+ exports.ChartAccountsCategoryEnum.PROPERTY_EXPENSE,
8291
+ exports.ChartAccountsCategoryEnum.PROPERTY_DEPRECIATION,
8292
+ exports.ChartAccountsCategoryEnum.PROPERTY_CAPITAL_WORKS,
8293
+ exports.ChartAccountsCategoryEnum.WORK_DEPRECIATION,
8294
+ exports.ChartAccountsCategoryEnum.WORK_INCOME,
8295
+ exports.ChartAccountsCategoryEnum.WORK_EXPENSE,
8296
+ exports.ChartAccountsCategoryEnum.OTHER_INCOME,
8297
+ exports.ChartAccountsCategoryEnum.OTHER_EXPENSE,
8298
+ exports.ChartAccountsCategoryEnum.PERSONAL_INCOME,
8299
+ exports.ChartAccountsCategoryEnum.PERSONAL_EXPENSE,
8300
+ exports.ChartAccountsCategoryEnum.SOLE_INCOME,
8301
+ exports.ChartAccountsCategoryEnum.SOLE_EXPENSE,
8302
+ exports.ChartAccountsCategoryEnum.SOLE_DEPRECIATION
8303
+ ];
8304
+ }
8305
+ ChartAccountsCategoryECollection.prototype.getByType = function (types) {
8306
+ var _this = this;
8307
+ if (!Array.isArray(types)) {
8308
+ types = [types];
8309
+ }
8310
+ var items = [];
8311
+ types.forEach(function (type) {
8312
+ var filtered = _this.items.filter(function (item) { return exports.ChartAccountsCategoryEnum[item].includes(type.toUpperCase()); });
8313
+ items.push.apply(items, __spreadArray([], __read(filtered)));
8314
+ });
8315
+ return new ChartAccountsCategoryECollection(items);
8316
+ };
8317
+ ChartAccountsCategoryECollection.prototype.getByTankType = function (tankTypes) {
8318
+ var _this = this;
8319
+ if (!Array.isArray(tankTypes)) {
8320
+ tankTypes = [tankTypes];
8321
+ }
8322
+ var items = [];
8323
+ tankTypes.forEach(function (tankType) {
8324
+ var filtered = _this.items.filter(function (item) { return exports.ChartAccountsCategoryEnum[item].includes(tankType.toUpperCase()); });
8325
+ items.push.apply(items, __spreadArray([], __read(filtered)));
8326
+ });
8327
+ return new ChartAccountsCategoryECollection(items);
8328
+ };
8329
+ return ChartAccountsCategoryECollection;
8330
+ }());
8331
+
8271
8332
  var ChartAccountsDepreciation$1 = /** @class */ (function (_super) {
8272
8333
  __extends(ChartAccountsDepreciation, _super);
8273
8334
  function ChartAccountsDepreciation() {
@@ -15406,7 +15467,13 @@
15406
15467
  }
15407
15468
  TutorialVideoService.prototype.get = function () {
15408
15469
  return this.http.get(TutorialVideoService.googleUrl + "&q='" + TutorialVideoService.parents + "'+in+parents&key=" + this.environment.googleDriveId)
15409
- .pipe(operators.map(function (response) { return response.files; }));
15470
+ .pipe(operators.map(function (response) {
15471
+ // video has a title like "1. Title".
15472
+ response.files.forEach(function (item) {
15473
+ item.name = item.name.split('.', 2)[1];
15474
+ });
15475
+ return response.files;
15476
+ }));
15410
15477
  };
15411
15478
  return TutorialVideoService;
15412
15479
  }());
@@ -15540,6 +15607,27 @@
15540
15607
  return AbstractForm;
15541
15608
  }(forms.FormGroup));
15542
15609
 
15610
+ /**
15611
+ * Check if at least one form field is true, otherwise form is invalid.
15612
+ * Use with groups of boolean form controls (checkbox, toggle, etc.)
15613
+ */
15614
+ function atLeastOneCheckedValidator() {
15615
+ return function (formGroup) {
15616
+ return Object.values(formGroup.controls)
15617
+ .find(function (control) { return control.value; }) ? null : { nothingChecked: true };
15618
+ };
15619
+ }
15620
+
15621
+ /**
15622
+ * Validation function for autocomplete fields. Checks that the user should select a value from a list rather than type in input field
15623
+ * @TODO Alex: create class AppValidators with static methods and move there all custom validators (line Angular Validators)
15624
+ */
15625
+ function autocompleteValidator() {
15626
+ return function (control) {
15627
+ return (!control.value || (typeof control.value === 'object')) ? null : { notFromList: true };
15628
+ };
15629
+ }
15630
+
15543
15631
  function conditionalValidator(condition, validator) {
15544
15632
  return function (control) {
15545
15633
  revalidateOnChanges(control);
@@ -15565,6 +15653,44 @@
15565
15653
  return;
15566
15654
  }
15567
15655
 
15656
+ /**
15657
+ * Regular expressions that are used to check password strength and valid values
15658
+ */
15659
+ var PASSWORD_REGEXPS = {
15660
+ medium: /(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,})/,
15661
+ strong: /(((?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]))|((?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*]))|((?=.*[A-Z])(?=.*[0-9]))(?=.*[!@#$%^&*]))(?=.{8,})/,
15662
+ format: /^[0-9a-zA-Z!@$!%*?&#]*$/
15663
+ };
15664
+ function passwordValidator() {
15665
+ return function (control) {
15666
+ if (!PASSWORD_REGEXPS.format.test(control.value)) {
15667
+ return { passwordInvalid: true };
15668
+ }
15669
+ if (!PASSWORD_REGEXPS.medium.test(control.value)) {
15670
+ return { passwordWeak: true };
15671
+ }
15672
+ return null;
15673
+ };
15674
+ }
15675
+
15676
+ function passwordMatchValidator(newPassControlName, confirmPassControlName) {
15677
+ var _this = this;
15678
+ return function (group) {
15679
+ var passwordControl = group.get(newPassControlName);
15680
+ var confirmControl = group.get(confirmPassControlName);
15681
+ if (confirmControl.errors && !confirmControl.hasError('passwordMismatch')) {
15682
+ // return if another validator has already found an error on the confirmControl
15683
+ return _this;
15684
+ }
15685
+ if (passwordControl.value !== confirmControl.value) {
15686
+ confirmControl.setErrors({ passwordMismatch: true });
15687
+ }
15688
+ else {
15689
+ confirmControl.setErrors(null);
15690
+ }
15691
+ };
15692
+ }
15693
+
15568
15694
  /**
15569
15695
  * Validator that check if sum amount of provided fields is greater than provided sum
15570
15696
  * @param field to check in each formArray element
@@ -15614,7 +15740,7 @@
15614
15740
  this.push(new forms.FormGroup({
15615
15741
  property: new forms.FormControl(null, forms.Validators.required),
15616
15742
  // @TODO disable for loans
15617
- percent: new forms.FormControl({ value: 100, disabled: !this.at(0).contains('percent') }, forms.Validators.required),
15743
+ percent: new forms.FormControl({ value: this.getRemainingPercent(), disabled: !this.at(0).contains('percent') }, forms.Validators.required),
15618
15744
  // @TODO enable for loans
15619
15745
  // amount: new FormControl(
15620
15746
  // {value: this.bankAccount.currentBalance * bankAccountProperty.percent / 100},
@@ -15643,6 +15769,14 @@
15643
15769
  propertyFormGroup.get('percent').disable();
15644
15770
  });
15645
15771
  };
15772
+ /**
15773
+ * Percentage available for adding a new bank account property.
15774
+ * Remaining percent can't be more than 100 and less than 0
15775
+ */
15776
+ BankAccountPropertiesForm.prototype.getRemainingPercent = function () {
15777
+ var currentTotalPercent = this.controls.reduce(function (sum, control) { return sum + control.get('percent').value; }, 0);
15778
+ return currentTotalPercent < 100 ? 100 - currentTotalPercent : 0;
15779
+ };
15646
15780
  return BankAccountPropertiesForm;
15647
15781
  }(forms.FormArray));
15648
15782
 
@@ -15867,65 +16001,6 @@
15867
16001
  return BankLoginForm;
15868
16002
  }(AbstractForm));
15869
16003
 
15870
- /**
15871
- * Check if at least one form field is true, otherwise form is invalid.
15872
- * Use with groups of boolean form controls (checkbox, toggle, etc.)
15873
- */
15874
- function atLeastOneCheckedValidator() {
15875
- return function (formGroup) {
15876
- return Object.values(formGroup.controls)
15877
- .find(function (control) { return control.value; }) ? null : { nothingChecked: true };
15878
- };
15879
- }
15880
-
15881
- /**
15882
- * Validation function for autocomplete fields. Checks that the user should select a value from a list rather than type in input field
15883
- * @TODO Alex: create class AppValidators with static methods and move there all custom validators (line Angular Validators)
15884
- */
15885
- function autocompleteValidator() {
15886
- return function (control) {
15887
- return (!control.value || (typeof control.value === 'object')) ? null : { notFromList: true };
15888
- };
15889
- }
15890
-
15891
- /**
15892
- * Regular expressions that are used to check password strength and valid values
15893
- */
15894
- var PASSWORD_REGEXPS = {
15895
- medium: /(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,})/,
15896
- strong: /(((?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]))|((?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*]))|((?=.*[A-Z])(?=.*[0-9]))(?=.*[!@#$%^&*]))(?=.{8,})/,
15897
- format: /^[0-9a-zA-Z!@$!%*?&#]*$/
15898
- };
15899
- function passwordValidator() {
15900
- return function (control) {
15901
- if (!PASSWORD_REGEXPS.format.test(control.value)) {
15902
- return { passwordInvalid: true };
15903
- }
15904
- if (!PASSWORD_REGEXPS.medium.test(control.value)) {
15905
- return { passwordWeak: true };
15906
- }
15907
- return null;
15908
- };
15909
- }
15910
-
15911
- function passwordMatchValidator(newPassControlName, confirmPassControlName) {
15912
- var _this = this;
15913
- return function (group) {
15914
- var passwordControl = group.get(newPassControlName);
15915
- var confirmControl = group.get(confirmPassControlName);
15916
- if (confirmControl.errors && !confirmControl.hasError('passwordMismatch')) {
15917
- // return if another validator has already found an error on the confirmControl
15918
- return _this;
15919
- }
15920
- if (passwordControl.value !== confirmControl.value) {
15921
- confirmControl.setErrors({ passwordMismatch: true });
15922
- }
15923
- else {
15924
- confirmControl.setErrors(null);
15925
- }
15926
- };
15927
- }
15928
-
15929
16004
  var ClientIncomeTypesForm = /** @class */ (function (_super) {
15930
16005
  __extends(ClientIncomeTypesForm, _super);
15931
16006
  function ClientIncomeTypesForm(clientIncomeTypes) {
@@ -16577,9 +16652,7 @@
16577
16652
  return SoleDetailsForm;
16578
16653
  }(AbstractForm));
16579
16654
 
16580
- /**
16581
- * Public API Surface of tt-core
16582
- */
16655
+ // @TODO Alex: Create indexes everywhere and break this file to imports from indexes
16583
16656
 
16584
16657
  /**
16585
16658
  * Generated bundle index. Do not edit.
@@ -16631,6 +16704,7 @@
16631
16704
  exports.CHART_ACCOUNTS_CATEGORIES = CHART_ACCOUNTS_CATEGORIES;
16632
16705
  exports.CalculationFormItem = CalculationFormItem;
16633
16706
  exports.ChartAccounts = ChartAccounts;
16707
+ exports.ChartAccountsCategoryECollection = ChartAccountsCategoryECollection;
16634
16708
  exports.ChartAccountsCollection = ChartAccountsCollection;
16635
16709
  exports.ChartAccountsDepreciation = ChartAccountsDepreciation;
16636
16710
  exports.ChartAccountsDepreciationService = ChartAccountsDepreciationService;