taxtank-core 0.27.5 → 0.28.0

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 (54) hide show
  1. package/bundles/taxtank-core.umd.js +332 -55
  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/db/Enums/sole-invoice-statuses.enum.js +8 -0
  5. package/esm2015/lib/db/Enums/sole-invoice-template-tax-type.enum.js +7 -0
  6. package/esm2015/lib/db/Models/chart-accounts/chart-accounts.js +1 -1
  7. package/esm2015/lib/db/Models/sole/sole-business.js +1 -1
  8. package/esm2015/lib/db/Models/sole/sole-invoice-template.js +1 -1
  9. package/esm2015/lib/db/Models/sole/sole-invoice.js +1 -1
  10. package/esm2015/lib/forms/bank/bank-account/bank-account-add-manual.form.js +6 -10
  11. package/esm2015/lib/forms/sole/index.js +3 -1
  12. package/esm2015/lib/forms/sole/sole-business.form.js +24 -3
  13. package/esm2015/lib/forms/sole/sole-invoice-item.form.js +43 -0
  14. package/esm2015/lib/forms/sole/sole-invoice-template.form.js +5 -3
  15. package/esm2015/lib/forms/sole/sole-invoice.form.js +51 -0
  16. package/esm2015/lib/models/endpoint/endpoints.const.js +5 -1
  17. package/esm2015/lib/models/event/app-event-type.enum.js +21 -20
  18. package/esm2015/lib/models/sole/sole-business.js +5 -1
  19. package/esm2015/lib/models/sole/sole-details.js +3 -1
  20. package/esm2015/lib/models/sole/sole-invoice-item.js +8 -1
  21. package/esm2015/lib/models/sole/sole-invoice-template.js +12 -2
  22. package/esm2015/lib/models/sole/sole-invoice.js +55 -2
  23. package/esm2015/lib/services/http/income-source/income-source.service.js +12 -1
  24. package/esm2015/lib/services/http/sole/index.js +2 -1
  25. package/esm2015/lib/services/http/sole/sole-business/sole-business.service.js +10 -1
  26. package/esm2015/lib/services/http/sole/sole-invoice/sole-invoice.service.js +21 -0
  27. package/esm2015/public-api.js +3 -1
  28. package/fesm2015/taxtank-core.js +274 -41
  29. package/fesm2015/taxtank-core.js.map +1 -1
  30. package/lib/collections/income-source.collection.d.ts +1 -0
  31. package/lib/db/Enums/sole-invoice-statuses.enum.d.ts +6 -0
  32. package/lib/db/Enums/sole-invoice-template-tax-type.enum.d.ts +5 -0
  33. package/lib/db/Models/chart-accounts/chart-accounts.d.ts +1 -0
  34. package/lib/db/Models/sole/sole-business.d.ts +2 -0
  35. package/lib/db/Models/sole/sole-invoice-template.d.ts +2 -1
  36. package/lib/db/Models/sole/sole-invoice.d.ts +2 -1
  37. package/lib/forms/bank/bank-account/bank-account-add-manual.form.d.ts +1 -3
  38. package/lib/forms/sole/index.d.ts +2 -0
  39. package/lib/forms/sole/sole-business.form.d.ts +2 -0
  40. package/lib/forms/sole/sole-invoice-item.form.d.ts +10 -0
  41. package/lib/forms/sole/sole-invoice-template.form.d.ts +3 -2
  42. package/lib/forms/sole/sole-invoice.form.d.ts +14 -0
  43. package/lib/models/event/app-event-type.enum.d.ts +20 -19
  44. package/lib/models/sole/sole-business.d.ts +2 -0
  45. package/lib/models/sole/sole-details.d.ts +2 -0
  46. package/lib/models/sole/sole-invoice-item.d.ts +2 -0
  47. package/lib/models/sole/sole-invoice-template.d.ts +5 -1
  48. package/lib/models/sole/sole-invoice.d.ts +12 -0
  49. package/lib/services/http/income-source/income-source.service.d.ts +7 -1
  50. package/lib/services/http/sole/index.d.ts +1 -0
  51. package/lib/services/http/sole/sole-business/sole-business.service.d.ts +2 -0
  52. package/lib/services/http/sole/sole-invoice/sole-invoice.service.d.ts +11 -0
  53. package/package.json +1 -1
  54. package/public-api.d.ts +2 -0
