taxtank-core 0.28.2 → 0.28.5

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 (26) hide show
  1. package/bundles/taxtank-core.umd.js +238 -12
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/forms/index.js +2 -1
  4. package/esm2015/lib/forms/property/index.js +2 -0
  5. package/esm2015/lib/forms/property/property-sale/index.js +4 -0
  6. package/esm2015/lib/forms/property/property-sale/property-sale-cost-base.form.js +39 -0
  7. package/esm2015/lib/forms/property/property-sale/property-sale-cost-sale.form.js +74 -0
  8. package/esm2015/lib/forms/property/property-sale/property-sale-exemptions.form.js +75 -0
  9. package/esm2015/lib/models/endpoint/endpoints.const.js +3 -1
  10. package/esm2015/lib/models/property/property-sale/index.js +6 -0
  11. package/esm2015/lib/models/property/property-sale/property-sale-cost-base.js +20 -0
  12. package/esm2015/lib/services/http/transaction/transaction.service.js +8 -4
  13. package/esm2015/lib/validators/min-date/min-date.validator.js +6 -2
  14. package/esm2015/public-api.js +2 -5
  15. package/fesm2015/taxtank-core.js +208 -8
  16. package/fesm2015/taxtank-core.js.map +1 -1
  17. package/lib/forms/index.d.ts +1 -0
  18. package/lib/forms/property/index.d.ts +1 -0
  19. package/lib/forms/property/property-sale/index.d.ts +3 -0
  20. package/lib/forms/property/property-sale/property-sale-cost-base.form.d.ts +14 -0
  21. package/lib/forms/property/property-sale/property-sale-cost-sale.form.d.ts +25 -0
  22. package/lib/forms/property/property-sale/property-sale-exemptions.form.d.ts +26 -0
  23. package/lib/models/property/property-sale/index.d.ts +5 -0
  24. package/lib/models/property/property-sale/property-sale-cost-base.d.ts +12 -0
  25. package/package.json +1 -1
  26. package/public-api.d.ts +1 -4
@@ -963,6 +963,7 @@
963
963
  BANK_TRANSACTIONS_IMPORT_POST: new Endpoint('POST', '\\/bank-transactions\\/\\d+\\/import'),
964
964
  BASIQ_ACCOUNTS_GET: new Endpoint('GET', '\\/basiq\\/accounts'),
965
965
  BASIQ_TOKEN_GET: new Endpoint('GET', '\\/basiq\\/tokens'),
966
+ BORROWING_EXPENSES_GET: new Endpoint('GET', '\\/borrowing-expenses'),
966
967
  CHARTS_INCOME_GET: new Endpoint('GET', '\\/charts\\/\\incomes'),
967
968
  CHARTS_EXPENSES_GET: new Endpoint('GET', '\\/charts\\/\\expenses'),
968
969
  CHART_ACCOUNTS_GET: new Endpoint('GET', '\\/chart-accounts'),
@@ -1071,6 +1072,7 @@
1071
1072
  SOLE_INVOICE_TEMPLATES_POST: new Endpoint('POST', '\\/sole-invoice-templates'),
1072
1073
  SOLE_INVOICE_TEMPLATES_PUT: new Endpoint('PUT', '\\/sole-invoice-templates\\/\\d+'),
1073
1074
  SOLE_INVOICE_TEMPLATES_DELETE: new Endpoint('DELETE', '\\/sole-invoice-templates\\/\\d+'),
1075
+ TAX_EXEMPTIONS_GET: new Endpoint('GET', '\\/tax-exemptions'),
1074
1076
  TAX_CALCULATION_POST: new Endpoint('POST', '\\/tax-calculation'),
1075
1077
  TAX_REVIEWS_GET: new Endpoint('GET', '\\/tax-reviews'),
1076
1078
  TAX_REVIEWS_DELETE: new Endpoint('DELETE', '\\/tax-reviews\\/\\d+'),
@@ -10332,6 +10334,34 @@
10332
10334
  classTransformer.Type(function () { return PropertySaleTaxExemptionMetadata$1; })
10333
10335
  ], PropertySale.prototype, "taxExemptionMetadata", void 0);
10334
10336
 
