taxtank-core 0.29.4 → 0.29.6

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 (37) hide show
  1. package/bundles/taxtank-core.umd.js +71 -13
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/sole/sole-business-losses.collection.js +2 -2
  4. package/esm2015/lib/collections/transaction/transaction.collection.js +3 -3
  5. package/esm2015/lib/db/Enums/file-type.enum.js +14 -0
  6. package/esm2015/lib/db/Models/file.js +4 -0
  7. package/esm2015/lib/db/Models/index.js +2 -1
  8. package/esm2015/lib/db/Models/sole/sole-invoice-template.js +1 -1
  9. package/esm2015/lib/forms/report/my-tax/my-tax-business-income-or-losses/my-tax-business-income-or-losses.form.js +1 -4
  10. package/esm2015/lib/forms/sole/sole-business-loss.form.js +3 -3
  11. package/esm2015/lib/forms/sole/sole-invoice-template.form.js +3 -2
  12. package/esm2015/lib/models/file/file.js +8 -0
  13. package/esm2015/lib/models/file/index.js +2 -0
  14. package/esm2015/lib/models/index.js +2 -1
  15. package/esm2015/lib/models/report/my-tax/my-tax-business-income-or-losses/my-tax-business-losses/my-tax-business-losses.js +4 -4
  16. package/esm2015/lib/models/report/sole/sole-business/sole-business-loss-report.js +3 -3
  17. package/esm2015/lib/models/sole/sole-invoice-template.js +12 -1
  18. package/esm2015/lib/services/http/file/file.service.js +32 -0
  19. package/esm2015/lib/services/http/file/index.js +2 -0
  20. package/esm2015/lib/services/http/index.js +2 -1
  21. package/fesm2015/taxtank-core.js +56 -14
  22. package/fesm2015/taxtank-core.js.map +1 -1
  23. package/lib/collections/transaction/transaction.collection.d.ts +1 -1
  24. package/lib/db/Enums/file-type.enum.d.ts +12 -0
  25. package/lib/db/Models/file.d.ts +16 -0
  26. package/lib/db/Models/index.d.ts +1 -0
  27. package/lib/db/Models/sole/sole-invoice-template.d.ts +2 -0
  28. package/lib/forms/report/my-tax/my-tax-business-income-or-losses/my-tax-business-income-or-losses.form.d.ts +0 -3
  29. package/lib/models/file/file.d.ts +7 -0
  30. package/lib/models/file/index.d.ts +1 -0
  31. package/lib/models/index.d.ts +1 -0
  32. package/lib/models/report/sole/sole-business/sole-business-loss-report.d.ts +2 -3
  33. package/lib/models/sole/sole-invoice-template.d.ts +6 -1
  34. package/lib/services/http/file/file.service.d.ts +16 -0
  35. package/lib/services/http/file/index.d.ts +1 -0
  36. package/lib/services/http/index.d.ts +1 -0
  37. package/package.json +1 -1
@@ -2881,6 +2881,14 @@
2881
2881
  return Vehicle;
2882
2882
  }(AbstractModel));
2883
2883
 
2884
+ var File$1 = /** @class */ (function (_super) {
2885
+ __extends(File, _super);
2886
+ function File() {
2887
+ return _super !== null && _super.apply(this, arguments) || this;
2888
+ }
2889
+ return File;
2890
+ }(AbstractModel));
2891
+
2884
2892
  var Phone$1 = /** @class */ (function (_super) {
2885
2893
  __extends(Phone, _super);
2886
2894
  function Phone() {
@@ -5376,6 +5384,18 @@
5376
5384
  SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["NO_TAX"] = 2] = "NO_TAX";
5377
5385
  })(exports.SoleInvoiceTemplateTaxTypeEnum || (exports.SoleInvoiceTemplateTaxTypeEnum = {}));
5378
5386
 
5387
+ /**
5388
+ * The model renamed for more comfortable work because File already exist in JS
5389
+ * @TODO Alex: consider a better name like document
5390
+ */
5391
+ var AppFile = /** @class */ (function (_super) {
5392
+ __extends(AppFile, _super);
5393
+ function AppFile() {
5394
+ return _super !== null && _super.apply(this, arguments) || this;
5395
+ }
5396
+ return AppFile;
5397
+ }(File$1));
5398
+
5379
5399
  var SoleInvoiceTemplate = /** @class */ (function (_super) {
5380
5400
  __extends(SoleInvoiceTemplate, _super);
5381
5401
  function SoleInvoiceTemplate() {
@@ -5399,6 +5419,13 @@
5399
5419
  enumerable: false,
5400
5420
  configurable: true
5401
5421
  });
5422
+ SoleInvoiceTemplate.prototype.getPhoto = function () {
5423
+ var _a;
5424
+ return ((_a = this.file) === null || _a === void 0 ? void 0 : _a.publicUrl) || null;
5425
+ };
5426
+ SoleInvoiceTemplate.prototype.getPhotoPlaceholder = function () {
5427
+ return "" + this.name[0].toUpperCase() + this.name[1].toUpperCase();
5428
+ };
5402
5429
  return SoleInvoiceTemplate;
5403
5430
  }(SoleInvoiceTemplate$1));