@@ -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 () {
@@ -1059,6 +1060,10 @@
1059
1060
  SOLE_BUSINESSES_PUT: new Endpoint('PUT', '\\/sole-businesses\\/\\d+'),
1060
1061
  SOLE_DEPRECIATION_METHODS_GET: new Endpoint('GET', '\\/sole-depreciation-methods'),
1061
1062
  SOLE_DEPRECIATION_METHODS_PUT: new Endpoint('PUT', '\\/sole-depreciation-methods\\/\\d+'),
1063
+ SOLE_INVOICES_GET: new Endpoint('GET', '\\/sole-invoices'),
1064
+ SOLE_INVOICES_POST: new Endpoint('POST', '\\/sole-invoices'),
1065
+ SOLE_INVOICES_PUT: new Endpoint('PUT', '\\/sole-invoices\\/\\d+'),
1066
+ SOLE_INVOICES_DELETE: new Endpoint('DELETE', '\\/sole-invoices\\/\\d+'),
1062
1067
  SOLE_INVOICE_TEMPLATES_GET: new Endpoint('GET', '\\/sole-invoice-templates'),
1063
1068
  SOLE_INVOICE_TEMPLATES_POST: new Endpoint('POST', '\\/sole-invoice-templates'),
1064
1069
  SOLE_INVOICE_TEMPLATES_PUT: new Endpoint('PUT', '\\/sole-invoice-templates\\/\\d+'),
@@ -3126,8 +3131,17 @@
3126
3131
  var SoleInvoiceItem = /** @class */ (function (_super) {
3127
3132
  __extends(SoleInvoiceItem, _super);
3128
3133
  function SoleInvoiceItem() {
3129
- return _super !== null && _super.apply(this, arguments) || this;
3134
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
3135
+ _this.isGST = false;
3136
+ return _this;
3130
3137
  }
3138
+ Object.defineProperty(SoleInvoiceItem.prototype, "amount", {
3139
+ get: function () {
3140
+ return this.price * this.quantity;
3141
+ },
3142
+ enumerable: false,
3143
+ configurable: true
3144
+ });
3131
3145
  return SoleInvoiceItem;
3132
3146
  }(SoleInvoiceItem$1));
3133
3147
  __decorate([
@@ -3188,13 +3202,29 @@
3188
3202
  return SoleInvoiceTemplate;
3189
3203
  }(AbstractModel));
3190
3204
 
3205
+ exports.SoleInvoiceTemplateTaxTypeEnum = void 0;
3206
+ (function (SoleInvoiceTemplateTaxTypeEnum) {
3207
+ SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["EXCLUSIVE"] = 0] = "EXCLUSIVE";
3208
+ SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["INCLUSIVE"] = 1] = "INCLUSIVE";
3209
+ SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["NONE"] = 2] = "NONE";
3210
+ })(exports.SoleInvoiceTemplateTaxTypeEnum || (exports.SoleInvoiceTemplateTaxTypeEnum = {}));
3211
+
3191
3212
  var SoleInvoiceTemplate = /** @class */ (function (_super) {
3192
3213
  __extends(SoleInvoiceTemplate, _super);
3193
3214
  function SoleInvoiceTemplate() {
3194
3215
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
3195
- _this.isTaxIncluded = false;
3216
+ _this.taxType = exports.SoleInvoiceTemplateTaxTypeEnum.NONE;
3196
3217
  return _this;
3197
3218
  }
3219
+ SoleInvoiceTemplate.prototype.isNoTax = function () {
3220
+ return this.taxType === exports.SoleInvoiceTemplateTaxTypeEnum.NONE;
3221
+ };
3222
+ SoleInvoiceTemplate.prototype.isTaxExclusive = function () {
3223
+ return this.taxType === exports.SoleInvoiceTemplateTaxTypeEnum.EXCLUSIVE;
3224
+ };
3225
+ SoleInvoiceTemplate.prototype.isTaxInclusive = function () {
3226
+ return this.taxType === exports.SoleInvoiceTemplateTaxTypeEnum.INCLUSIVE;
3227
+ };
3198
3228
  return SoleInvoiceTemplate;
3199
3229
  }(SoleInvoiceTemplate$1));
