taxtank-core 0.27.6 → 0.28.1

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.
Files changed (27) hide show
  1. package/bundles/taxtank-core.umd.js +95 -21
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/income-source.collection.js +4 -1
  4. package/esm2015/lib/collections/index.js +2 -1
  5. package/esm2015/lib/collections/sole/index.js +2 -0
  6. package/esm2015/lib/collections/sole/sole-invoice.collection.js +13 -0
  7. package/esm2015/lib/db/Models/sole/sole-business.js +1 -1
  8. package/esm2015/lib/forms/sole/sole-business.form.js +24 -3
  9. package/esm2015/lib/models/event/app-event-type.enum.js +21 -20
  10. package/esm2015/lib/models/sole/sole-business.js +5 -1
  11. package/esm2015/lib/models/sole/sole-invoice.js +7 -1
  12. package/esm2015/lib/services/http/income-source/income-source.service.js +12 -1
  13. package/esm2015/lib/services/http/sole/sole-business/sole-business.service.js +10 -1
  14. package/fesm2015/taxtank-core.js +82 -21
  15. package/fesm2015/taxtank-core.js.map +1 -1
  16. package/lib/collections/income-source.collection.d.ts +1 -0
  17. package/lib/collections/index.d.ts +1 -0
  18. package/lib/collections/sole/index.d.ts +1 -0
  19. package/lib/collections/sole/sole-invoice.collection.d.ts +7 -0
  20. package/lib/db/Models/sole/sole-business.d.ts +2 -0
  21. package/lib/forms/sole/sole-business.form.d.ts +2 -0
  22. package/lib/models/event/app-event-type.enum.d.ts +20 -19
  23. package/lib/models/sole/sole-business.d.ts +2 -0
  24. package/lib/models/sole/sole-invoice.d.ts +2 -0
  25. package/lib/services/http/income-source/income-source.service.d.ts +7 -1
  26. package/lib/services/http/sole/sole-business/sole-business.service.d.ts +2 -0
  27. package/package.json +1 -1
@@ -588,25 +588,26 @@
588
588
  AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_DELETED"] = 38] = "PROPERTY_SUBSCRIPTION_DELETED";
589
589
  AppEventTypeEnum[AppEventTypeEnum["PROPERTY_VALUATION_DOCUMENT_CREATED"] = 39] = "PROPERTY_VALUATION_DOCUMENT_CREATED";
590
590
  AppEventTypeEnum[AppEventTypeEnum["SERVICE_SUBSCRIPTION_UPDATED"] = 40] = "SERVICE_SUBSCRIPTION_UPDATED";
591
- AppEventTypeEnum[AppEventTypeEnum["SOLE_DEPRECIATION_METHOD_UPDATED"] = 41] = "SOLE_DEPRECIATION_METHOD_UPDATED";
592
- AppEventTypeEnum[AppEventTypeEnum["TAX_REVIEW_UPDATED"] = 42] = "TAX_REVIEW_UPDATED";
593
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_CREATED"] = 43] = "TRANSACTION_CREATED";
594
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_DELETED"] = 44] = "TRANSACTION_DELETED";
595
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED"] = 45] = "TRANSACTION_UPDATED";
596
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_RECEIPT"] = 46] = "TRANSACTION_UPDATED_WITH_RECEIPT";
597
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_DELETED_RECEIPT"] = 47] = "TRANSACTION_UPDATED_WITH_DELETED_RECEIPT";
598
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_CREATED"] = 48] = "TRANSACTION_RECEIPT_CREATED";
599
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_DELETED"] = 49] = "TRANSACTION_RECEIPT_DELETED";
600
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTIONS_CREATED"] = 50] = "TRANSACTIONS_CREATED";
601
- AppEventTypeEnum[AppEventTypeEnum["USER_UPDATED"] = 51] = "USER_UPDATED";
602
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_UPDATED"] = 52] = "VEHICLE_CLAIM_UPDATED";
603
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 53] = "VEHICLE_CLAIM_CREATED";
604
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_UPDATED"] = 54] = "VEHICLE_CLAIM_DETAILS_UPDATED";
605
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_CREATED"] = 55] = "VEHICLE_CLAIM_DETAILS_CREATED";
606
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_CREATED"] = 56] = "VEHICLE_LOGBOOK_CREATED";
607
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_UPDATED"] = 57] = "VEHICLE_LOGBOOK_UPDATED";
608
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_DELETED"] = 58] = "VEHICLE_LOGBOOK_DELETED";
609
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED"] = 59] = "VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED";
591
+ AppEventTypeEnum[AppEventTypeEnum["SOLE_BUSINESS_CREATED"] = 41] = "SOLE_BUSINESS_CREATED";
592
+ AppEventTypeEnum[AppEventTypeEnum["SOLE_DEPRECIATION_METHOD_UPDATED"] = 42] = "SOLE_DEPRECIATION_METHOD_UPDATED";
593
+ AppEventTypeEnum[AppEventTypeEnum["TAX_REVIEW_UPDATED"] = 43] = "TAX_REVIEW_UPDATED";
594
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_CREATED"] = 44] = "TRANSACTION_CREATED";
595
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_DELETED"] = 45] = "TRANSACTION_DELETED";
596
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED"] = 46] = "TRANSACTION_UPDATED";
597
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_RECEIPT"] = 47] = "TRANSACTION_UPDATED_WITH_RECEIPT";
598
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_DELETED_RECEIPT"] = 48] = "TRANSACTION_UPDATED_WITH_DELETED_RECEIPT";
599
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_CREATED"] = 49] = "TRANSACTION_RECEIPT_CREATED";
600
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_DELETED"] = 50] = "TRANSACTION_RECEIPT_DELETED";
601
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTIONS_CREATED"] = 51] = "TRANSACTIONS_CREATED";
602
+ AppEventTypeEnum[AppEventTypeEnum["USER_UPDATED"] = 52] = "USER_UPDATED";
603
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_UPDATED"] = 53] = "VEHICLE_CLAIM_UPDATED";
604
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 54] = "VEHICLE_CLAIM_CREATED";
605
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_UPDATED"] = 55] = "VEHICLE_CLAIM_DETAILS_UPDATED";
606
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_CREATED"] = 56] = "VEHICLE_CLAIM_DETAILS_CREATED";
607
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_CREATED"] = 57] = "VEHICLE_LOGBOOK_CREATED";
608
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_UPDATED"] = 58] = "VEHICLE_LOGBOOK_UPDATED";
609
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_DELETED"] = 59] = "VEHICLE_LOGBOOK_DELETED";
610
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED"] = 60] = "VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED";
610
611
  })(exports.AppEventTypeEnum || (exports.AppEventTypeEnum = {}));