10337
+ /**
10338
+ * @Todo TT-2143 should be removed when PropertySaleCostBaseForm refactored (cut property to separated form)
10339
+ */
10340
+ var PropertySaleCostBase = /** @class */ (function () {
10341
+ function PropertySaleCostBase() {
10342
+ }
10343
+ PropertySaleCostBase.createFrom = function (property, propertySale, depreciations, holdingCosts) {
10344
+ var _a, _b, _c;
10345
+ return classTransformer.plainToClass(PropertySaleCostBase, {
10346
+ property: classTransformer.plainToClass(Property, property),
10347
+ sale: classTransformer.plainToClass(PropertySale, Object.assign({}, propertySale, {
10348
+ holdingCosts: (_a = propertySale.holdingCosts) !== null && _a !== void 0 ? _a : Math.abs(holdingCosts.sumBy('amount')),
10349
+ structuralImprovementsWDV: (_b = propertySale.structuralImprovementsWDV) !== null && _b !== void 0 ? _b : depreciations.getWithCapitalProject().getCloseBalanceByYear(),
10350
+ buildingAtCostClaimed: (_c = propertySale.buildingAtCostClaimed) !== null && _c !== void 0 ? _c : depreciations.getWithoutCapitalProject().getClaimedAmountByYear(),
10351
+ })),
10352
+ });
10353
+ };
10354
+ return PropertySaleCostBase;
10355
+ }());
10356
+
10357
+ var PropertySaleTaxExemptionMetadata = /** @class */ (function (_super) {
10358
+ __extends(PropertySaleTaxExemptionMetadata, _super);
10359
+ function PropertySaleTaxExemptionMetadata() {
10360
+ return _super !== null && _super.apply(this, arguments) || this;
10361
+ }
10362
+ return PropertySaleTaxExemptionMetadata;
10363
+ }(PropertySaleTaxExemptionMetadata$1));
10364
+
10335
10365
  var TaxExemption$1 = /** @class */ (function (_super) {
10336
10366
  __extends(TaxExemption, _super);
10337
10367
  function TaxExemption() {
@@ -10364,14 +10394,6 @@
10364
10394
  return TaxExemptionMetadata;
10365
10395
  }(TaxExemptionMetadata$1));
10366
10396
 
10367
- var PropertySaleTaxExemptionMetadata = /** @class */ (function (_super) {
10368
- __extends(PropertySaleTaxExemptionMetadata, _super);
10369
- function PropertySaleTaxExemptionMetadata() {
10370
- return _super !== null && _super.apply(this, arguments) || this;
10371
- }
10372
- return PropertySaleTaxExemptionMetadata;
10373
- }(PropertySaleTaxExemptionMetadata$1));
10374
-
10375
10397
  /**
10376
10398
  * @Todo waiting for the Sole tank implementation
10377
10399
  */
@@ -12847,9 +12869,12 @@
12847
12869
  * Get list of property holding costs (transactions related to vacant land property)
12848
12870
  */
12849
12871
  TransactionService.prototype.getPropertyHoldingCosts = function (propertyId) {
12850
- return this.http.get(this.environment.apiV2 + "/" + this.url + "?propertyId=" + propertyId + "&propertyCategoryId=" + exports.PropertyCategoryListEnum.VACANT_LAND)
12851
- .pipe(operators.map(function (transactionsBase) {
12852
- return transactionsBase.map(function (transactionBase) { return classTransformer.plainToClass(Transaction, transactionBase); });
12872
+ return this.get()
12873
+ .pipe(operators.map(function (transactions) {
12874
+ return new TransactionCollection(transactions)
12875
+ .filterBy('property.id', propertyId)
12876
+ .filterBy('property.category.id', exports.PropertyCategoryListEnum.VACANT_LAND)
12877
+ .toArray();
12853
12878
  }));
12854
12879
  };
12855
12880
  /**
@@ -16954,7 +16979,11 @@
16954
16979
  function minDateValidator(date, message) {
16955
16980
  if (message === void 0) { message = MessagesEnum.INVALID_DATE.replace('$1', new i1$1.DatePipe('en-US').transform(date)); }
16956
16981
  return function (control) {
16957
- if (!control.value || (control.value >= date)) {
16982
+ if (!control.value) {
16983
+ return null;
16984
+ }
16985
+ // form control value can be as a Moment object - we wrap it in "new Date()" to work with it like with JS Date
16986
+ if (new Date(control.value) >= new Date(date)) {
16958
16987
  return null;
16959
16988
  }
16960
16989
  return { minDate: message };
@@ -17645,6 +17674,199 @@
17645
17674
  return UserInviteForm;
17646
17675
  }(AbstractForm));
17647
17676
 
17677
+ /**
17678
+ * @Todo TT-2143 remove Property stuff and use this form just for PropertySale
17679
+ * @Todo TT-2143 create and extend from abstract PropertySale form
17680
+ */
17681
+ var PropertySaleCostBaseForm = /** @class */ (function (_super) {
17682
+ __extends(PropertySaleCostBaseForm, _super);
17683
+ function PropertySaleCostBaseForm(propertySaleCostBase) {
17684
+ var _this = _super.call(this, {
17685
+ property: new forms.FormGroup({
17686
+ purchasePrice: new forms.FormControl(propertySaleCostBase.property.purchasePrice, forms.Validators.required),
17687
+ contractDate: new forms.FormControl(propertySaleCostBase.property.contractDate, forms.Validators.required),
17688
+ stampDuty: new forms.FormControl(propertySaleCostBase.property.stampDuty, forms.Validators.required),
17689
+ legalFees: new forms.FormControl(propertySaleCostBase.property.legalFees, forms.Validators.required),
17690
+ otherCapitalCosts: new forms.FormControl(propertySaleCostBase.property.otherCapitalCosts, forms.Validators.required),
17691
+ }),
17692
+ sale: new forms.FormGroup({
17693
+ holdingCosts: new forms.FormControl(propertySaleCostBase.sale.holdingCosts),
17694
+ structuralImprovementsWDV: new forms.FormControl(propertySaleCostBase.sale.structuralImprovementsWDV),
17695
+ buildingAtCostClaimed: new forms.FormControl(propertySaleCostBase.sale.buildingAtCostClaimed)
17696
+ })
17697
+ }, propertySaleCostBase) || this;
17698
+ _this.propertySaleCostBase = propertySaleCostBase;
17699
+ return _this;
17700
+ }
17701
+ PropertySaleCostBaseForm.prototype.getProperty = function () {
17702
+ return classTransformer.plainToClass(Property, Object.assign({}, this.propertySaleCostBase.property, this.get('property').value));
17703
+ };
17704
+ PropertySaleCostBaseForm.prototype.getPropertySale = function () {
17705
+ return classTransformer.plainToClass(PropertySale, Object.assign({}, this.propertySaleCostBase.sale, this.get('sale').value));
17706
+ };
17707
+ PropertySaleCostBaseForm.prototype.submit = function (data) {
17708
+ if (data === void 0) { data = {}; }
17709
+ Object.assign(data, { property: classTransformer.plainToClass(Property, Object.assign({}, this.propertySaleCostBase.property, this.get('property').value)) }, { sale: classTransformer.plainToClass(PropertySale, Object.assign({}, this.propertySaleCostBase.sale, this.get('sale').value)) });
17710
+ return _super.prototype.submit.call(this, data);
17711
+ };
17712
+ return PropertySaleCostBaseForm;
17713
+ }(AbstractForm));
17714
+
17715
+ /**
17716
+ * @Todo TT-2143 Create and extend from abstract PropertySale form
17717
+ */
17718
+ var PropertySaleCostSaleForm = /** @class */ (function (_super) {
17719
+ __extends(PropertySaleCostSaleForm, _super);
17720
+ function PropertySaleCostSaleForm(propertySale, property) {
17721
+ var _this = _super.call(this, {
17722
+ price: new forms.FormControl(propertySale.price, forms.Validators.required),
17723
+ contractDate: new forms.FormControl(propertySale.contractDate, forms.Validators.required),
17724
+ settlementDate: new forms.FormControl(propertySale.settlementDate, forms.Validators.required),
17725
+ commission: new forms.FormControl(propertySale.commission || 0, forms.Validators.required),
17726
+ legalFees: new forms.FormControl(propertySale.legalFees || 0, forms.Validators.required),
17727
+ otherCost: new forms.FormControl(propertySale.otherCost || 0, forms.Validators.required),
17728
+ capitalLoss: new forms.FormControl(propertySale.capitalLoss || 0, forms.Validators.required),
17729
+ // capital gain tax
17730
+ grossCGT: new forms.FormControl({ value: propertySale.grossCGT, disabled: true }, forms.Validators.required),
17731
+ }, propertySale) || this;
17732
+ _this.propertySale = propertySale;
17733
+ _this.property = property;
17734
+ _this.updateGrossCGT();
17735
+ _this.listenEvents();
17736
+ return _this;
17737
+ }
17738
+ PropertySaleCostSaleForm.prototype.listenEvents = function () {
17739
+ this.listenCommissionUpdated();
17740
+ this.listenLegalFeesUpdated();
17741
+ this.listenOtherCostUpdated();
17742
+ this.listenPriceUpdated();
17743
+ this.listenCapitalLossUpdated();
17744
+ };
17745
+ /**
17746
+ * Get property instance based on provided property and form value to get actual form calculations
17747
+ * @Todo TT-2143 Move to parent abstract PropertySale form
17748
+ */
17749
+ PropertySaleCostSaleForm.prototype.getPropertySale = function () {
17750
+ return classTransformer.plainToClass(PropertySale, Object.assign({}, this.propertySale, this.getRawValue()));
17751
+ };
17752
+ PropertySaleCostSaleForm.prototype.submit = function (data) {
17753
+ if (data === void 0) { data = {}; }
17754
+ // 'grossCGT' field is always disabled, but we need it to submit result
17755
+ Object.assign(data, { grossCGT: this.get('grossCGT').value });
17756
+ return _super.prototype.submit.call(this, data);
17757
+ };
17758
+ PropertySaleCostSaleForm.prototype.updateGrossCGT = function () {
17759
+ this.get('grossCGT').setValue(Math.round(this.property.calculateCGT(this.getPropertySale())).toFixed());
17760
+ };
17761
+ PropertySaleCostSaleForm.prototype.listenCommissionUpdated = function () {
17762
+ var _this = this;
17763
+ this.get('commission').valueChanges.subscribe(function () {
17764
+ _this.updateGrossCGT();
17765
+ });
17766
+ };
17767
+ PropertySaleCostSaleForm.prototype.listenLegalFeesUpdated = function () {
17768
+ var _this = this;
17769
+ this.get('legalFees').valueChanges.subscribe(function () {
17770
+ _this.updateGrossCGT();
17771
+ });
17772
+ };
17773
+ PropertySaleCostSaleForm.prototype.listenOtherCostUpdated = function () {
17774
+ var _this = this;
17775
+ this.get('otherCost').valueChanges.subscribe(function () {
17776
+ _this.updateGrossCGT();
17777
+ });
17778
+ };
17779
+ PropertySaleCostSaleForm.prototype.listenPriceUpdated = function () {
17780
+ var _this = this;
17781
+ this.get('price').valueChanges.subscribe(function () {
17782
+ _this.updateGrossCGT();
17783
+ });
17784
+ };
17785
+ PropertySaleCostSaleForm.prototype.listenCapitalLossUpdated = function () {
17786
+ var _this = this;
17787
+ this.get('capitalLoss').valueChanges.subscribe(function () {
17788
+ _this.updateGrossCGT();
17789
+ });
17790
+ };
17791
+ return PropertySaleCostSaleForm;
17792
+ }(AbstractForm));
17793
+
17794
+ /**
17795
+ * @Todo TT-2143 Create and extend from abstract PropertySale form
17796
+ */
17797
+ var PropertySaleExemptionsForm = /** @class */ (function (_super) {
17798
+ __extends(PropertySaleExemptionsForm, _super);
17799
+ function PropertySaleExemptionsForm(propertySale, property, taxExemptions) {
17800
+ var _this = this;
17801
+ var _a, _b;
17802
+ _this = _super.call(this, {
17803
+ taxExemption: new forms.FormControl(taxExemptions.findBy('id', (_b = (_a = propertySale.taxExemption) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : property.getCGTExemption(propertySale))),
17804
+ taxExemptionMetadata: new forms.FormArray([]),
17805
+ netCGT: new forms.FormControl(propertySale.netCGT)
17806
+ }, propertySale) || this;
17807
+ _this.propertySale = propertySale;
17808
+ _this.property = property;
17809
+ _this.taxExemptions = taxExemptions;
17810
+ if (propertySale.taxExemption) {
17811
+ _this.setFormMetadataControls();
17812
+ }
17813
+ _this.updateNetCGT();
17814
+ _this.listenEvents();
17815
+ return _this;
17816
+ }
17817
+ PropertySaleExemptionsForm.prototype.listenEvents = function () {
17818
+ this.listenTaxExemptionUpdated();
17819
+ };
17820
+ /**
17821
+ * @Todo TT-2143 Move to parent abstract PropertySale form
17822
+ */
17823
+ PropertySaleExemptionsForm.prototype.getPropertySale = function () {
17824
+ return classTransformer.plainToClass(PropertySale, Object.assign({}, this.propertySale, this.getRawValue()));
17825
+ };
17826
+ PropertySaleExemptionsForm.prototype.updateNetCGT = function () {
17827
+ this.get('netCGT').setValue(this.property.calculateNetCGT(this.getPropertySale()));
17828
+ };
17829
+ PropertySaleExemptionsForm.prototype.listenTaxExemptionUpdated = function () {
17830
+ var _this = this;
17831
+ this.get('taxExemption').valueChanges.subscribe(function (taxExemption) {
17832
+ _this.updateNetCGT();
17833
+ _this.setFormMetadataControls(taxExemption);
17834
+ });
17835
+ };
17836
+ /**
17837
+ * show metadata related to passed tax exemption or existing property sale metadata
17838
+ */
17839
+ PropertySaleExemptionsForm.prototype.setFormMetadataControls = function (taxExemption) {
17840
+ var _this = this;
17841
+ // use property sale tax exemption if it exists to preselect data
17842
+ var currentTaxExemption = this.propertySale.taxExemption ?
17843
+ this.taxExemptions.findBy('id', this.propertySale.taxExemption.id) :
17844
+ taxExemption;
17845
+ var formArray = this.get('taxExemptionMetadata');
17846
+ // clean up
17847
+ formArray.clear();
17848
+ // show all tax exemption metadata fields
17849
+ currentTaxExemption.metadata.forEach(function (metadata) {
17850
+ // use property sale tax exemption metadata value if it exists
17851
+ var metadataValue = _this.propertySale.taxExemption ?
17852
+ _this.propertySale.taxExemptionMetadata
17853
+ .find(function (saleMetadata) { return saleMetadata.metadata.id === metadata.id; }).value :
17854
+ null;
17855
+ var validators = [
17856
+ // claim percent is optional
17857
+ metadata.id !== exports.TaxExemptionMetadataEnum.CLAIM_PERCENT && forms.Validators.required,
17858
+ // ppr days can't be more than ownership days
17859
+ metadata.id === exports.TaxExemptionMetadataEnum.PPR_DAYS && forms.Validators.max(_this.property.getOwnershipDuration(_this.propertySale))
17860
+ ].filter(Boolean);
17861
+ formArray.push(new forms.FormGroup({
17862
+ metadata: new forms.FormControl(metadata),
17863
+ value: new forms.FormControl(metadataValue, validators)
17864
+ }));
17865
+ });
17866
+ };
17867
+ return PropertySaleExemptionsForm;
17868
+ }(AbstractForm));
17869
+
17648
17870
  /**
17649
17871
  * @Todo waiting for the Sole tank implementation
17650
17872
  */
@@ -18396,6 +18618,10 @@
18396
18618
  exports.PropertyReportItemTransactionCollection = PropertyReportItemTransactionCollection;
18397
18619
  exports.PropertySale = PropertySale;
18398
18620
  exports.PropertySaleCollection = PropertySaleCollection;
18621
+ exports.PropertySaleCostBase = PropertySaleCostBase;
18622
+ exports.PropertySaleCostBaseForm = PropertySaleCostBaseForm;
18623
+ exports.PropertySaleCostSaleForm = PropertySaleCostSaleForm;
18624
+ exports.PropertySaleExemptionsForm = PropertySaleExemptionsForm;
18399
18625
  exports.PropertySaleService = PropertySaleService;
18400
18626
  exports.PropertySaleTaxExemptionMetadata = PropertySaleTaxExemptionMetadata;
18401
18627
  exports.PropertyService = PropertyService;