3200
3230
  __decorate([
@@ -3204,11 +3234,105 @@
3204
3234
  classTransformer.Type(function () { return BankAccount; })
3205
3235
  ], SoleInvoiceTemplate.prototype, "bankAccount", void 0);
3206
3236
 
3237
+ exports.SoleInvoiceStatusesEnum = void 0;
3238
+ (function (SoleInvoiceStatusesEnum) {
3239
+ SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["CANCELED"] = 0] = "CANCELED";
3240
+ SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["DRAFT"] = 1] = "DRAFT";
3241
+ SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PENDING"] = 2] = "PENDING";
3242
+ SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PAID"] = 3] = "PAID";
3243
+ })(exports.SoleInvoiceStatusesEnum || (exports.SoleInvoiceStatusesEnum = {}));
3244
+
3245
+ var SoleDetails$1 = /** @class */ (function (_super) {
3246
+ __extends(SoleDetails, _super);
3247
+ function SoleDetails() {
3248
+ return _super !== null && _super.apply(this, arguments) || this;
3249
+ }
3250
+ return SoleDetails;
3251
+ }(AbstractModel));
3252
+
3253
+ var SoleDetails = /** @class */ (function (_super) {
3254
+ __extends(SoleDetails, _super);
3255
+ function SoleDetails() {
3256
+ return _super !== null && _super.apply(this, arguments) || this;
3257
+ }
3258
+ return SoleDetails;
3259
+ }(SoleDetails$1));
3260
+ SoleDetails.GSTPercentMultiplier = 0.1;
3261
+ SoleDetails.GSTPercentDivider = 11;
3262
+ __decorate([
3263
+ classTransformer.Type(function () { return User; })
3264
+ ], SoleDetails.prototype, "user", void 0);
3265
+
3207
3266
  var SoleInvoice = /** @class */ (function (_super) {
3208
3267
  __extends(SoleInvoice, _super);
3209
3268
  function SoleInvoice() {
3210
- return _super !== null && _super.apply(this, arguments) || this;
3269
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
3270
+ _this.items = [classTransformer.plainToClass(SoleInvoiceItem, {})];
3271
+ _this.status = exports.SoleInvoiceStatusesEnum.DRAFT;
3272
+ return _this;
3211
3273
  }
3274
+ Object.defineProperty(SoleInvoice.prototype, "amount", {
3275
+ get: function () {
3276
+ return this.items.reduce(function (sum, item) { return sum + item.amount; }, 0);
3277
+ },
3278
+ enumerable: false,
3279
+ configurable: true
3280
+ });
3281
+ SoleInvoice.prototype.getGSTItems = function () {
3282
+ return this.items.filter(function (item) { return item.isGST; });
3283
+ };
3284
+ SoleInvoice.prototype.getGSTItemsAmount = function () {
3285
+ return this.getGSTItems().reduce(function (sum, item) { return sum + item.amount; }, 0);
3286
+ };
3287
+ Object.defineProperty(SoleInvoice.prototype, "subtotal", {
3288
+ get: function () {
3289
+ var _a;
3290
+ if ((_a = this.template) === null || _a === void 0 ? void 0 : _a.isTaxInclusive()) {
3291
+ return this.amount - this.GSTAmount;
3292
+ }
3293
+ return this.amount;
3294
+ },
3295
+ enumerable: false,
3296
+ configurable: true
3297
+ });
3298
+ Object.defineProperty(SoleInvoice.prototype, "GSTAmount", {
3299
+ get: function () {
3300
+ var _a, _b;
3301
+ switch (true) {
3302
+ case (_a = this.template) === null || _a === void 0 ? void 0 : _a.isTaxInclusive():
3303
+ return +(this.getGSTItemsAmount() / SoleDetails.GSTPercentDivider).toFixed(2);
3304
+ case (_b = this.template) === null || _b === void 0 ? void 0 : _b.isTaxExclusive():
3305
+ return +(this.getGSTItemsAmount() * SoleDetails.GSTPercentMultiplier).toFixed(2);
3306
+ default:
3307
+ return 0;
3308
+ }
3309
+ },
3310
+ enumerable: false,
3311
+ configurable: true
3312
+ });
3313
+ Object.defineProperty(SoleInvoice.prototype, "total", {
3314
+ get: function () {
3315
+ var _a;
3316
+ if ((_a = this.template) === null || _a === void 0 ? void 0 : _a.isTaxExclusive()) {
3317
+ return this.amount + this.GSTAmount;
3318
+ }
3319
+ return this.amount;
3320
+ },
3321
+ enumerable: false,
3322
+ configurable: true
3323
+ });
3324
+ SoleInvoice.prototype.isDraft = function () {
3325
+ return this.status === exports.SoleInvoiceStatusesEnum.DRAFT;
3326
+ };
3327
+ SoleInvoice.prototype.isCancelled = function () {
3328
+ return this.status === exports.SoleInvoiceStatusesEnum.CANCELED;
3329
+ };
3330
+ SoleInvoice.prototype.isPending = function () {
3331
+ return this.status === exports.SoleInvoiceStatusesEnum.PENDING;
3332
+ };
3333
+ SoleInvoice.prototype.isPaid = function () {
3334
+ return this.status === exports.SoleInvoiceStatusesEnum.PAID;
3335
+ };
3212
3336
  return SoleInvoice;
3213
3337
  }(SoleInvoice$1));