5404
5431
  __decorate([
@@ -5407,6 +5434,9 @@
5407
5434
  __decorate([
5408
5435
  classTransformer.Type(function () { return BankAccount; })
5409
5436
  ], SoleInvoiceTemplate.prototype, "bankAccount", void 0);
5437
+ __decorate([
5438
+ classTransformer.Type(function () { return AppFile; })
5439
+ ], SoleInvoiceTemplate.prototype, "file", void 0);
5410
5440
 
5411
5441
  exports.SoleInvoiceStatusesEnum = void 0;
5412
5442
  (function (SoleInvoiceStatusesEnum) {
@@ -8646,8 +8676,9 @@
8646
8676
  /**
8647
8677
  * @TODO vik business transactions calculated differently, separated collection?
8648
8678
  */
8649
- TransactionCollection.prototype.getBusinessClaimAmount = function (businessId, allocations) {
8650
- var transactions = this.filterBy('business.id', businessId);
8679
+ TransactionCollection.prototype.getBusinessClaimAmount = function (allocations, businessId) {
8680
+ if (businessId === void 0) { businessId = null; }
8681
+ var transactions = businessId ? this.filterBy('business.id', businessId) : this;
8651
8682
  var expenses = transactions.getExpenseTransactions();
8652
8683
  var incomes = transactions.getIncomeTransactions();
8653
8684
  return incomes.calculateAllocatedClaimAmount(allocations) + expenses.sumBy('claimAmount');
@@ -9121,7 +9152,7 @@
9121
9152
  var lossOffsetRule = (_a = _this.findBy('business.id', +businessId)) === null || _a === void 0 ? void 0 : _a.offsetRule;
9122
9153
  var businessClaimAmount = transactionsByBusinessId
9123
9154
  .get(businessId)
9124
- .getBusinessClaimAmount(+businessId, allocations);
9155
+ .getBusinessClaimAmount(allocations, +businessId);
9125
9156
  // @TODO vik it has nothing to do with getClaimAmountsByBusinessId
9126
9157
  // no way to apply loss for business without profit if offset rules not met
9127
9158
  if (businessClaimAmount < 0 && !lossOffsetRule) {
@@ -11968,9 +11999,8 @@
11968
11999
  this.deductionsForGeneralSmallBusinessPoolAmount = depreciations
11969
12000
  .getSBPDepreciations()
11970
12001
  .sumBy('claimAmount');
11971
- this.currentYearNetNonPrimaryIncomeOrLossesAmount = +(allocations.filterBy('transaction.id', transactions.getIds()).sumBy('amount') -
11972
- depreciations.sumBy('claimAmount'))
11973
- .toFixed(2);
12002
+ this.currentYearNetNonPrimaryIncomeOrLossesAmount = new TransactionCollection(transactions.toArray(), depreciations.toArray())
12003
+ .getBusinessClaimAmount(allocations);
11974
12004
  this.priorYearsNonPrimaryLossesAmount = businessLosses.sumBy('openBalance');
11975
12005
  this.netNonPrimaryIncomeOrLossesAmount = this.currentYearNetNonPrimaryIncomeOrLossesAmount -
11976
12006
  this.priorYearsNonPrimaryLossesAmount;
@@ -12505,7 +12535,7 @@
12505
12535
  var _this = _super.call(this) || this;
12506
12536
  _this.openBalance = loss.openBalance;
12507
12537
  var claimAmount = new TransactionCollection(transactions.toArray(), depreciations.toArray())
12508
- .getBusinessClaimAmount(loss.business.id, new TransactionAllocationCollection(allocations));
12538
+ .getBusinessClaimAmount(new TransactionAllocationCollection(allocations), loss.business.id);
12509
12539
  _this.netIncome = claimAmount;
12510
12540
  _this.closeBalance = loss.offsetRule ? 0 : claimAmount - _this.openBalance;
12511
12541
  return _this;
@@ -14174,6 +14204,34 @@
14174
14204
  }] }];
14175
14205
  } });
14176
14206
 
