taxtank-core 0.28.4 → 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.
- package/bundles/taxtank-core.umd.js +232 -11
- package/bundles/taxtank-core.umd.js.map +1 -1
- package/esm2015/lib/forms/index.js +2 -1
- package/esm2015/lib/forms/property/index.js +2 -0
- package/esm2015/lib/forms/property/property-sale/index.js +4 -0
- package/esm2015/lib/forms/property/property-sale/property-sale-cost-base.form.js +39 -0
- package/esm2015/lib/forms/property/property-sale/property-sale-cost-sale.form.js +74 -0
- package/esm2015/lib/forms/property/property-sale/property-sale-exemptions.form.js +75 -0
- package/esm2015/lib/models/endpoint/endpoints.const.js +2 -1
- package/esm2015/lib/models/property/property-sale/index.js +6 -0
- package/esm2015/lib/models/property/property-sale/property-sale-cost-base.js +20 -0
- package/esm2015/lib/services/http/transaction/transaction.service.js +8 -4
- package/esm2015/public-api.js +2 -5
- package/fesm2015/taxtank-core.js +202 -7
- package/fesm2015/taxtank-core.js.map +1 -1
- package/lib/forms/index.d.ts +1 -0
- package/lib/forms/property/index.d.ts +1 -0
- package/lib/forms/property/property-sale/index.d.ts +3 -0
- package/lib/forms/property/property-sale/property-sale-cost-base.form.d.ts +14 -0
- package/lib/forms/property/property-sale/property-sale-cost-sale.form.d.ts +25 -0
- package/lib/forms/property/property-sale/property-sale-exemptions.form.d.ts +26 -0
- package/lib/models/property/property-sale/index.d.ts +5 -0
- package/lib/models/property/property-sale/property-sale-cost-base.d.ts +12 -0
- package/package.json +1 -1
- package/public-api.d.ts +1 -4
|
@@ -1072,6 +1072,7 @@
|
|
|
1072
1072
|
SOLE_INVOICE_TEMPLATES_POST: new Endpoint('POST', '\\/sole-invoice-templates'),
|
|
1073
1073
|
SOLE_INVOICE_TEMPLATES_PUT: new Endpoint('PUT', '\\/sole-invoice-templates\\/\\d+'),
|
|
1074
1074
|
SOLE_INVOICE_TEMPLATES_DELETE: new Endpoint('DELETE', '\\/sole-invoice-templates\\/\\d+'),
|
|
1075
|
+
TAX_EXEMPTIONS_GET: new Endpoint('GET', '\\/tax-exemptions'),
|
|
1075
1076
|
TAX_CALCULATION_POST: new Endpoint('POST', '\\/tax-calculation'),
|
|
1076
1077
|
TAX_REVIEWS_GET: new Endpoint('GET', '\\/tax-reviews'),
|
|
1077
1078
|
TAX_REVIEWS_DELETE: new Endpoint('DELETE', '\\/tax-reviews\\/\\d+'),
|
|
@@ -10333,6 +10334,34 @@
|
|
|
10333
10334
|
classTransformer.Type(function () { return PropertySaleTaxExemptionMetadata$1; })
|
|
10334
10335
|
], PropertySale.prototype, "taxExemptionMetadata", void 0);
|
|
10335
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
|
+
|
|
10336
10365
|
var TaxExemption$1 = /** @class */ (function (_super) {
|
|
10337
10366
|
__extends(TaxExemption, _super);
|
|
10338
10367
|
function TaxExemption() {
|
|
@@ -10365,14 +10394,6 @@
|
|
|
10365
10394
|
return TaxExemptionMetadata;
|
|
10366
10395
|
}(TaxExemptionMetadata$1));
|
|
10367
10396
|
|
|
10368
|
-
var PropertySaleTaxExemptionMetadata = /** @class */ (function (_super) {
|
|
10369
|
-
__extends(PropertySaleTaxExemptionMetadata, _super);
|
|
10370
|
-
function PropertySaleTaxExemptionMetadata() {
|
|
10371
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
10372
|
-
}
|
|
10373
|
-
return PropertySaleTaxExemptionMetadata;
|
|
10374
|
-
}(PropertySaleTaxExemptionMetadata$1));
|
|
10375
|
-
|
|
10376
10397
|
/**
|
|
10377
10398
|
* @Todo waiting for the Sole tank implementation
|
|
10378
10399
|
*/
|
|
@@ -12848,9 +12869,12 @@
|
|
|
12848
12869
|
* Get list of property holding costs (transactions related to vacant land property)
|
|
12849
12870
|
*/
|
|
12850
12871
|
TransactionService.prototype.getPropertyHoldingCosts = function (propertyId) {
|
|
12851
|
-
return this.
|
|
12852
|
-
.pipe(operators.map(function (
|
|
12853
|
-
return
|
|
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();
|
|
12854
12878
|
}));
|
|
12855
12879
|
};
|
|
12856
12880
|
/**
|
|
@@ -17650,6 +17674,199 @@
|
|
|
17650
17674
|
return UserInviteForm;
|
|
17651
17675
|
}(AbstractForm));
|
|
17652
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
|
+
|
|
17653
17870
|
/**
|
|
17654
17871
|
* @Todo waiting for the Sole tank implementation
|
|
17655
17872
|
*/
|
|
@@ -18401,6 +18618,10 @@
|
|
|
18401
18618
|
exports.PropertyReportItemTransactionCollection = PropertyReportItemTransactionCollection;
|
|
18402
18619
|
exports.PropertySale = PropertySale;
|
|
18403
18620
|
exports.PropertySaleCollection = PropertySaleCollection;
|
|
18621
|
+
exports.PropertySaleCostBase = PropertySaleCostBase;
|
|
18622
|
+
exports.PropertySaleCostBaseForm = PropertySaleCostBaseForm;
|
|
18623
|
+
exports.PropertySaleCostSaleForm = PropertySaleCostSaleForm;
|
|
18624
|
+
exports.PropertySaleExemptionsForm = PropertySaleExemptionsForm;
|
|
18404
18625
|
exports.PropertySaleService = PropertySaleService;
|
|
18405
18626
|
exports.PropertySaleTaxExemptionMetadata = PropertySaleTaxExemptionMetadata;
|
|
18406
18627
|
exports.PropertyService = PropertyService;
|