3214
3338
  __decorate([
@@ -4550,6 +4674,9 @@
4550
4674
  __decorate([
4551
4675
  classTransformer.Type(function () { return SoleBusinessActivity$1; })
4552
4676
  ], SoleBusiness.prototype, "activity", void 0);
4677
+ __decorate([
4678
+ classTransformer.Type(function () { return IncomeSource; })
4679
+ ], SoleBusiness.prototype, "incomeSource", void 0);
4553
4680
 
4554
4681
  var SoleBusinessActivity = /** @class */ (function (_super) {
4555
4682
  __extends(SoleBusinessActivity, _super);
@@ -4584,25 +4711,6 @@
4584
4711
  return SoleDepreciationMethod;
4585
4712
  }(SoleDepreciationMethod$1));
4586
4713
 
4587
- var SoleDetails$1 = /** @class */ (function (_super) {
4588
- __extends(SoleDetails, _super);
4589
- function SoleDetails() {
4590
- return _super !== null && _super.apply(this, arguments) || this;
4591
- }
4592
- return SoleDetails;
4593
- }(AbstractModel));
4594
-
4595
- var SoleDetails = /** @class */ (function (_super) {
4596
- __extends(SoleDetails, _super);
4597
- function SoleDetails() {
4598
- return _super !== null && _super.apply(this, arguments) || this;
4599
- }
4600
- return SoleDetails;
4601
- }(SoleDetails$1));
4602
- __decorate([
4603
- classTransformer.Type(function () { return User; })
4604
- ], SoleDetails.prototype, "user", void 0);
4605
-
4606
4714
  var User = /** @class */ (function (_super) {
4607
4715
  __extends(User, _super);
4608
4716
  function User() {
@@ -7010,6 +7118,9 @@
7010
7118
  IncomeSourceCollection.prototype.getSalary = function () {
7011
7119
  return this.items.filter(function (incomeSource) { return incomeSource.isSalaryIncome(); });
7012
7120
  };
7121
+ IncomeSourceCollection.prototype.getOther = function () {
7122
+ return this.items.filter(function (incomeSource) { return incomeSource.isOtherIncome(); });
7123
+ };
7013
7124
  Object.defineProperty(IncomeSourceCollection.prototype, "forecasts", {
7014
7125
  /**
7015
7126
  * Get income sources list of forecasts
@@ -11007,6 +11118,13 @@
11007
11118
  _this.isHydra = true;
11008
11119
  return _this;
11009
11120
  }
11121
+ SoleBusinessService.prototype.add = function (soleBusiness) {
11122
+ var _this = this;
11123
+ return _super.prototype.add.call(this, soleBusiness).pipe(operators.map(function (business) {
11124
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.SOLE_BUSINESS_CREATED, business));
11125
+ return business;
11126
+ }));
11127
+ };
11010
11128
  return SoleBusinessService;
11011
11129
  }(RestService));
11012
11130
  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 });
@@ -11171,6 +11289,26 @@
11171
11289
  }] }];
11172
11290
  } });
11173
11291
 
11292
+ var SoleInvoiceService = /** @class */ (function (_super) {
11293
+ __extends(SoleInvoiceService, _super);
11294
+ function SoleInvoiceService() {
11295
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
11296
+ _this.modelClass = SoleInvoice;
11297
+ _this.url = 'sole-invoices';
11298
+ _this.isHydra = true;
11299
+ return _this;
11300
+ }
11301
+ return SoleInvoiceService;
11302
+ }(RestService));
11303
+ SoleInvoiceService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleInvoiceService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
11304
+ SoleInvoiceService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleInvoiceService, providedIn: 'root' });
11305
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleInvoiceService, decorators: [{
11306
+ type: i0.Injectable,
11307
+ args: [{
11308
+ providedIn: 'root'
11309
+ }]
11310
+ }] });
11311
+
11174
11312
  var SoleInvoiceTemplateService = /** @class */ (function (_super) {
11175
11313
  __extends(SoleInvoiceTemplateService, _super);
11176
11314
  function SoleInvoiceTemplateService() {
@@ -11909,6 +12047,9 @@
11909
12047
  _this.incomeSourceTypeSubject = new rxjs.ReplaySubject(1);
11910
12048
  return _this;
11911
12049
  }
12050
+ IncomeSourceService.prototype.listenEvents = function () {
12051
+ this.listenSoleBusinessCreated();
12052
+ };
11912
12053
  /**
11913
12054
  * Get income sources tax calculation
11914
12055
  * @param salaryForecast for which tax should be calculated
@@ -11983,6 +12124,15 @@
11983
12124
  }
11984
12125
  return this.incomeSourceTypeSubject.asObservable();
11985
12126
  };
12127
+ /**
12128
+ * Sole businesses create together with income source
12129
+ */
12130
+ IncomeSourceService.prototype.listenSoleBusinessCreated = function () {
12131
+ var _this = this;
12132
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.SOLE_BUSINESS_CREATED).subscribe(function () {
12133
+ _this.resetCache();
12134
+ });
12135
+ };
11986
12136
  return IncomeSourceService;
11987
12137
  }(RestService));
11988
12138
  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 });