611
612
 
612
613
  var EventDispatcherService = /** @class */ (function () {
@@ -3332,6 +3333,12 @@
3332
3333
  SoleInvoice.prototype.isPaid = function () {
3333
3334
  return this.status === exports.SoleInvoiceStatusesEnum.PAID;
3334
3335
  };
3336
+ SoleInvoice.prototype.isOverdue = function () {
3337
+ return this.isPending() && this.dateTo < new Date();
3338
+ };
3339
+ SoleInvoice.prototype.isUnpaid = function () {
3340
+ return this.isPending() && this.dateTo >= new Date();
3341
+ };
3335
3342
  return SoleInvoice;
3336
3343
  }(SoleInvoice$1));
3337
3344
  __decorate([
@@ -4673,6 +4680,9 @@
4673
4680
  __decorate([
4674
4681
  classTransformer.Type(function () { return SoleBusinessActivity$1; })
4675
4682
  ], SoleBusiness.prototype, "activity", void 0);
4683
+ __decorate([
4684
+ classTransformer.Type(function () { return IncomeSource; })
4685
+ ], SoleBusiness.prototype, "incomeSource", void 0);
4676
4686
 
4677
4687
  var SoleBusinessActivity = /** @class */ (function (_super) {
4678
4688
  __extends(SoleBusinessActivity, _super);
@@ -6382,6 +6392,23 @@
6382
6392
  return VehicleLogbookCollection;
6383
6393
  }(Collection));
6384
6394
 
6395
+ var SoleInvoiceCollection = /** @class */ (function (_super) {
6396
+ __extends(SoleInvoiceCollection, _super);
6397
+ function SoleInvoiceCollection() {
6398
+ return _super !== null && _super.apply(this, arguments) || this;
6399
+ }
6400
+ SoleInvoiceCollection.prototype.getOverdue = function () {
6401
+ return this.filter(function (invoice) { return invoice.isOverdue(); });
6402
+ };
6403
+ SoleInvoiceCollection.prototype.getUnpaid = function () {
6404
+ return this.filter(function (invoice) { return invoice.isUnpaid(); });
6405
+ };
6406
+ SoleInvoiceCollection.prototype.getPaid = function () {
6407
+ return this.filter(function (invoice) { return invoice.isPaid(); });
6408
+ };
6409
+ return SoleInvoiceCollection;
6410
+ }(Collection));
6411
+
6385
6412
  // @TODO Alex move here all collections
6386
6413
 
6387
6414
  var AccountSetupItemCollection = /** @class */ (function (_super) {
@@ -7114,6 +7141,9 @@
7114
7141
  IncomeSourceCollection.prototype.getSalary = function () {
7115
7142
  return this.items.filter(function (incomeSource) { return incomeSource.isSalaryIncome(); });
7116
7143
  };
7144
+ IncomeSourceCollection.prototype.getOther = function () {
7145
+ return this.items.filter(function (incomeSource) { return incomeSource.isOtherIncome(); });
7146
+ };
7117
7147
  Object.defineProperty(IncomeSourceCollection.prototype, "forecasts", {
7118
7148
  /**
7119
7149
  * Get income sources list of forecasts
@@ -11111,6 +11141,13 @@
11111
11141
  _this.isHydra = true;
11112
11142
  return _this;
11113
11143
  }
11144
+ SoleBusinessService.prototype.add = function (soleBusiness) {
11145
+ var _this = this;
11146
+ return _super.prototype.add.call(this, soleBusiness).pipe(operators.map(function (business) {
11147
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.SOLE_BUSINESS_CREATED, business));
11148
+ return business;
11149
+ }));
11150
+ };
11114
11151
  return SoleBusinessService;
11115
11152
  }(RestService));
11116
11153
  SoleBusinessService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleBusinessService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -12033,6 +12070,9 @@
12033
12070
  _this.incomeSourceTypeSubject = new rxjs.ReplaySubject(1);
12034
12071
  return _this;
12035
12072
  }
12073
+ IncomeSourceService.prototype.listenEvents = function () {
12074
+ this.listenSoleBusinessCreated();
12075
+ };
12036
12076
  /**
12037
12077
  * Get income sources tax calculation
12038
12078
  * @param salaryForecast for which tax should be calculated
@@ -12107,6 +12147,15 @@
12107
12147
  }
12108
12148
  return this.incomeSourceTypeSubject.asObservable();
12109
12149
  };
12150
+ /**
12151
+ * Sole businesses create together with income source
12152
+ */
12153
+ IncomeSourceService.prototype.listenSoleBusinessCreated = function () {
12154
+ var _this = this;
12155
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.SOLE_BUSINESS_CREATED).subscribe(function () {
12156
+ _this.resetCache();
12157
+ });
12158
+ };
12110
12159
  return IncomeSourceService;
12111
12160
  }(RestService));
12112
12161
  IncomeSourceService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IncomeSourceService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -16937,13 +16986,37 @@
16937
16986
  __extends(SoleBusinessForm, _super);
16938
16987
  function SoleBusinessForm(business) {
16939
16988
  if (business === void 0) { business = classTransformer.plainToClass(SoleBusiness, {}); }
16940
- return _super.call(this, {
16989
+ var _this = _super.call(this, {
16941
16990
  name: new forms.FormControl(business.name, forms.Validators.required),
16942
16991
  activity: new forms.FormControl(business.activity, forms.Validators.required),
16943
16992
  description: new forms.FormControl(business.description),
16944
- website: new forms.FormControl(business.website)
16993
+ website: new forms.FormControl(business.website),
16945
16994
  }, business) || this;
16995
+ // User have to create income source with new business.
16996
+ // Income source is not able for edit business
16997
+ if (!business.id) {
16998
+ // @TODO Alex: move to separated form class
16999
+ _this.addControl('incomeSource', new forms.FormGroup({
17000
+ type: new forms.FormControl(exports.IncomeSourceTypeEnum.SOLE, forms.Validators.required),
17001
+ name: new forms.FormControl(null, forms.Validators.required),
17002
+ soleForecasts: new forms.FormArray([
17003
+ new forms.FormGroup({
17004
+ financialYear: new forms.FormControl(new FinancialYear().year, forms.Validators.required),
17005
+ amount: new forms.FormControl(null, forms.Validators.required),
17006
+ taxInstalments: new forms.FormControl(null, forms.Validators.required)
17007
+ })
17008
+ ])
17009
+ }));
17010
+ }
17011
+ return _this;
16946
17012
  }
17013
+ Object.defineProperty(SoleBusinessForm.prototype, "forecastFormGroup", {
17014
+ get: function () {
17015
+ return this.get('incomeSource').get('soleForecasts').at(0);
17016
+ },
17017
+ enumerable: false,
17018
+ configurable: true
17019
+ });
16947
17020
  return SoleBusinessForm;
16948
17021
  }(AbstractForm));
16949
17022
 
@@ -18278,6 +18351,7 @@
18278
18351
  exports.SoleForecast = SoleForecast;
18279
18352
  exports.SoleForecastService = SoleForecastService;
18280
18353
  exports.SoleInvoice = SoleInvoice;
18354
+ exports.SoleInvoiceCollection = SoleInvoiceCollection;
18281
18355
  exports.SoleInvoiceForm = SoleInvoiceForm;
18282
18356
  exports.SoleInvoiceItem = SoleInvoiceItem;
18283
18357
  exports.SoleInvoiceItemForm = SoleInvoiceItemForm;