14207
+ var FileService = /** @class */ (function (_super) {
14208
+ __extends(FileService, _super);
14209
+ function FileService() {
14210
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
14211
+ _this.endpointUri = 'files';
14212
+ _this.modelClass = AppFile;
14213
+ _this.collectionClass = Collection;
14214
+ _this.isApiPlatform = true;
14215
+ _this.disabledMethods = ['post', 'postBatch', 'put', 'putBatch', 'delete', 'deleteBatch'];
14216
+ return _this;
14217
+ }
14218
+ FileService.prototype.upload = function (file) {
14219
+ var formData = new FormData();
14220
+ formData.append('file', file);
14221
+ return this.http.post(this.apiUrl, formData)
14222
+ .pipe(operators.map(function (fileBase) { return classTransformer.plainToClass(AppFile, fileBase); }));
14223
+ };
14224
+ return FileService;
14225
+ }(RestService$1));
14226
+ FileService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FileService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
14227
+ FileService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FileService, providedIn: 'root' });
14228
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FileService, decorators: [{
14229
+ type: i0.Injectable,
14230
+ args: [{
14231
+ providedIn: 'root'
14232
+ }]
14233
+ }] });
14234
+
14177
14235
  /**
14178
14236
  * @TODO extend rest service when it could work with single objects, not only arrays
14179
14237
  */
@@ -19108,11 +19166,11 @@
19108
19166
  openBalance: new forms.FormControl(loss.openBalance, [forms.Validators.required, forms.Validators.min(0)]),
19109
19167
  offsetRule: new forms.FormControl((_a = loss.offsetRule) === null || _a === void 0 ? void 0 : _a.id),
19110
19168
  // sum of depreciations/transactions claim amount - openBalance
19111
- balance: new forms.FormControl({ value: profit - loss.openBalance, disabled: true }),
19169
+ balance: new forms.FormControl({ value: (profit - loss.openBalance).toFixed(2), disabled: true }),
19112
19170
  }, loss) || this;
19113
19171
  _this.loss = loss;
19114
19172
  _this.get('openBalance').valueChanges.subscribe(function (openBalance) {
19115
- _this.get('balance').setValue(profit - openBalance);
19173
+ _this.get('balance').setValue((profit - openBalance).toFixed(2));
19116
19174
  });
19117
19175
  return _this;
19118
19176
  }
@@ -19399,7 +19457,8 @@
19399
19457
  taxType: new forms.FormControl(invoiceTemplate.taxType, forms.Validators.required),
19400
19458
  // 32767 - max value because we have small int data type in database for this field, but we don't have actual max validation for term
19401
19459
  term: new forms.FormControl(invoiceTemplate.term, [forms.Validators.required, forms.Validators.min(0), forms.Validators.max(32767)]),
19402
- bankAccount: new forms.FormControl(invoiceTemplate.bankAccount, [forms.Validators.required])
19460
+ bankAccount: new forms.FormControl(invoiceTemplate.bankAccount, [forms.Validators.required]),
19461
+ file: new forms.FormControl(invoiceTemplate.file)
19403
19462
  }, invoiceTemplate) || this;
19404
19463
  }
19405
19464
  return SoleInvoiceTemplateForm;
@@ -20174,9 +20233,6 @@
20174
20233
  return MyTaxBusinessLossesForm;
20175
20234
  }(AbstractForm));
20176
20235
 
20177
- /**
20178
- * @Todo waiting for the Sole tank implementation
20179
- */
20180
20236
  var MyTaxBusinessIncomeOrLossesForm = /** @class */ (function (_super) {
20181
20237
  __extends(MyTaxBusinessIncomeOrLossesForm, _super);
20182
20238
  function MyTaxBusinessIncomeOrLossesForm(businessDetails, businessIncome, businessLosses) {
@@ -21067,6 +21123,7 @@
21067
21123
  exports.AddressService = AddressService;
21068
21124
  exports.AppEvent = AppEvent;
21069
21125
  exports.AppEvent2 = AppEvent2;
21126
+ exports.AppFile = AppFile;
21070
21127
  exports.AssetsService = AssetsService;
21071
21128
  exports.AuthService = AuthService;
21072
21129
  exports.BANK_ACCOUNT_TYPES = BANK_ACCOUNT_TYPES;
@@ -21181,6 +21238,7 @@
21181
21238
  exports.ExportFormatterService = ExportFormatterService;
21182
21239
  exports.ExportableCollection = ExportableCollection;
21183
21240
  exports.FacebookService = FacebookService;
21241
+ exports.FileService = FileService;
21184
21242
  exports.FileValidator = FileValidator;
21185
21243
  exports.FinancialYear = FinancialYear;
21186
21244
  exports.Firm = Firm;