@@ -16813,13 +16963,37 @@
16813
16963
  __extends(SoleBusinessForm, _super);
16814
16964
  function SoleBusinessForm(business) {
16815
16965
  if (business === void 0) { business = classTransformer.plainToClass(SoleBusiness, {}); }
16816
- return _super.call(this, {
16966
+ var _this = _super.call(this, {
16817
16967
  name: new forms.FormControl(business.name, forms.Validators.required),
16818
16968
  activity: new forms.FormControl(business.activity, forms.Validators.required),
16819
16969
  description: new forms.FormControl(business.description),
16820
- website: new forms.FormControl(business.website)
16970
+ website: new forms.FormControl(business.website),
16821
16971
  }, business) || this;
16972
+ // User have to create income source with new business.
16973
+ // Income source is not able for edit business
16974
+ if (!business.id) {
16975
+ // @TODO Alex: move to separated form class
16976
+ _this.addControl('incomeSource', new forms.FormGroup({
16977
+ type: new forms.FormControl(exports.IncomeSourceTypeEnum.SOLE, forms.Validators.required),
16978
+ name: new forms.FormControl(null, forms.Validators.required),
16979
+ soleForecasts: new forms.FormArray([
16980
+ new forms.FormGroup({
16981
+ financialYear: new forms.FormControl(new FinancialYear().year, forms.Validators.required),
16982
+ amount: new forms.FormControl(null, forms.Validators.required),
16983
+ taxInstalments: new forms.FormControl(null, forms.Validators.required)
16984
+ })
16985
+ ])
16986
+ }));
16987
+ }
16988
+ return _this;
16822
16989
  }
16990
+ Object.defineProperty(SoleBusinessForm.prototype, "forecastFormGroup", {
16991
+ get: function () {
16992
+ return this.get('incomeSource').get('soleForecasts').at(0);
16993
+ },
16994
+ enumerable: false,
16995
+ configurable: true
16996
+ });
16823
16997
  return SoleBusinessForm;
16824
16998
  }(AbstractForm));
16825
16999
 
@@ -16926,15 +17100,119 @@
16926
17100
  return SoleDetailsForm;
16927
17101
  }(AbstractForm));
16928
17102
 
17103
+ var SoleInvoiceItemForm = /** @class */ (function (_super) {
17104
+ __extends(SoleInvoiceItemForm, _super);
17105
+ function SoleInvoiceItemForm(item) {
17106
+ var _this = this;
17107
+ var _a;
17108
+ _this = _super.call(this, {
17109
+ description: new forms.FormControl(item.description, forms.Validators.required),
17110
+ quantity: new forms.FormControl(item.quantity, forms.Validators.required),
17111
+ price: new forms.FormControl(item.price, forms.Validators.required),
17112
+ isGST: new forms.FormControl({ value: item.isGST, disabled: !((_a = item.chartAccounts) === null || _a === void 0 ? void 0 : _a.isGST) }),
17113
+ chartAccounts: new forms.FormControl(item.chartAccounts, forms.Validators.required)
17114
+ }, item) || this;
17115
+ _this.listenEvents();
17116
+ return _this;
17117
+ }
17118
+ SoleInvoiceItemForm.prototype.listenEvents = function () {
17119
+ this.listenChartAccountsChanges();
17120
+ };
17121
+ SoleInvoiceItemForm.prototype.onTemplateChanged = function (template) {
17122
+ this.template = template;
17123
+ if (this.template.isNoTax()) {
17124
+ this.get('isGST').setValue(false);
17125
+ this.get('isGST').disable();
17126
+ }
17127
+ else {
17128
+ this.get('isGST').enable();
17129
+ }
17130
+ };
17131
+ SoleInvoiceItemForm.prototype.listenChartAccountsChanges = function () {
17132
+ var _this = this;
17133
+ this.get('chartAccounts').valueChanges.subscribe(function (chartAccounts) {
17134
+ if (_this.template.isNoTax()) {
17135
+ return;
17136
+ }
17137
+ if (chartAccounts.isGST) {
17138
+ _this.get('isGST').enable();
17139
+ }
17140
+ else {
17141
+ _this.get('isGST').setValue(false);
17142
+ _this.get('isGST').disable();
17143
+ }
17144
+ });
17145
+ };
17146
+ return SoleInvoiceItemForm;
17147
+ }(AbstractForm));
17148
+
17149
+ var SoleInvoiceForm = /** @class */ (function (_super) {
17150
+ __extends(SoleInvoiceForm, _super);
17151
+ function SoleInvoiceForm(invoice) {
17152
+ var _this = _super.call(this, {
17153
+ dateFrom: new forms.FormControl(invoice.dateFrom, forms.Validators.required),
17154
+ dateTo: new forms.FormControl(invoice.dateTo, forms.Validators.required),
17155
+ items: new forms.FormArray(invoice.items.map(function (item) { return new SoleInvoiceItemForm(item); })),
17156
+ payer: new forms.FormControl(invoice.payer, forms.Validators.required),
17157
+ template: new forms.FormControl(invoice.template, forms.Validators.required)
17158
+ }, invoice) || this;
17159
+ if (invoice.id) {
17160
+ _this.updateItemsForm(invoice.template);
17161
+ }
17162
+ _this.listenEvents();
17163
+ return _this;
17164
+ }
17165
+ Object.defineProperty(SoleInvoiceForm.prototype, "items", {
17166
+ get: function () {
17167
+ return this.get('items');
17168
+ },
17169
+ enumerable: false,
17170
+ configurable: true
17171
+ });
17172
+ SoleInvoiceForm.prototype.listenEvents = function () {
17173
+ this.listenTemplateChanges();
17174
+ };
17175
+ SoleInvoiceForm.prototype.addItem = function () {
17176
+ this.items.push(new SoleInvoiceItemForm(classTransformer.plainToClass(SoleInvoiceItem, {})));
17177
+ };
17178
+ SoleInvoiceForm.prototype.removeItem = function (index) {
17179
+ // do not remove the last item
17180
+ if (this.items.length === 1) {
17181
+ return;
17182
+ }
17183
+ this.items.removeAt(index);
17184
+ };
17185
+ SoleInvoiceForm.prototype.submit = function (data) {
17186
+ if (data === void 0) { data = {}; }
17187
+ var items = this.items.controls.map(function (control) { return control.submit(); });
17188
+ return _super.prototype.submit.call(this, Object.assign({}, data, { items: items }));
17189
+ };
17190
+ SoleInvoiceForm.prototype.listenTemplateChanges = function () {
17191
+ var _this = this;
17192
+ this.get('template').valueChanges.subscribe(function (template) {
17193
+ _this.updateItemsForm(template);
17194
+ });
17195
+ };
17196
+ SoleInvoiceForm.prototype.updateItemsForm = function (template) {
17197
+ this.items.controls.forEach(function (itemForm) {
17198
+ itemForm.onTemplateChanged(template);
17199
+ });
17200
+ };
17201
+ return SoleInvoiceForm;
17202
+ }(AbstractForm));
17203
+
16929
17204
  var SoleInvoiceTemplateForm = /** @class */ (function (_super) {
16930
17205
  __extends(SoleInvoiceTemplateForm, _super);
16931
- function SoleInvoiceTemplateForm(invoiceTemplate) {
16932
- return _super.call(this, {
17206
+ function SoleInvoiceTemplateForm(invoiceTemplate, soleDetails) {
17207
+ var _this = _super.call(this, {
16933
17208
  name: new forms.FormControl(invoiceTemplate.name, forms.Validators.required),
16934
- isTaxIncluded: new forms.FormControl(invoiceTemplate.isTaxIncluded),
17209
+ // taxType always 'No Tax' when sole details are not GST registered
17210
+ taxType: new forms.FormControl({ value: invoiceTemplate.taxType, disabled: !soleDetails.isGST }, forms.Validators.required),
16935
17211
  term: new forms.FormControl(invoiceTemplate.term, [forms.Validators.required, forms.Validators.min(0)]),
16936
17212
  bankAccount: new forms.FormControl(invoiceTemplate.bankAccount, [forms.Validators.required])
16937
17213
  }, invoiceTemplate) || this;
17214
+ _this.soleDetails = soleDetails;
17215
+ return _this;
16938
17216
  }
16939
17217
  return SoleInvoiceTemplateForm;
16940
17218
  }(AbstractForm));
@@ -17006,17 +17284,13 @@
17006
17284
  function BankAccountAddManualForm(connection) {
17007
17285
  var _this = _super.call(this) || this;
17008
17286
  _this.connection = connection;
17009
- _this
17010
- .addControl('type', new forms.FormControl(null, forms.Validators.required))
17011
- .addControl('accountName', new forms.FormControl(null, forms.Validators.required))
17012
- .addControl('currentBalance', new forms.FormControl(null, forms.Validators.required))
17013
- .addControl('accountNumber', new forms.FormControl(null, [forms.Validators.required, forms.Validators.pattern(BankAccountAddManualForm.accountNumberPattern)]));
17014
- _this.listenEvents();
17287
+ _this.addControl('type', new forms.FormControl(null, forms.Validators.required));
17288
+ _this.addControl('accountName', new forms.FormControl(null, forms.Validators.required));
17289
+ _this.addControl('currentBalance', new forms.FormControl(null, forms.Validators.required));
17290
+ _this.addControl('accountNumber', new forms.FormControl(null, [forms.Validators.required, forms.Validators.pattern(BankAccountAddManualForm.accountNumberPattern)]));
17291
+ _this.listenTypeChanges();
17015
17292
  return _this;
17016
17293
  }
17017
- BankAccountAddManualForm.prototype.listenEvents = function () {
17018
- this.listenTypeChanges();
17019
- };
17020
17294
  /**
17021
17295
  * Add/Remove loan form depends on selected bank account type
17022
17296
  */
@@ -18054,7 +18328,10 @@
18054
18328
  exports.SoleForecast = SoleForecast;
18055
18329
  exports.SoleForecastService = SoleForecastService;
18056
18330
  exports.SoleInvoice = SoleInvoice;
18331
+ exports.SoleInvoiceForm = SoleInvoiceForm;
18057
18332
  exports.SoleInvoiceItem = SoleInvoiceItem;
18333
+ exports.SoleInvoiceItemForm = SoleInvoiceItemForm;
18334
+ exports.SoleInvoiceService = SoleInvoiceService;
18058
18335
  exports.SoleInvoiceTemplate = SoleInvoiceTemplate;
18059
18336
  exports.SoleInvoiceTemplateForm = SoleInvoiceTemplateForm;
18060
18337
  exports.SoleInvoiceTemplateService = SoleInvoiceTemplateService;