taxtank-core 0.28.109 → 0.28.111
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 +2025 -2020
- package/bundles/taxtank-core.umd.js.map +1 -1
- package/esm2015/lib/collections/transaction/transaction.collection.js +1 -4
- package/esm2015/lib/forms/transaction/work-income.form.js +14 -18
- package/esm2015/lib/models/transaction/transaction.js +16 -6
- package/fesm2015/taxtank-core.js +1563 -1561
- package/fesm2015/taxtank-core.js.map +1 -1
- package/lib/collections/transaction/transaction.collection.d.ts +0 -3
- package/lib/forms/transaction/work-income.form.d.ts +5 -9
- package/lib/models/transaction/transaction.d.ts +5 -3
- package/package.json +1 -1
|
@@ -4531,2504 +4531,2514 @@
|
|
|
4531
4531
|
classTransformer.Type(function () { return Transaction; })
|
|
4532
4532
|
], TransactionAllocation.prototype, "transaction", void 0);
|
|
4533
4533
|
|
|
4534
|
-
var
|
|
4535
|
-
__extends(
|
|
4536
|
-
function
|
|
4537
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
4538
|
-
}
|
|
4539
|
-
return Depreciation;
|
|
4540
|
-
}(TransactionBase));
|
|
4541
|
-
|
|
4542
|
-
var DepreciationCapitalProject$1 = /** @class */ (function (_super) {
|
|
4543
|
-
__extends(DepreciationCapitalProject, _super);
|
|
4544
|
-
function DepreciationCapitalProject() {
|
|
4534
|
+
var PropertySaleCollection = /** @class */ (function (_super) {
|
|
4535
|
+
__extends(PropertySaleCollection, _super);
|
|
4536
|
+
function PropertySaleCollection() {
|
|
4545
4537
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
4546
4538
|
}
|
|
4547
|
-
|
|
4548
|
-
|
|
4539
|
+
Object.defineProperty(PropertySaleCollection.prototype, "grossCGT", {
|
|
4540
|
+
get: function () {
|
|
4541
|
+
return this.create(this.items.filter(function (propertySale) { return propertySale.grossCGT > 0; })).sumBy('grossCGT');
|
|
4542
|
+
},
|
|
4543
|
+
enumerable: false,
|
|
4544
|
+
configurable: true
|
|
4545
|
+
});
|
|
4546
|
+
/**
|
|
4547
|
+
* Property sales are CGT applicable unless it has "Principle place of residence" exemption type
|
|
4548
|
+
*/
|
|
4549
|
+
PropertySaleCollection.prototype.getCGTApplicable = function () {
|
|
4550
|
+
return this.create(this.items.filter(function (propertySale) { return propertySale.isCGTApplicable(); }));
|
|
4551
|
+
};
|
|
4552
|
+
PropertySaleCollection.prototype.getByPropertyShareIds = function (ids) {
|
|
4553
|
+
return this.filterBy('share.id', ids);
|
|
4554
|
+
};
|
|
4555
|
+
return PropertySaleCollection;
|
|
4556
|
+
}(Collection));
|
|
4549
4557
|
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
classTransformer.Type(function () { return Date; })
|
|
4559
|
-
], DepreciationCapitalProject.prototype, "effectiveDate", void 0);
|
|
4558
|
+
exports.TaxExemptionMetadataEnum = void 0;
|
|
4559
|
+
(function (TaxExemptionMetadataEnum) {
|
|
4560
|
+
// principle place of residence
|
|
4561
|
+
TaxExemptionMetadataEnum[TaxExemptionMetadataEnum["PPR_DAYS"] = 1] = "PPR_DAYS";
|
|
4562
|
+
// market value once it was moved, decimal
|
|
4563
|
+
TaxExemptionMetadataEnum[TaxExemptionMetadataEnum["MARKET_VALUE"] = 2] = "MARKET_VALUE";
|
|
4564
|
+
TaxExemptionMetadataEnum[TaxExemptionMetadataEnum["CLAIM_PERCENT"] = 3] = "CLAIM_PERCENT";
|
|
4565
|
+
})(exports.TaxExemptionMetadataEnum || (exports.TaxExemptionMetadataEnum = {}));
|
|
4560
4566
|
|
|
4561
|
-
var
|
|
4562
|
-
__extends(
|
|
4563
|
-
function
|
|
4567
|
+
var PropertySaleTaxExemptionMetadataCollection = /** @class */ (function (_super) {
|
|
4568
|
+
__extends(PropertySaleTaxExemptionMetadataCollection, _super);
|
|
4569
|
+
function PropertySaleTaxExemptionMetadataCollection() {
|
|
4564
4570
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
4565
4571
|
}
|
|
4566
|
-
|
|
4567
|
-
|
|
4572
|
+
PropertySaleTaxExemptionMetadataCollection.prototype.getPPRDays = function () {
|
|
4573
|
+
var _a, _b;
|
|
4574
|
+
return (_b = (_a = this.getByMetadataId(exports.TaxExemptionMetadataEnum.PPR_DAYS)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0;
|
|
4575
|
+
};
|
|
4576
|
+
PropertySaleTaxExemptionMetadataCollection.prototype.getMarketValue = function () {
|
|
4577
|
+
var _a, _b;
|
|
4578
|
+
return (_b = (_a = this.getByMetadataId(exports.TaxExemptionMetadataEnum.MARKET_VALUE)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0;
|
|
4579
|
+
};
|
|
4580
|
+
PropertySaleTaxExemptionMetadataCollection.prototype.getClaimPercent = function () {
|
|
4581
|
+
var _a, _b;
|
|
4582
|
+
return (_b = (_a = this.getByMetadataId(exports.TaxExemptionMetadataEnum.CLAIM_PERCENT)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 100;
|
|
4583
|
+
};
|
|
4584
|
+
PropertySaleTaxExemptionMetadataCollection.prototype.getByMetadataId = function (id) {
|
|
4585
|
+
return this.items.find(function (metadata) { return metadata.metadata.id === id; });
|
|
4586
|
+
};
|
|
4587
|
+
return PropertySaleTaxExemptionMetadataCollection;
|
|
4588
|
+
}(Collection));
|
|
4568
4589
|
|
|
4569
|
-
var
|
|
4570
|
-
__extends(
|
|
4571
|
-
function
|
|
4590
|
+
var PropertyCollection = /** @class */ (function (_super) {
|
|
4591
|
+
__extends(PropertyCollection, _super);
|
|
4592
|
+
function PropertyCollection() {
|
|
4572
4593
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
4573
4594
|
}
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
}
|
|
4581
|
-
|
|
4595
|
+
/**
|
|
4596
|
+
* Get new property collection filtered by category id
|
|
4597
|
+
* @param id id of category for filter
|
|
4598
|
+
*/
|
|
4599
|
+
PropertyCollection.prototype.getByCategoryId = function (id) {
|
|
4600
|
+
return new PropertyCollection(this.items.filter(function (property) { return property.category.id === id; }));
|
|
4601
|
+
};
|
|
4602
|
+
/**
|
|
4603
|
+
* Get new property collection filtered by active status
|
|
4604
|
+
*/
|
|
4605
|
+
PropertyCollection.prototype.getActiveProperties = function () {
|
|
4606
|
+
return new PropertyCollection(this.items.filter(function (property) { return property.isActive; }));
|
|
4607
|
+
};
|
|
4608
|
+
PropertyCollection.prototype.getCreatedProperties = function () {
|
|
4609
|
+
return new PropertyCollection(this.items.filter(function (property) { return property.isOwn(); }));
|
|
4610
|
+
};
|
|
4611
|
+
/**
|
|
4612
|
+
* Get new property collection filtered by shared
|
|
4613
|
+
*/
|
|
4614
|
+
PropertyCollection.prototype.getSharedProperties = function () {
|
|
4615
|
+
return new PropertyCollection(this.items.filter(function (property) { return !property.isOwn(); }));
|
|
4616
|
+
};
|
|
4617
|
+
/**
|
|
4618
|
+
* Properties that are taxed and will be included in reports (Tax summary, My tax report, e.t.c.)
|
|
4619
|
+
*/
|
|
4620
|
+
PropertyCollection.prototype.getTaxInclusive = function () {
|
|
4621
|
+
return this.create(this.items.filter(function (property) { return property.category.isTaxInclusive; }));
|
|
4622
|
+
};
|
|
4623
|
+
PropertyCollection.prototype.getUnsold = function () {
|
|
4624
|
+
return this.create(this.items.filter(function (property) { return !property.isSold(); }));
|
|
4625
|
+
};
|
|
4626
|
+
Object.defineProperty(PropertyCollection.prototype, "purchasePrice", {
|
|
4627
|
+
/**
|
|
4628
|
+
* Get total purchase price for all properties in the collection
|
|
4629
|
+
*/
|
|
4582
4630
|
get: function () {
|
|
4583
|
-
return
|
|
4631
|
+
return this.sumBy('purchasePrice');
|
|
4584
4632
|
},
|
|
4585
4633
|
enumerable: false,
|
|
4586
4634
|
configurable: true
|
|
4587
4635
|
});
|
|
4588
|
-
|
|
4589
|
-
// @TODO find a better place
|
|
4590
|
-
var year = this.financialYear - (month > 5 ? 1 : 0);
|
|
4591
|
-
// forecast date intersect by month
|
|
4592
|
-
var range = new momentRange.DateRange(this.fromDate, this.toDate).intersect(new momentRange.DateRange(new Date(year, month, 1), new Date(year, month + 1, 0)));
|
|
4593
|
-
return range ? range.duration('days') + 1 : 0;
|
|
4594
|
-
};
|
|
4595
|
-
Object.defineProperty(DepreciationForecast.prototype, "claimOpenBalance", {
|
|
4636
|
+
Object.defineProperty(PropertyCollection.prototype, "growthPercent", {
|
|
4596
4637
|
get: function () {
|
|
4597
|
-
return this.
|
|
4638
|
+
return this.sumBy('growthPercent');
|
|
4598
4639
|
},
|
|
4599
4640
|
enumerable: false,
|
|
4600
4641
|
configurable: true
|
|
4601
4642
|
});
|
|
4602
|
-
Object.defineProperty(
|
|
4643
|
+
Object.defineProperty(PropertyCollection.prototype, "marketValue", {
|
|
4603
4644
|
get: function () {
|
|
4604
|
-
return this.
|
|
4645
|
+
return this.sumBy('marketValue');
|
|
4605
4646
|
},
|
|
4606
4647
|
enumerable: false,
|
|
4607
4648
|
configurable: true
|
|
4608
4649
|
});
|
|
4609
|
-
Object.defineProperty(
|
|
4650
|
+
Object.defineProperty(PropertyCollection.prototype, "firstForecastYear", {
|
|
4610
4651
|
get: function () {
|
|
4611
|
-
return this.
|
|
4652
|
+
return this.items.reduce(function (min, property) {
|
|
4653
|
+
var current = property.firstForecastYear;
|
|
4654
|
+
return min > current ? current : min;
|
|
4655
|
+
}, new FinancialYear().year);
|
|
4612
4656
|
},
|
|
4613
4657
|
enumerable: false,
|
|
4614
4658
|
configurable: true
|
|
4615
4659
|
});
|
|
4616
|
-
Object.defineProperty(
|
|
4660
|
+
Object.defineProperty(PropertyCollection.prototype, "marketValueGrowth", {
|
|
4617
4661
|
get: function () {
|
|
4618
|
-
return this.
|
|
4662
|
+
return (this.marketValue - this.purchasePrice) / this.purchasePrice;
|
|
4619
4663
|
},
|
|
4620
4664
|
enumerable: false,
|
|
4621
4665
|
configurable: true
|
|
4622
4666
|
});
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
/**
|
|
4630
|
-
* Enum with income amount types (Net or Gross)
|
|
4631
|
-
*/
|
|
4632
|
-
exports.IncomeAmountTypeEnum = void 0;
|
|
4633
|
-
(function (IncomeAmountTypeEnum) {
|
|
4634
|
-
IncomeAmountTypeEnum[IncomeAmountTypeEnum["NET"] = 0] = "NET";
|
|
4635
|
-
IncomeAmountTypeEnum[IncomeAmountTypeEnum["GROSS"] = 1] = "GROSS";
|
|
4636
|
-
})(exports.IncomeAmountTypeEnum || (exports.IncomeAmountTypeEnum = {}));
|
|
4637
|
-
|
|
4638
|
-
exports.TransactionCategoryEnum = void 0;
|
|
4639
|
-
(function (TransactionCategoryEnum) {
|
|
4640
|
-
TransactionCategoryEnum[TransactionCategoryEnum["PROPERTY"] = 0] = "PROPERTY";
|
|
4641
|
-
TransactionCategoryEnum[TransactionCategoryEnum["WORK"] = 1] = "WORK";
|
|
4642
|
-
TransactionCategoryEnum[TransactionCategoryEnum["SOLE"] = 2] = "SOLE";
|
|
4643
|
-
TransactionCategoryEnum[TransactionCategoryEnum["PERSONAL"] = 3] = "PERSONAL";
|
|
4644
|
-
})(exports.TransactionCategoryEnum || (exports.TransactionCategoryEnum = {}));
|
|
4645
|
-
|
|
4646
|
-
/**
|
|
4647
|
-
* @TODO Alex: clarify grouping rules and refactor
|
|
4648
|
-
*/
|
|
4649
|
-
var Depreciation = /** @class */ (function (_super) {
|
|
4650
|
-
__extends(Depreciation, _super);
|
|
4651
|
-
function Depreciation() {
|
|
4652
|
-
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
4653
|
-
_this.forecasts = [];
|
|
4654
|
-
_this.type = exports.DepreciationTypeEnum.PLANT_EQUIPMENT;
|
|
4655
|
-
/**
|
|
4656
|
-
* @TODO remove after ? signs removed from db models
|
|
4657
|
-
*/
|
|
4658
|
-
_this.amount = 0;
|
|
4659
|
-
return _this;
|
|
4660
|
-
}
|
|
4661
|
-
// Type checking
|
|
4662
|
-
Depreciation.prototype.isCapital = function () {
|
|
4663
|
-
return this.type === exports.DepreciationTypeEnum.CAPITAL_WORKS;
|
|
4664
|
-
};
|
|
4665
|
-
Depreciation.prototype.isBorrowingExpense = function () {
|
|
4666
|
-
return this.type === exports.DepreciationTypeEnum.BORROWING_EXPENSES;
|
|
4667
|
-
};
|
|
4668
|
-
Depreciation.prototype.isAsset = function () {
|
|
4669
|
-
return this.type === exports.DepreciationTypeEnum.PLANT_EQUIPMENT;
|
|
4670
|
-
};
|
|
4671
|
-
// Calculation checking
|
|
4672
|
-
Depreciation.prototype.isSBPCalculation = function () {
|
|
4673
|
-
return this.calculation === exports.DepreciationCalculationEnum.SBP;
|
|
4674
|
-
};
|
|
4675
|
-
Depreciation.prototype.isPrimeCost = function () {
|
|
4676
|
-
return this.calculation === exports.DepreciationCalculationEnum.PRIME_COST;
|
|
4677
|
-
};
|
|
4678
|
-
Depreciation.prototype.isDiminishing = function () {
|
|
4679
|
-
return this.calculation === exports.DepreciationCalculationEnum.DIMINISHING;
|
|
4680
|
-
};
|
|
4681
|
-
// Pool checking
|
|
4682
|
-
Depreciation.prototype.isPlantEquipmentPool = function () {
|
|
4683
|
-
return this.isAsset() && !this.isSBPCalculation() && !this.isWrittenOff() && !this.isLVP();
|
|
4684
|
-
};
|
|
4685
|
-
Depreciation.prototype.isLVP = function () {
|
|
4686
|
-
return this.isAsset()
|
|
4687
|
-
&& !this.isSBPCalculation()
|
|
4688
|
-
&& this.isDiminishing()
|
|
4689
|
-
&& this.currentYearForecast.closeBalance > Depreciation.WRITTEN_OFF_THRESHOLD
|
|
4690
|
-
&& this.currentYearForecast.closeBalance <= Depreciation.LOW_VALUE_POOL_THRESHOLD;
|
|
4691
|
-
};
|
|
4692
|
-
Depreciation.prototype.isSBP = function () {
|
|
4693
|
-
return this.isAsset() && this.isSBPCalculation() && !this.isWrittenOff();
|
|
4667
|
+
/**
|
|
4668
|
+
* list of properties
|
|
4669
|
+
*/
|
|
4670
|
+
PropertyCollection.prototype.getCGTApplicable = function () {
|
|
4671
|
+
return this.create(this.items.filter(function (property) { return property.isCGTApplicable(); }));
|
|
4694
4672
|
};
|
|
4695
|
-
|
|
4696
|
-
return this.
|
|
4673
|
+
PropertyCollection.prototype.getOwnerOccupiedProperties = function () {
|
|
4674
|
+
return new PropertyCollection(this.items.filter(function (property) { return property.category.isOwnerOccupied(); }));
|
|
4697
4675
|
};
|
|
4698
|
-
Object.defineProperty(
|
|
4676
|
+
Object.defineProperty(PropertyCollection.prototype, "earliestContractDate", {
|
|
4699
4677
|
get: function () {
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
}
|
|
4704
|
-
return (_a = new FinancialYear(this.writeOffManualDate || this.writeOffDate)) === null || _a === void 0 ? void 0 : _a.year;
|
|
4678
|
+
return this.items.reduce(function (min, property) {
|
|
4679
|
+
return min < property.contractDate ? min : property.contractDate;
|
|
4680
|
+
}, new FinancialYear(new Date()).startDate);
|
|
4705
4681
|
},
|
|
4706
4682
|
enumerable: false,
|
|
4707
4683
|
configurable: true
|
|
4708
4684
|
});
|
|
4709
4685
|
/**
|
|
4710
|
-
*
|
|
4686
|
+
* Get list of unique property categories from collection
|
|
4711
4687
|
*/
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
return ((_a = this.chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id) === exports.ChartAccountsHeadingVehicleListEnum.DEPRECIATION_VEHICLES;
|
|
4688
|
+
PropertyCollection.prototype.getCategories = function () {
|
|
4689
|
+
return uniqBy__default["default"](this.items.map(function (property) { return property.category; }), 'id');
|
|
4715
4690
|
};
|
|
4716
4691
|
/**
|
|
4717
|
-
* Get
|
|
4692
|
+
* Get property with the highest growth percent
|
|
4718
4693
|
*/
|
|
4719
|
-
|
|
4720
|
-
return this.
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
/**
|
|
4724
|
-
* @TODO Vik: Research a problem with depreciations without current year forecast
|
|
4725
|
-
*/
|
|
4726
|
-
get: function () {
|
|
4727
|
-
return this.forecasts.find(function (forecast) {
|
|
4728
|
-
return forecast.financialYear === new FinancialYear().year;
|
|
4729
|
-
}) || classTransformer.plainToClass(DepreciationForecast, {
|
|
4730
|
-
financialYear: new FinancialYear().year,
|
|
4731
|
-
openBalance: 0,
|
|
4732
|
-
closeBalance: 0,
|
|
4733
|
-
amount: 0,
|
|
4734
|
-
claimPercent: 0
|
|
4735
|
-
});
|
|
4736
|
-
},
|
|
4737
|
-
enumerable: false,
|
|
4738
|
-
configurable: true
|
|
4739
|
-
});
|
|
4740
|
-
Depreciation.prototype.getForecastByYear = function (year) {
|
|
4741
|
-
return this.forecasts.find(function (forecast) {
|
|
4742
|
-
return forecast.financialYear === year;
|
|
4743
|
-
});
|
|
4744
|
-
};
|
|
4745
|
-
Depreciation.prototype.getClaimAmountByYear = function (year) {
|
|
4746
|
-
var _a;
|
|
4747
|
-
return ((_a = this.getForecastByYear(year)) === null || _a === void 0 ? void 0 : _a.claimAmount) || 0;
|
|
4748
|
-
};
|
|
4749
|
-
Depreciation.prototype.getCloseBalanceByYear = function (year) {
|
|
4750
|
-
var _a;
|
|
4751
|
-
return ((_a = this.getForecastByYear(year)) === null || _a === void 0 ? void 0 : _a.closeBalance) || 0;
|
|
4752
|
-
};
|
|
4753
|
-
Depreciation.prototype.isBuildingAtCost = function () {
|
|
4754
|
-
return this.chartAccounts.id === exports.ChartAccountsListEnum.BUILDING_AT_COST;
|
|
4694
|
+
PropertyCollection.prototype.getBestPerformanceGrowthProperty = function () {
|
|
4695
|
+
return this.items.reduce(function (max, current) {
|
|
4696
|
+
return max.growthPercent < current.growthPercent ? current : max;
|
|
4697
|
+
}, this.first);
|
|
4755
4698
|
};
|
|
4756
4699
|
/**
|
|
4757
|
-
*
|
|
4700
|
+
* Get property with the lowest tax position
|
|
4758
4701
|
*/
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
var
|
|
4762
|
-
return
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4702
|
+
PropertyCollection.prototype.getBestPerformanceTaxProperty = function (transactions, depreciations) {
|
|
4703
|
+
var transactionsByProperty = transactions.groupBy('property.id');
|
|
4704
|
+
var depreciationsByProperty = depreciations.groupBy('property.id');
|
|
4705
|
+
return this.items.reduce(function (min, current) {
|
|
4706
|
+
var minTaxPosition = min.getTaxPosition(transactionsByProperty.get(min.id), depreciationsByProperty.get(min.id));
|
|
4707
|
+
var currentTaxPosition = current.getTaxPosition(transactionsByProperty.get(current.id), depreciationsByProperty.get(current.id));
|
|
4708
|
+
return minTaxPosition > currentTaxPosition ? current : min;
|
|
4709
|
+
}, this.first);
|
|
4766
4710
|
};
|
|
4767
|
-
Object.defineProperty(Depreciation.prototype, "claimAmount", {
|
|
4768
|
-
/**
|
|
4769
|
-
* @TODO Michael: remove and check everywhere in reports
|
|
4770
|
-
*/
|
|
4771
|
-
get: function () {
|
|
4772
|
-
var _a;
|
|
4773
|
-
return ((_a = this.currentYearForecast) === null || _a === void 0 ? void 0 : _a.claimAmount) || 0;
|
|
4774
|
-
},
|
|
4775
|
-
enumerable: false,
|
|
4776
|
-
configurable: true
|
|
4777
|
-
});
|
|
4778
|
-
Object.defineProperty(Depreciation.prototype, "amountWithGst", {
|
|
4779
|
-
get: function () {
|
|
4780
|
-
// gst applies only to new assets
|
|
4781
|
-
if (this.isNew()) {
|
|
4782
|
-
return _super.prototype.amountWithGst;
|
|
4783
|
-
}
|
|
4784
|
-
return this.amount;
|
|
4785
|
-
},
|
|
4786
|
-
enumerable: false,
|
|
4787
|
-
configurable: true
|
|
4788
|
-
});
|
|
4789
|
-
Object.defineProperty(Depreciation.prototype, "gstClaimAmount", {
|
|
4790
|
-
get: function () {
|
|
4791
|
-
var _a;
|
|
4792
|
-
return this.gstAmount * ((_a = this.currentYearForecast) === null || _a === void 0 ? void 0 : _a.claimRate);
|
|
4793
|
-
},
|
|
4794
|
-
enumerable: false,
|
|
4795
|
-
configurable: true
|
|
4796
|
-
});
|
|
4797
4711
|
/**
|
|
4798
|
-
*
|
|
4712
|
+
* Show best performance properties first
|
|
4713
|
+
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/217677997/Property+Tank+Dashboard
|
|
4799
4714
|
*/
|
|
4800
|
-
|
|
4801
|
-
|
|
4715
|
+
PropertyCollection.prototype.sortByBestPerformance = function (transactions, depreciations) {
|
|
4716
|
+
var activeProperties = this.getActiveProperties();
|
|
4717
|
+
// nothing to sort when no active properties
|
|
4718
|
+
if (!activeProperties.length) {
|
|
4719
|
+
return this;
|
|
4720
|
+
}
|
|
4721
|
+
var bestProperties = uniqBy__default["default"](this.create([
|
|
4722
|
+
activeProperties.getBestPerformanceGrowthProperty(),
|
|
4723
|
+
activeProperties.getBestPerformanceTaxProperty(transactions, depreciations)
|
|
4724
|
+
]).toArray(), 'id');
|
|
4725
|
+
var newItems = this.remove(bestProperties).toArray();
|
|
4726
|
+
newItems.unshift.apply(newItems, __spreadArray([], __read(bestProperties)));
|
|
4727
|
+
return this.create(newItems);
|
|
4802
4728
|
};
|
|
4803
|
-
return
|
|
4804
|
-
}(
|
|
4805
|
-
Depreciation.WRITTEN_OFF_THRESHOLD = 300;
|
|
4806
|
-
Depreciation.LOW_VALUE_POOL_THRESHOLD = 1000;
|
|
4807
|
-
__decorate([
|
|
4808
|
-
classTransformer.Type(function () { return Date; })
|
|
4809
|
-
], Depreciation.prototype, "purchaseDate", void 0);
|
|
4810
|
-
__decorate([
|
|
4811
|
-
classTransformer.Type(function () { return Date; })
|
|
4812
|
-
], Depreciation.prototype, "date", void 0);
|
|
4813
|
-
__decorate([
|
|
4814
|
-
classTransformer.Type(function () { return Date; })
|
|
4815
|
-
], Depreciation.prototype, "lowValuePoolDate", void 0);
|
|
4816
|
-
__decorate([
|
|
4817
|
-
classTransformer.Type(function () { return Date; })
|
|
4818
|
-
], Depreciation.prototype, "writeOffManualDate", void 0);
|
|
4819
|
-
__decorate([
|
|
4820
|
-
classTransformer.Type(function () { return Date; })
|
|
4821
|
-
], Depreciation.prototype, "writeOffDate", void 0);
|
|
4822
|
-
__decorate([
|
|
4823
|
-
classTransformer.Type(function () { return DepreciationCapitalProject; })
|
|
4824
|
-
], Depreciation.prototype, "depreciationCapitalProject", void 0);
|
|
4825
|
-
__decorate([
|
|
4826
|
-
classTransformer.Type(function () { return DepreciationForecast; }),
|
|
4827
|
-
classTransformer.Transform(function (_c) {
|
|
4828
|
-
var value = _c.value, obj = _c.obj;
|
|
4829
|
-
// value = array of DepreciationForecast
|
|
4830
|
-
// obj = plain (whole Depreciation object)
|
|
4831
|
-
// Set isLVP flag for each DepreciationForecast
|
|
4832
|
-
// @TODO refactor
|
|
4833
|
-
value.forEach(function (forecast) {
|
|
4834
|
-
forecast.isLVP =
|
|
4835
|
-
forecast.closeBalance < 1000 &&
|
|
4836
|
-
obj.calculation === exports.DepreciationCalculationEnum.DIMINISHING &&
|
|
4837
|
-
obj.type === exports.DepreciationTypeEnum.PLANT_EQUIPMENT &&
|
|
4838
|
-
!(obj.amount > Depreciation.WRITTEN_OFF_THRESHOLD && obj.amount < Depreciation.LOW_VALUE_POOL_THRESHOLD) &&
|
|
4839
|
-
!(obj.writeOffDate && new FinancialYear(new Date(obj.writeOffDate)).year === obj.financialYear);
|
|
4840
|
-
});
|
|
4841
|
-
return value;
|
|
4842
|
-
})
|
|
4843
|
-
], Depreciation.prototype, "forecasts", void 0);
|
|
4844
|
-
__decorate([
|
|
4845
|
-
classTransformer.Type(function () { return ChartAccounts; })
|
|
4846
|
-
], Depreciation.prototype, "chartAccounts", void 0);
|
|
4847
|
-
__decorate([
|
|
4848
|
-
classTransformer.Type(function () { return BankTransaction; })
|
|
4849
|
-
], Depreciation.prototype, "bankTransaction", void 0);
|
|
4850
|
-
__decorate([
|
|
4851
|
-
classTransformer.Exclude()
|
|
4852
|
-
], Depreciation.prototype, "amountWithGst", null);
|
|
4853
|
-
__decorate([
|
|
4854
|
-
classTransformer.Exclude()
|
|
4855
|
-
], Depreciation.prototype, "gstClaimAmount", null);
|
|
4729
|
+
return PropertyCollection;
|
|
4730
|
+
}(Collection));
|
|
4856
4731
|
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
4862
|
-
// list of child transactions (fees)
|
|
4863
|
-
_this.transactions = [];
|
|
4864
|
-
_this.metadata = [];
|
|
4865
|
-
_this.allocations = [];
|
|
4866
|
-
_this.tax = 0;
|
|
4867
|
-
_this.operation = exports.TransactionOperationEnum.FIND_AND_MATCH;
|
|
4868
|
-
_this.claimPercent = 100;
|
|
4869
|
-
_this.amount = 0;
|
|
4870
|
-
return _this;
|
|
4732
|
+
var PropertyCategoryMovementCollection = /** @class */ (function (_super) {
|
|
4733
|
+
__extends(PropertyCategoryMovementCollection, _super);
|
|
4734
|
+
function PropertyCategoryMovementCollection() {
|
|
4735
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
4871
4736
|
}
|
|
4872
|
-
|
|
4873
|
-
|
|
4737
|
+
/**
|
|
4738
|
+
* @TODO TT-2355 Alex refactor propertyForecast, use separated api (then I can remove property from param)
|
|
4739
|
+
*/
|
|
4740
|
+
PropertyCategoryMovementCollection.prototype.getByForecast = function (property, forecast) {
|
|
4741
|
+
var financialYear = new FinancialYear(forecast.financialYear);
|
|
4742
|
+
return this.filterBy('property.id', property.id).filter(function (movement) {
|
|
4743
|
+
return movement.fromDate <= financialYear.endDate && !movement.toDate || movement.toDate >= financialYear.startDate;
|
|
4744
|
+
});
|
|
4874
4745
|
};
|
|
4875
|
-
|
|
4876
|
-
return this.
|
|
4746
|
+
PropertyCategoryMovementCollection.prototype.hasCategory = function (categoryId) {
|
|
4747
|
+
return !!this.findBy('propertyCategory.id', categoryId);
|
|
4877
4748
|
};
|
|
4749
|
+
return PropertyCategoryMovementCollection;
|
|
4750
|
+
}(Collection));
|
|
4751
|
+
|
|
4752
|
+
var VehicleClaimCollection = /** @class */ (function (_super) {
|
|
4753
|
+
__extends(VehicleClaimCollection, _super);
|
|
4754
|
+
function VehicleClaimCollection() {
|
|
4755
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
4756
|
+
}
|
|
4878
4757
|
/**
|
|
4879
|
-
* @
|
|
4758
|
+
* Get remaining kilometers limit. Total limit ({@link VehicleClaim.totalKmsLimit}) - claimed kilometers from other vehicle claims
|
|
4880
4759
|
*/
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
if (
|
|
4884
|
-
|
|
4760
|
+
VehicleClaimCollection.prototype.getKmsLimitForClaim = function (claim) {
|
|
4761
|
+
var collection = this;
|
|
4762
|
+
if (claim) {
|
|
4763
|
+
collection = collection.removeBy('id', claim.id);
|
|
4885
4764
|
}
|
|
4886
|
-
return
|
|
4765
|
+
return VehicleClaim.totalKmsLimit - collection.sumBy('kilometers');
|
|
4887
4766
|
};
|
|
4888
4767
|
/**
|
|
4889
|
-
* @
|
|
4768
|
+
* Get remaining work usage limit. Total limit ({@link VehicleClaim.totalWorkUsagePercent}) - claimed percent from other vehicle claims
|
|
4890
4769
|
*/
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
if (
|
|
4894
|
-
|
|
4770
|
+
VehicleClaimCollection.prototype.getWorkUsageLimitForClaim = function (claim) {
|
|
4771
|
+
var collection = this;
|
|
4772
|
+
if (claim) {
|
|
4773
|
+
collection = collection.removeBy('id', claim.id);
|
|
4895
4774
|
}
|
|
4896
|
-
return
|
|
4775
|
+
return VehicleClaim.totalWorkUsagePercent - collection.sumBy('workUsage');
|
|
4897
4776
|
};
|
|
4898
|
-
|
|
4899
|
-
|
|
4777
|
+
return VehicleClaimCollection;
|
|
4778
|
+
}(Collection));
|
|
4779
|
+
|
|
4780
|
+
var VehicleLogbookCollection = /** @class */ (function (_super) {
|
|
4781
|
+
__extends(VehicleLogbookCollection, _super);
|
|
4782
|
+
function VehicleLogbookCollection() {
|
|
4783
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
4784
|
+
}
|
|
4785
|
+
/**
|
|
4786
|
+
* Best period may be calculated only when user has logbooks minimum for VehicleLogbook.bestPeriodWeeks
|
|
4787
|
+
* @TODO Vik: Best period: move this and related logic to backend
|
|
4788
|
+
*/
|
|
4789
|
+
VehicleLogbookCollection.prototype.isBestPeriodExist = function () {
|
|
4790
|
+
if (this.items.length < 2) {
|
|
4791
|
+
return false;
|
|
4792
|
+
}
|
|
4793
|
+
return VehicleLogbook.bestPeriodDuration < (this.last.date.getTime() - this.first.date.getTime());
|
|
4900
4794
|
};
|
|
4901
|
-
|
|
4902
|
-
|
|
4795
|
+
/**
|
|
4796
|
+
* Get collection of non-personal logbooks (work-related, sole-related).
|
|
4797
|
+
* @TODO Vik: Best period: move this and related logic to backend
|
|
4798
|
+
*/
|
|
4799
|
+
VehicleLogbookCollection.prototype.getClaimableLogbooks = function () {
|
|
4800
|
+
return this.filterBy('isPersonal', false);
|
|
4903
4801
|
};
|
|
4904
|
-
Object.defineProperty(Transaction.prototype, "chartAccountsCategories", {
|
|
4905
|
-
get: function () {
|
|
4906
|
-
switch (true) {
|
|
4907
|
-
case this.isPersonal():
|
|
4908
|
-
return CHART_ACCOUNTS_CATEGORIES.personal;
|
|
4909
|
-
case this.isPropertyTank():
|
|
4910
|
-
return CHART_ACCOUNTS_CATEGORIES.property;
|
|
4911
|
-
case this.isSoleTank():
|
|
4912
|
-
return CHART_ACCOUNTS_CATEGORIES.sole;
|
|
4913
|
-
default:
|
|
4914
|
-
return CHART_ACCOUNTS_CATEGORIES.work;
|
|
4915
|
-
}
|
|
4916
|
-
},
|
|
4917
|
-
enumerable: false,
|
|
4918
|
-
configurable: true
|
|
4919
|
-
});
|
|
4920
|
-
Object.defineProperty(Transaction.prototype, "isKmsChartAccountsCategory", {
|
|
4921
|
-
/**
|
|
4922
|
-
* Check if transaction has 'Kms travelled for work' chart accounts category
|
|
4923
|
-
*/
|
|
4924
|
-
get: function () {
|
|
4925
|
-
return this.chartAccounts.id === exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK;
|
|
4926
|
-
},
|
|
4927
|
-
enumerable: false,
|
|
4928
|
-
configurable: true
|
|
4929
|
-
});
|
|
4930
4802
|
/**
|
|
4931
|
-
* Get
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
return this.date;
|
|
4935
|
-
};
|
|
4936
|
-
/**
|
|
4937
|
-
* Check if transaction type is vehicle
|
|
4803
|
+
* Get Logbook Period with the biggest work usage percent
|
|
4804
|
+
* Best period duration is defined as VehicleLogbook.bestPeriodWeeks by the ATO
|
|
4805
|
+
* @TODO Vik: Best period: move this and related logic to backend
|
|
4938
4806
|
*/
|
|
4939
|
-
|
|
4940
|
-
|
|
4807
|
+
VehicleLogbookCollection.prototype.getBestPeriod = function () {
|
|
4808
|
+
if (!this.isBestPeriodExist()) {
|
|
4809
|
+
return null;
|
|
4810
|
+
}
|
|
4811
|
+
var bestPeriod;
|
|
4812
|
+
// get list of all logbooks available for best period calculation
|
|
4813
|
+
var claimableLogbooks = this.getClaimableLogbooks().toArray();
|
|
4814
|
+
for (var i = 0; i < claimableLogbooks.length; i++) {
|
|
4815
|
+
// no sense to check next logbooks because we already get the end of the year
|
|
4816
|
+
if (bestPeriod && bestPeriod.isEndOfYear()) {
|
|
4817
|
+
break;
|
|
4818
|
+
}
|
|
4819
|
+
// get date range started from current handling logbook date
|
|
4820
|
+
var dateRange = claimableLogbooks[i].getPeriod();
|
|
4821
|
+
// get all logbooks included in current logbook period
|
|
4822
|
+
var logbooksInRange = this.filterByRange('date', dateRange.start, dateRange.end);
|
|
4823
|
+
var currentPeriod = classTransformer.plainToClass(LogbookPeriod, {
|
|
4824
|
+
from: dateRange.start,
|
|
4825
|
+
to: dateRange.end,
|
|
4826
|
+
kilometers: logbooksInRange.getClaimableLogbooks().kilometers,
|
|
4827
|
+
workUsage: logbooksInRange.getWorkUsage(),
|
|
4828
|
+
logbooks: logbooksInRange
|
|
4829
|
+
});
|
|
4830
|
+
// compare with previous best period and overwrite if needs
|
|
4831
|
+
if (!bestPeriod || currentPeriod.workUsage > bestPeriod.workUsage) {
|
|
4832
|
+
bestPeriod = currentPeriod;
|
|
4833
|
+
}
|
|
4834
|
+
else if (currentPeriod.workUsage === bestPeriod.workUsage) {
|
|
4835
|
+
// if work usage is the same then get period with the biggest work usage for work tank
|
|
4836
|
+
var oldWorkUsage = bestPeriod.logbooks.filterBy('tankType', exports.TankTypeEnum.WORK).getWorkUsage();
|
|
4837
|
+
var currentWorkUsage = currentPeriod.logbooks.filterBy('tankType', exports.TankTypeEnum.WORK).getWorkUsage();
|
|
4838
|
+
if (oldWorkUsage < currentWorkUsage) {
|
|
4839
|
+
bestPeriod = currentPeriod;
|
|
4840
|
+
}
|
|
4841
|
+
}
|
|
4842
|
+
}
|
|
4843
|
+
return bestPeriod;
|
|
4941
4844
|
};
|
|
4942
|
-
Object.defineProperty(
|
|
4943
|
-
get: function () {
|
|
4944
|
-
return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.TAX_FREE_COMPONENT);
|
|
4945
|
-
},
|
|
4946
|
-
enumerable: false,
|
|
4947
|
-
configurable: true
|
|
4948
|
-
});
|
|
4949
|
-
Object.defineProperty(Transaction.prototype, "frankingCredit", {
|
|
4950
|
-
get: function () {
|
|
4951
|
-
return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.FRANKING_CREDIT);
|
|
4952
|
-
},
|
|
4953
|
-
enumerable: false,
|
|
4954
|
-
configurable: true
|
|
4955
|
-
});
|
|
4956
|
-
Object.defineProperty(Transaction.prototype, "eligibleForReduction", {
|
|
4957
|
-
get: function () {
|
|
4958
|
-
return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.ELIGIBLE_FOR_REDUCTION);
|
|
4959
|
-
},
|
|
4960
|
-
enumerable: false,
|
|
4961
|
-
configurable: true
|
|
4962
|
-
});
|
|
4963
|
-
Object.defineProperty(Transaction.prototype, "untaxedElement", {
|
|
4964
|
-
get: function () {
|
|
4965
|
-
return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.UNTAXED_ELEMENT);
|
|
4966
|
-
},
|
|
4967
|
-
enumerable: false,
|
|
4968
|
-
configurable: true
|
|
4969
|
-
});
|
|
4970
|
-
Object.defineProperty(Transaction.prototype, "isTransfer", {
|
|
4845
|
+
Object.defineProperty(VehicleLogbookCollection.prototype, "kilometers", {
|
|
4971
4846
|
/**
|
|
4972
|
-
*
|
|
4973
|
-
* @TODO bad usage of get (and all is* methods), getter should sound like a noun
|
|
4847
|
+
* Calculate total kilometers traveled
|
|
4974
4848
|
*/
|
|
4975
4849
|
get: function () {
|
|
4976
|
-
return this.
|
|
4977
|
-
},
|
|
4978
|
-
enumerable: false,
|
|
4979
|
-
configurable: true
|
|
4980
|
-
});
|
|
4981
|
-
Transaction.prototype.isFindAndMatch = function () {
|
|
4982
|
-
return this.operation === exports.TransactionOperationEnum.FIND_AND_MATCH;
|
|
4983
|
-
};
|
|
4984
|
-
Transaction.prototype.isMatchInvoice = function () {
|
|
4985
|
-
return this.operation === exports.TransactionOperationEnum.MATCH_INVOICE;
|
|
4986
|
-
};
|
|
4987
|
-
Object.defineProperty(Transaction.prototype, "debit", {
|
|
4988
|
-
get: function () {
|
|
4989
|
-
return this.isDebit() ? Math.abs(this.grossAmount) : 0;
|
|
4990
|
-
},
|
|
4991
|
-
enumerable: false,
|
|
4992
|
-
configurable: true
|
|
4993
|
-
});
|
|
4994
|
-
Object.defineProperty(Transaction.prototype, "credit", {
|
|
4995
|
-
get: function () {
|
|
4996
|
-
return this.isCredit() ? Math.abs(this.grossAmount) : 0;
|
|
4850
|
+
return this.sumBy('kilometers');
|
|
4997
4851
|
},
|
|
4998
4852
|
enumerable: false,
|
|
4999
4853
|
configurable: true
|
|
5000
4854
|
});
|
|
5001
4855
|
/**
|
|
5002
|
-
*
|
|
5003
|
-
* @
|
|
5004
|
-
* @Todo modify 'metadata' property from array to Collection
|
|
5005
|
-
*/
|
|
5006
|
-
Transaction.prototype.getMetadataFieldValue = function (field) {
|
|
5007
|
-
var _a;
|
|
5008
|
-
return +((_a = this.metadata.find(function (transactionMetadata) {
|
|
5009
|
-
return transactionMetadata.chartAccountsMetadata.id === field;
|
|
5010
|
-
})) === null || _a === void 0 ? void 0 : _a.value) || 0;
|
|
5011
|
-
};
|
|
5012
|
-
Transaction.prototype.isCash = function () {
|
|
5013
|
-
return this.source === exports.TransactionSourceEnum.CASH;
|
|
5014
|
-
};
|
|
5015
|
-
/**
|
|
5016
|
-
* Create Depreciation instance based on Transaction
|
|
5017
|
-
*/
|
|
5018
|
-
Transaction.prototype.toDepreciation = function () {
|
|
5019
|
-
return classTransformer.plainToClass(Depreciation, {
|
|
5020
|
-
date: this.date,
|
|
5021
|
-
amount: this.amount,
|
|
5022
|
-
chartAccounts: this.chartAccounts,
|
|
5023
|
-
description: this.description,
|
|
5024
|
-
type: exports.DepreciationTypeEnum.PLANT_EQUIPMENT,
|
|
5025
|
-
claimPercent: this.claimPercent,
|
|
5026
|
-
property: this.property,
|
|
5027
|
-
calculation: this.property ? this.property.depreciationCalculation : exports.DepreciationCalculationEnum.PRIME_COST
|
|
5028
|
-
});
|
|
5029
|
-
};
|
|
5030
|
-
/**
|
|
5031
|
-
* Check if transaction is completely allocated
|
|
4856
|
+
* Calculate work usage (percent of business-related kilometers from total kilometers)
|
|
4857
|
+
* @TODO Alex: TT-2089 replace with getter
|
|
5032
4858
|
*/
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
Transaction.prototype.getAllocatedAmount = function (allocations) {
|
|
5037
|
-
return allocations.filterBy('transaction.id', this.id).sumBy('amount');
|
|
5038
|
-
};
|
|
5039
|
-
Transaction.prototype.getAllocatedClaimAmount = function (allocations) {
|
|
5040
|
-
return this.getAllocatedAmount(allocations) * this.claimRatio;
|
|
4859
|
+
VehicleLogbookCollection.prototype.getWorkUsage = function () {
|
|
4860
|
+
var workKilometers = this.getClaimableLogbooks().kilometers;
|
|
4861
|
+
return Math.round(workKilometers / this.kilometers * 100);
|
|
5041
4862
|
};
|
|
5042
4863
|
/**
|
|
5043
|
-
* Get
|
|
4864
|
+
* Get list of logbooks related to passed vehicle claim
|
|
5044
4865
|
*/
|
|
5045
|
-
|
|
5046
|
-
return
|
|
4866
|
+
VehicleLogbookCollection.prototype.getByVehicleClaim = function (vehicleClaim) {
|
|
4867
|
+
return vehicleClaim.isSoleTank()
|
|
4868
|
+
// sole tank may have multiple vehicle claims, so we need to filter by business.id
|
|
4869
|
+
? this.filterBy('business.id', vehicleClaim.business.id)
|
|
4870
|
+
// work tank may have only one vehicle claim, so we need to filter by tank type
|
|
4871
|
+
: this.filterBy('tankType', exports.TankTypeEnum.WORK);
|
|
5047
4872
|
};
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
* Total transaction amount including taxes and other additional amounts
|
|
5051
|
-
*/
|
|
5052
|
-
get: function () {
|
|
5053
|
-
var grossAmount = _super.prototype.grossAmount + this.tax;
|
|
5054
|
-
if (this.isExpense()) {
|
|
5055
|
-
return grossAmount;
|
|
5056
|
-
}
|
|
5057
|
-
grossAmount += this.transactions.filter(function (t) { var _a; return !((_a = t.chartAccounts) === null || _a === void 0 ? void 0 : _a.isSalaryIncluded()); }).reduce(function (sum, transaction) { return sum + Math.abs(transaction.amount); }, 0);
|
|
5058
|
-
if (this.isWorkTank()) {
|
|
5059
|
-
grossAmount += this.frankingCredit - this.taxFreeComponent - this.eligibleForReduction;
|
|
5060
|
-
}
|
|
5061
|
-
return +(Math.round(grossAmount * 100) / 100).toFixed(2);
|
|
5062
|
-
},
|
|
5063
|
-
enumerable: false,
|
|
5064
|
-
configurable: true
|
|
5065
|
-
});
|
|
5066
|
-
return Transaction;
|
|
5067
|
-
}(Transaction$1));
|
|
5068
|
-
__decorate([
|
|
5069
|
-
classTransformer.Type(function () { return Transaction; })
|
|
5070
|
-
], Transaction.prototype, "transactions", void 0);
|
|
5071
|
-
__decorate([
|
|
5072
|
-
classTransformer.Type(function () { return Property; })
|
|
5073
|
-
], Transaction.prototype, "property", void 0);
|
|
5074
|
-
__decorate([
|
|
5075
|
-
classTransformer.Type(function () { return TransactionReceipt; })
|
|
5076
|
-
], Transaction.prototype, "receipt", void 0);
|
|
5077
|
-
__decorate([
|
|
5078
|
-
classTransformer.Type(function () { return ChartAccounts; })
|
|
5079
|
-
], Transaction.prototype, "chartAccounts", void 0);
|
|
5080
|
-
__decorate([
|
|
5081
|
-
classTransformer.Type(function () { return IncomeSource; })
|
|
5082
|
-
], Transaction.prototype, "incomeSource", void 0);
|
|
5083
|
-
__decorate([
|
|
5084
|
-
classTransformer.Type(function () { return TransactionMetadata; })
|
|
5085
|
-
], Transaction.prototype, "metadata", void 0);
|
|
5086
|
-
__decorate([
|
|
5087
|
-
classTransformer.Type(function () { return Transaction; })
|
|
5088
|
-
], Transaction.prototype, "transfer", void 0);
|
|
5089
|
-
__decorate([
|
|
5090
|
-
classTransformer.Type(function () { return Loan; })
|
|
5091
|
-
], Transaction.prototype, "loan", void 0);
|
|
5092
|
-
__decorate([
|
|
5093
|
-
classTransformer.Type(function () { return Date; })
|
|
5094
|
-
], Transaction.prototype, "date", void 0);
|
|
5095
|
-
__decorate([
|
|
5096
|
-
classTransformer.Type(function () { return TransactionAllocation; })
|
|
5097
|
-
], Transaction.prototype, "allocations", void 0);
|
|
5098
|
-
|
|
5099
|
-
var SoleInvoiceItem = /** @class */ (function (_super) {
|
|
5100
|
-
__extends(SoleInvoiceItem, _super);
|
|
5101
|
-
function SoleInvoiceItem() {
|
|
5102
|
-
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
5103
|
-
_this.isGST = false;
|
|
5104
|
-
return _this;
|
|
5105
|
-
}
|
|
5106
|
-
Object.defineProperty(SoleInvoiceItem.prototype, "totalPrice", {
|
|
5107
|
-
get: function () {
|
|
5108
|
-
return this.price * this.quantity;
|
|
5109
|
-
},
|
|
5110
|
-
enumerable: false,
|
|
5111
|
-
configurable: true
|
|
5112
|
-
});
|
|
5113
|
-
return SoleInvoiceItem;
|
|
5114
|
-
}(SoleInvoiceItem$1));
|
|
5115
|
-
__decorate([
|
|
5116
|
-
classTransformer.Type(function () { return SoleInvoice; })
|
|
5117
|
-
], SoleInvoiceItem.prototype, "invoice", void 0);
|
|
5118
|
-
__decorate([
|
|
5119
|
-
classTransformer.Type(function () { return ChartAccounts; })
|
|
5120
|
-
], SoleInvoiceItem.prototype, "chartAccounts", void 0);
|
|
5121
|
-
__decorate([
|
|
5122
|
-
classTransformer.Type(function () { return Transaction; })
|
|
5123
|
-
], SoleInvoiceItem.prototype, "transaction", void 0);
|
|
5124
|
-
|
|
5125
|
-
var SoleContact$1 = /** @class */ (function (_super) {
|
|
5126
|
-
__extends(SoleContact, _super);
|
|
5127
|
-
function SoleContact() {
|
|
5128
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
5129
|
-
}
|
|
5130
|
-
return SoleContact;
|
|
5131
|
-
}(AbstractModel));
|
|
4873
|
+
return VehicleLogbookCollection;
|
|
4874
|
+
}(Collection));
|
|
5132
4875
|
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
4876
|
+
/**
|
|
4877
|
+
* List of objects grouped by passed property
|
|
4878
|
+
*/
|
|
4879
|
+
var Dictionary = /** @class */ (function () {
|
|
4880
|
+
function Dictionary(items, path) {
|
|
4881
|
+
if (path === void 0) { path = 'id'; }
|
|
4882
|
+
this.items = {};
|
|
4883
|
+
if (!items.length) {
|
|
4884
|
+
return;
|
|
4885
|
+
}
|
|
4886
|
+
// Do nothing if provided path was not found in the 1st item
|
|
4887
|
+
if (!hasIn__default["default"](items[0], path.split('.')[0])) {
|
|
4888
|
+
return;
|
|
4889
|
+
}
|
|
4890
|
+
this.groupItems(items, path);
|
|
5138
4891
|
}
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
return this.firstName + " " + this.lastName;
|
|
5142
|
-
},
|
|
5143
|
-
enumerable: false,
|
|
5144
|
-
configurable: true
|
|
5145
|
-
});
|
|
5146
|
-
SoleContact.prototype.getPhotoPlaceholder = function () {
|
|
5147
|
-
return "" + this.firstName[0].toUpperCase() + this.lastName[0].toUpperCase();
|
|
4892
|
+
Dictionary.prototype.add = function (key, value) {
|
|
4893
|
+
this.items[key] = value;
|
|
5148
4894
|
};
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
return '';
|
|
4895
|
+
Dictionary.prototype.get = function (key) {
|
|
4896
|
+
return this.items[key] !== undefined ? this.items[key] : null;
|
|
5152
4897
|
};
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
], SoleContact.prototype, "invoices", void 0);
|
|
4898
|
+
Dictionary.prototype.groupItems = function (items, path) {
|
|
4899
|
+
var _this = this;
|
|
4900
|
+
items.forEach(function (item) {
|
|
4901
|
+
var key = get__default["default"](item, path);
|
|
4902
|
+
// if object does not have property for grouping it will be grouped as 'other'
|
|
4903
|
+
if (key === undefined) {
|
|
4904
|
+
key = 'other';
|
|
4905
|
+
}
|
|
4906
|
+
_this.items[key] = item;
|
|
4907
|
+
});
|
|
4908
|
+
};
|
|
4909
|
+
return Dictionary;
|
|
4910
|
+
}());
|
|
5167
4911
|
|
|
5168
|
-
var
|
|
5169
|
-
__extends(
|
|
5170
|
-
function
|
|
4912
|
+
var SoleBusinessLossesCollection = /** @class */ (function (_super) {
|
|
4913
|
+
__extends(SoleBusinessLossesCollection, _super);
|
|
4914
|
+
function SoleBusinessLossesCollection() {
|
|
5171
4915
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
5172
4916
|
}
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
_this
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
], SoleInvoiceTemplate.prototype, "bankAccount", void 0);
|
|
5214
|
-
|
|
5215
|
-
exports.SoleInvoiceStatusesEnum = void 0;
|
|
5216
|
-
(function (SoleInvoiceStatusesEnum) {
|
|
5217
|
-
SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["CANCELED"] = 0] = "CANCELED";
|
|
5218
|
-
SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["DRAFT"] = 1] = "DRAFT";
|
|
5219
|
-
SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PENDING"] = 2] = "PENDING";
|
|
5220
|
-
SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PAID"] = 3] = "PAID";
|
|
5221
|
-
})(exports.SoleInvoiceStatusesEnum || (exports.SoleInvoiceStatusesEnum = {}));
|
|
5222
|
-
|
|
5223
|
-
exports.SoleInvoiceTaxTypeEnum = void 0;
|
|
5224
|
-
(function (SoleInvoiceTaxTypeEnum) {
|
|
5225
|
-
SoleInvoiceTaxTypeEnum[SoleInvoiceTaxTypeEnum["TAX_EXCLUSIVE"] = 0] = "TAX_EXCLUSIVE";
|
|
5226
|
-
SoleInvoiceTaxTypeEnum[SoleInvoiceTaxTypeEnum["TAX_INCLUSIVE"] = 1] = "TAX_INCLUSIVE";
|
|
5227
|
-
SoleInvoiceTaxTypeEnum[SoleInvoiceTaxTypeEnum["NO_TAX"] = 2] = "NO_TAX";
|
|
5228
|
-
})(exports.SoleInvoiceTaxTypeEnum || (exports.SoleInvoiceTaxTypeEnum = {}));
|
|
4917
|
+
/**
|
|
4918
|
+
* Business loss applied in current year, includes previous year losses and current year losses for businesses matching offset rule
|
|
4919
|
+
*/
|
|
4920
|
+
SoleBusinessLossesCollection.prototype.calculateBusinessLossApplied = function (transactions) {
|
|
4921
|
+
var _this = this;
|
|
4922
|
+
// claim amounts for businesses that can be applied to be reduced by prior year business losses
|
|
4923
|
+
var claimAmountsByBusinessId = this.getClaimAmountsByBusinessId(transactions);
|
|
4924
|
+
return Object.keys(claimAmountsByBusinessId.items).reduce(function (sum, businessId) {
|
|
4925
|
+
var loss = _this.findBy('business.id', +businessId);
|
|
4926
|
+
var lossOpenBalance = (loss === null || loss === void 0 ? void 0 : loss.openBalance) || 0;
|
|
4927
|
+
// business loss can be applied to business profit or other income types profit in case in offset rule met
|
|
4928
|
+
return sum + ((loss === null || loss === void 0 ? void 0 : loss.offsetRule) ? lossOpenBalance : Math.min(lossOpenBalance, claimAmountsByBusinessId.get(businessId)));
|
|
4929
|
+
}, 0);
|
|
4930
|
+
};
|
|
4931
|
+
/**
|
|
4932
|
+
* Get business claim amounts that can be applied to be reduced by prior year business losses:
|
|
4933
|
+
* businesses with income or businesses with a loss, but which met the non-commercial loss rules
|
|
4934
|
+
* https://www.ato.gov.au/Business/Non-commercial-losses/
|
|
4935
|
+
*/
|
|
4936
|
+
SoleBusinessLossesCollection.prototype.getClaimAmountsByBusinessId = function (transactions) {
|
|
4937
|
+
var _this = this;
|
|
4938
|
+
var claimAmountsByBusinessId = new Dictionary([]);
|
|
4939
|
+
var transactionsByBusinessId = new CollectionDictionary(transactions, 'business.id');
|
|
4940
|
+
transactionsByBusinessId.keys.forEach(function (businessId) {
|
|
4941
|
+
var _a;
|
|
4942
|
+
// business loss may not exist if, when creating a business, user didn't add losses for previous years
|
|
4943
|
+
var lossOffsetRule = (_a = _this.findBy('business.id', +businessId)) === null || _a === void 0 ? void 0 : _a.offsetRule;
|
|
4944
|
+
var businessClaimAmount = transactionsByBusinessId
|
|
4945
|
+
.get(businessId)
|
|
4946
|
+
.getClaimAmountByBusinessId(+businessId);
|
|
4947
|
+
// no way to apply loss for business without profit if offset rules not met
|
|
4948
|
+
if (businessClaimAmount < 0 && !lossOffsetRule) {
|
|
4949
|
+
return;
|
|
4950
|
+
}
|
|
4951
|
+
claimAmountsByBusinessId.add(businessId, businessClaimAmount);
|
|
4952
|
+
});
|
|
4953
|
+
return claimAmountsByBusinessId;
|
|
4954
|
+
};
|
|
4955
|
+
return SoleBusinessLossesCollection;
|
|
4956
|
+
}(Collection));
|
|
5229
4957
|
|
|
5230
|
-
var
|
|
5231
|
-
__extends(
|
|
5232
|
-
function
|
|
4958
|
+
var SoleInvoiceCollection = /** @class */ (function (_super) {
|
|
4959
|
+
__extends(SoleInvoiceCollection, _super);
|
|
4960
|
+
function SoleInvoiceCollection() {
|
|
5233
4961
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
5234
4962
|
}
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
4963
|
+
SoleInvoiceCollection.prototype.getOverdue = function () {
|
|
4964
|
+
return this.filter(function (invoice) { return invoice.isOverdue(); });
|
|
4965
|
+
};
|
|
4966
|
+
SoleInvoiceCollection.prototype.getUnpaid = function () {
|
|
4967
|
+
return this.filter(function (invoice) { return invoice.isUnpaid(); });
|
|
4968
|
+
};
|
|
4969
|
+
SoleInvoiceCollection.prototype.getPaid = function () {
|
|
4970
|
+
return this.filter(function (invoice) { return invoice.isPaid(); });
|
|
4971
|
+
};
|
|
4972
|
+
SoleInvoiceCollection.prototype.getPending = function () {
|
|
4973
|
+
return this.filter(function (invoice) { return invoice.isPending(); });
|
|
4974
|
+
};
|
|
4975
|
+
SoleInvoiceCollection.prototype.getTransactionsIds = function () {
|
|
4976
|
+
return flatten__default["default"](this.items.map(function (invoice) { return invoice.getTransactionsIds(); }));
|
|
4977
|
+
};
|
|
4978
|
+
return SoleInvoiceCollection;
|
|
5243
4979
|
}(Collection));
|
|
5244
4980
|
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
return _this;
|
|
4981
|
+
/**
|
|
4982
|
+
* Chart serie class: chart data item
|
|
4983
|
+
* @TODO consider rename to ChartSerieData
|
|
4984
|
+
*/
|
|
4985
|
+
var ChartSerie = /** @class */ (function () {
|
|
4986
|
+
function ChartSerie() {
|
|
5252
4987
|
}
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
4988
|
+
return ChartSerie;
|
|
4989
|
+
}());
|
|
4990
|
+
|
|
4991
|
+
/**
|
|
4992
|
+
* Chart data class
|
|
4993
|
+
* @TODO consider rename to ChartSerie
|
|
4994
|
+
*/
|
|
4995
|
+
var ChartData = /** @class */ (function () {
|
|
4996
|
+
function ChartData() {
|
|
4997
|
+
}
|
|
4998
|
+
return ChartData;
|
|
4999
|
+
}());
|
|
5000
|
+
__decorate([
|
|
5001
|
+
classTransformer.Type(function () { return ChartSerie; })
|
|
5002
|
+
], ChartData.prototype, "data", void 0);
|
|
5003
|
+
|
|
5004
|
+
var MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan'];
|
|
5005
|
+
|
|
5006
|
+
/**
|
|
5007
|
+
* @TODO extend from TransactionBaseCollection
|
|
5008
|
+
* Collection of transactions
|
|
5009
|
+
*/
|
|
5010
|
+
var TransactionCollection = /** @class */ (function (_super) {
|
|
5011
|
+
__extends(TransactionCollection, _super);
|
|
5012
|
+
/**
|
|
5013
|
+
* @TODO use TransactionBaseCollection instead
|
|
5014
|
+
* we use depreciations as expense transactions a lot
|
|
5015
|
+
*/
|
|
5016
|
+
function TransactionCollection(transactions, depreciations) {
|
|
5017
|
+
if (transactions === void 0) { transactions = []; }
|
|
5018
|
+
if (depreciations === void 0) { depreciations = []; }
|
|
5019
|
+
return _super.call(this, __spreadArray(__spreadArray([], __read(transactions)), __read(depreciations.map(function (depreciation) { return depreciation.toTransaction(); })))) || this;
|
|
5020
|
+
}
|
|
5021
|
+
TransactionCollection.prototype.getSoleTransactions = function () {
|
|
5022
|
+
return this.filter(function (transaction) { return transaction.isSoleTank(); });
|
|
5023
|
+
};
|
|
5024
|
+
Object.defineProperty(TransactionCollection.prototype, "amount", {
|
|
5257
5025
|
get: function () {
|
|
5258
|
-
return
|
|
5026
|
+
return this.sumBy('amount');
|
|
5259
5027
|
},
|
|
5260
5028
|
enumerable: false,
|
|
5261
5029
|
configurable: true
|
|
5262
5030
|
});
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5031
|
+
TransactionCollection.prototype.getUnallocatedAmount = function (allocations) {
|
|
5032
|
+
return this.items.reduce(function (sum, transaction) {
|
|
5033
|
+
return sum + transaction.getUnallocatedAmount(allocations.filterBy('transaction.id', transaction.id));
|
|
5034
|
+
}, 0);
|
|
5035
|
+
};
|
|
5036
|
+
/**
|
|
5037
|
+
* get date of the last transaction
|
|
5038
|
+
*/
|
|
5039
|
+
TransactionCollection.prototype.getLastTransactionDate = function () {
|
|
5040
|
+
return new Date(Math.max.apply(Math, this.items.map(function (transaction) { return transaction.date; })));
|
|
5041
|
+
};
|
|
5042
|
+
Object.defineProperty(TransactionCollection.prototype, "claimAmount", {
|
|
5267
5043
|
get: function () {
|
|
5268
|
-
return this.
|
|
5044
|
+
return this.items.reduce(function (sum, transaction) { return sum + transaction.claimAmount; }, 0);
|
|
5269
5045
|
},
|
|
5270
5046
|
enumerable: false,
|
|
5271
5047
|
configurable: true
|
|
5272
5048
|
});
|
|
5273
|
-
Object.defineProperty(
|
|
5274
|
-
/**
|
|
5275
|
-
* Total invoice price without GST
|
|
5276
|
-
*/
|
|
5049
|
+
Object.defineProperty(TransactionCollection.prototype, "grossClaimAmount", {
|
|
5277
5050
|
get: function () {
|
|
5278
|
-
|
|
5279
|
-
return this.price - this.GSTAmount;
|
|
5280
|
-
}
|
|
5281
|
-
return this.price;
|
|
5051
|
+
return this.items.reduce(function (sum, transaction) { return sum + transaction.grossClaimAmount; }, 0);
|
|
5282
5052
|
},
|
|
5283
5053
|
enumerable: false,
|
|
5284
5054
|
configurable: true
|
|
5285
5055
|
});
|
|
5286
|
-
Object.defineProperty(
|
|
5287
|
-
/**
|
|
5288
|
-
* Total final price (net + GST)
|
|
5289
|
-
*/
|
|
5056
|
+
Object.defineProperty(TransactionCollection.prototype, "grossAmount", {
|
|
5290
5057
|
get: function () {
|
|
5291
|
-
|
|
5292
|
-
return this.price + this.GSTAmount;
|
|
5293
|
-
}
|
|
5294
|
-
return this.price;
|
|
5058
|
+
return this.items.reduce(function (sum, transaction) { return sum + transaction.grossAmount; }, 0);
|
|
5295
5059
|
},
|
|
5296
5060
|
enumerable: false,
|
|
5297
5061
|
configurable: true
|
|
5298
5062
|
});
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5063
|
+
TransactionCollection.prototype.getByChartAccountsCategories = function (categories) {
|
|
5064
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return categories.includes(transaction.chartAccounts.category); }));
|
|
5065
|
+
};
|
|
5066
|
+
/**
|
|
5067
|
+
* Get transactions by month
|
|
5068
|
+
* @param monthIndex by which desired month should be taken
|
|
5069
|
+
*/
|
|
5070
|
+
TransactionCollection.prototype.getByMonth = function (monthIndex) {
|
|
5071
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.date.getMonth() === monthIndex; }));
|
|
5072
|
+
};
|
|
5073
|
+
/**
|
|
5074
|
+
* Get collection of transactions metadata
|
|
5075
|
+
*/
|
|
5076
|
+
TransactionCollection.prototype.getTransactionsMetadata = function () {
|
|
5077
|
+
var metadataArray = [];
|
|
5078
|
+
this.items.forEach(function (transaction) {
|
|
5079
|
+
metadataArray.push.apply(metadataArray, __spreadArray([], __read(transaction.metadata)));
|
|
5080
|
+
});
|
|
5081
|
+
return new Collection(metadataArray);
|
|
5082
|
+
};
|
|
5083
|
+
TransactionCollection.prototype.getIncomeTransactions = function () {
|
|
5084
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isIncome(); }));
|
|
5085
|
+
};
|
|
5086
|
+
TransactionCollection.prototype.getExpenseTransactions = function () {
|
|
5087
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isExpense() && !transaction.isInterest(); }));
|
|
5088
|
+
};
|
|
5089
|
+
Object.defineProperty(TransactionCollection.prototype, "claimIncome", {
|
|
5303
5090
|
get: function () {
|
|
5304
|
-
|
|
5305
|
-
case exports.SoleInvoiceTaxTypeEnum.TAX_INCLUSIVE:
|
|
5306
|
-
return this.inclusiveGSTAmount;
|
|
5307
|
-
case exports.SoleInvoiceTaxTypeEnum.TAX_EXCLUSIVE:
|
|
5308
|
-
return this.exclusiveGSTAmount;
|
|
5309
|
-
case exports.SoleInvoiceTaxTypeEnum.NO_TAX:
|
|
5310
|
-
return 0;
|
|
5311
|
-
}
|
|
5091
|
+
return this.getIncomeTransactions().claimAmount;
|
|
5312
5092
|
},
|
|
5313
5093
|
enumerable: false,
|
|
5314
5094
|
configurable: true
|
|
5315
5095
|
});
|
|
5316
|
-
Object.defineProperty(
|
|
5317
|
-
/**
|
|
5318
|
-
* When tax inclusive, GST amount is included to total price
|
|
5319
|
-
*/
|
|
5096
|
+
Object.defineProperty(TransactionCollection.prototype, "claimExpense", {
|
|
5320
5097
|
get: function () {
|
|
5321
|
-
|
|
5322
|
-
return +(gstPrice - (gstPrice / (1 + ChartAccounts.GSTRatio))).toFixed(2);
|
|
5098
|
+
return this.getExpenseTransactions().claimAmount;
|
|
5323
5099
|
},
|
|
5324
5100
|
enumerable: false,
|
|
5325
5101
|
configurable: true
|
|
5326
5102
|
});
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5103
|
+
TransactionCollection.prototype.getInterestTransactions = function () {
|
|
5104
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isInterest(); }));
|
|
5105
|
+
};
|
|
5106
|
+
Object.defineProperty(TransactionCollection.prototype, "claimInterest", {
|
|
5331
5107
|
get: function () {
|
|
5332
|
-
return
|
|
5108
|
+
return this.getInterestTransactions().claimAmount;
|
|
5333
5109
|
},
|
|
5334
5110
|
enumerable: false,
|
|
5335
5111
|
configurable: true
|
|
5336
5112
|
});
|
|
5337
|
-
|
|
5338
|
-
|
|
5113
|
+
/**
|
|
5114
|
+
* Get collection of transactions and properties filtered by properties ids
|
|
5115
|
+
* @param ids Ids of properties for filter
|
|
5116
|
+
*/
|
|
5117
|
+
TransactionCollection.prototype.getByPropertiesIds = function (ids) {
|
|
5118
|
+
return new TransactionCollection(this.items.filter(function (transaction) {
|
|
5119
|
+
var _a;
|
|
5120
|
+
return ids.includes((_a = transaction.property) === null || _a === void 0 ? void 0 : _a.id);
|
|
5121
|
+
}));
|
|
5339
5122
|
};
|
|
5340
|
-
|
|
5341
|
-
|
|
5123
|
+
/**
|
|
5124
|
+
* Get new collection filtered by income source id
|
|
5125
|
+
* @param id id of income source for filter
|
|
5126
|
+
*/
|
|
5127
|
+
TransactionCollection.prototype.getByIncomeSourceId = function (id) {
|
|
5128
|
+
return new TransactionCollection(this.items.filter(function (transaction) { var _a; return ((_a = transaction.incomeSource) === null || _a === void 0 ? void 0 : _a.id) === id; }));
|
|
5129
|
+
};
|
|
5130
|
+
/**
|
|
5131
|
+
* Get new collection filtered by chart accounts category
|
|
5132
|
+
* @param category Chart accounts category value
|
|
5133
|
+
*/
|
|
5134
|
+
TransactionCollection.prototype.getByChartAccountsCategory = function (category) {
|
|
5135
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.chartAccounts.category === category; }));
|
|
5136
|
+
};
|
|
5137
|
+
/**
|
|
5138
|
+
* Get new collection of property transactions
|
|
5139
|
+
*/
|
|
5140
|
+
TransactionCollection.prototype.getPropertyTransactions = function () {
|
|
5141
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isPropertyTank(); }));
|
|
5142
|
+
};
|
|
5143
|
+
TransactionCollection.prototype.getDebitTransactions = function () {
|
|
5144
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isDebit(); }));
|
|
5145
|
+
};
|
|
5146
|
+
TransactionCollection.prototype.getCreditTransactions = function () {
|
|
5147
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isCredit(); }));
|
|
5148
|
+
};
|
|
5149
|
+
TransactionCollection.prototype.getByAllocations = function (allocations) {
|
|
5150
|
+
return new TransactionCollection(this.items.filter(function (transaction) { return allocations.hasTransaction(transaction); }));
|
|
5151
|
+
};
|
|
5152
|
+
/**
|
|
5153
|
+
* Get transactions related to Vehicle category
|
|
5154
|
+
*/
|
|
5155
|
+
TransactionCollection.prototype.getVehicleTransactions = function () {
|
|
5156
|
+
return this.create(this.items.filter(function (transaction) {
|
|
5157
|
+
return transaction.isVehicleTransaction();
|
|
5158
|
+
}));
|
|
5159
|
+
};
|
|
5160
|
+
/**
|
|
5161
|
+
* Get new transaction collection filtered by tank type
|
|
5162
|
+
*/
|
|
5163
|
+
TransactionCollection.prototype.getByTankType = function (tankType) {
|
|
5164
|
+
return this.create(this.items.filter(function (transaction) {
|
|
5165
|
+
switch (tankType) {
|
|
5166
|
+
case exports.TankTypeEnum.PROPERTY:
|
|
5167
|
+
return transaction.isPropertyTank();
|
|
5168
|
+
case exports.TankTypeEnum.WORK:
|
|
5169
|
+
return transaction.isWorkTank();
|
|
5170
|
+
case exports.TankTypeEnum.SOLE:
|
|
5171
|
+
return transaction.isSoleTank();
|
|
5172
|
+
// Transaction may be not related to any tank type (personal)
|
|
5173
|
+
default:
|
|
5174
|
+
return false;
|
|
5175
|
+
}
|
|
5176
|
+
}));
|
|
5342
5177
|
};
|
|
5343
|
-
|
|
5344
|
-
return
|
|
5178
|
+
TransactionCollection.prototype.getExportHeader = function () {
|
|
5179
|
+
return ['Date', 'Description', 'Debit', 'Credit'];
|
|
5345
5180
|
};
|
|
5346
|
-
|
|
5347
|
-
return
|
|
5181
|
+
TransactionCollection.prototype.getExportFooter = function () {
|
|
5182
|
+
return [
|
|
5183
|
+
classTransformer.plainToClass(ExportCell, { value: 'Total', type: ExportCellTypeEnum.STRING }),
|
|
5184
|
+
classTransformer.plainToClass(ExportCell, { value: '', type: ExportCellTypeEnum.STRING }),
|
|
5185
|
+
classTransformer.plainToClass(ExportCell, { value: this.sumBy('debit'), type: ExportCellTypeEnum.CURRENCY }),
|
|
5186
|
+
classTransformer.plainToClass(ExportCell, { value: this.sumBy('credit'), type: ExportCellTypeEnum.CURRENCY })
|
|
5187
|
+
];
|
|
5348
5188
|
};
|
|
5349
|
-
|
|
5350
|
-
return this.
|
|
5189
|
+
TransactionCollection.prototype.getExportBody = function () {
|
|
5190
|
+
return this.items.map(function (transaction) {
|
|
5191
|
+
return [
|
|
5192
|
+
classTransformer.plainToClass(ExportCell, { value: transaction.date, type: ExportCellTypeEnum.DATE }),
|
|
5193
|
+
classTransformer.plainToClass(ExportCell, { value: transaction.description, type: ExportCellTypeEnum.STRING }),
|
|
5194
|
+
classTransformer.plainToClass(ExportCell, { value: transaction.debit, type: ExportCellTypeEnum.CURRENCY }),
|
|
5195
|
+
classTransformer.plainToClass(ExportCell, { value: transaction.credit, type: ExportCellTypeEnum.CURRENCY })
|
|
5196
|
+
];
|
|
5197
|
+
});
|
|
5351
5198
|
};
|
|
5352
|
-
|
|
5353
|
-
|
|
5199
|
+
/**
|
|
5200
|
+
* Get list of vehicle transactions filtered by vehicle claim
|
|
5201
|
+
*/
|
|
5202
|
+
TransactionCollection.prototype.getByVehicleClaim = function (vehicleClaim) {
|
|
5203
|
+
if (!vehicleClaim) {
|
|
5204
|
+
return this.create([]);
|
|
5205
|
+
}
|
|
5206
|
+
return vehicleClaim.isSoleTank()
|
|
5207
|
+
// sole tank may have multiple vehicle claims, so we need to filter by business.id
|
|
5208
|
+
? this.getVehicleTransactions().filterBy('business.id', vehicleClaim.business.id)
|
|
5209
|
+
// work tank may have only one vehicle claim, so we need to filter by tank type
|
|
5210
|
+
: this.getVehicleTransactions().filterBy('tankType', exports.TankTypeEnum.WORK);
|
|
5354
5211
|
};
|
|
5355
5212
|
/**
|
|
5356
|
-
*
|
|
5213
|
+
* Get list of vehicle transactions except KMS transactions
|
|
5357
5214
|
*/
|
|
5358
|
-
|
|
5359
|
-
return this
|
|
5215
|
+
TransactionCollection.prototype.getLogbookTransactions = function () {
|
|
5216
|
+
return this
|
|
5217
|
+
.getVehicleTransactions()
|
|
5218
|
+
.removeBy('chartAccounts.id', [exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK, exports.ChartAccountsListEnum.KLMS_TRAVELLED]);
|
|
5360
5219
|
};
|
|
5361
5220
|
/**
|
|
5362
|
-
*
|
|
5363
|
-
*
|
|
5221
|
+
* Build chart data with transactions cash position.
|
|
5222
|
+
* Cash position = Income - Expenses (include depreciations)
|
|
5223
|
+
* Chart data for each month from fin year start till current month
|
|
5364
5224
|
*/
|
|
5365
|
-
|
|
5366
|
-
|
|
5225
|
+
TransactionCollection.prototype.getCashPositionChartData = function () {
|
|
5226
|
+
var _this = this;
|
|
5227
|
+
var chartData = [
|
|
5228
|
+
classTransformer.plainToClass(ChartData, { name: 'Income', data: [] }),
|
|
5229
|
+
classTransformer.plainToClass(ChartData, { name: 'Expense', data: [] })
|
|
5230
|
+
];
|
|
5231
|
+
new FinancialYear().getPastMonths().forEach(function (month) {
|
|
5232
|
+
chartData[0].data.push({
|
|
5233
|
+
label: MONTHS[month],
|
|
5234
|
+
value: _this.getIncomeTransactions().getByMonth(month).claimAmount
|
|
5235
|
+
});
|
|
5236
|
+
chartData[1].data.push({
|
|
5237
|
+
label: MONTHS[month],
|
|
5238
|
+
value: Math.abs(_this.getExpenseTransactions().getByMonth(month).claimAmount)
|
|
5239
|
+
});
|
|
5240
|
+
});
|
|
5241
|
+
return chartData;
|
|
5367
5242
|
};
|
|
5368
5243
|
/**
|
|
5369
|
-
*
|
|
5370
|
-
* we should subtract GST amount from total price to get subtotal price
|
|
5244
|
+
* user pays GST only from allocated part (or paid) of income
|
|
5371
5245
|
*/
|
|
5372
|
-
|
|
5373
|
-
|
|
5246
|
+
TransactionCollection.prototype.calculateAllocatedClaimAmount = function (allocations) {
|
|
5247
|
+
var allocatedClaimAmount = 0;
|
|
5248
|
+
this.filterBy('isGST', true).toArray().forEach(function (transaction) {
|
|
5249
|
+
allocatedClaimAmount += transaction.getAllocatedClaimAmount(allocations);
|
|
5250
|
+
});
|
|
5251
|
+
return allocatedClaimAmount;
|
|
5374
5252
|
};
|
|
5375
|
-
|
|
5376
|
-
return
|
|
5253
|
+
TransactionCollection.prototype.calculateAllocatedGST = function (allocations) {
|
|
5254
|
+
return this.calculateAllocatedClaimAmount(allocations) * ChartAccounts.GSTRatio;
|
|
5377
5255
|
};
|
|
5378
|
-
|
|
5256
|
+
TransactionCollection.prototype.getAllocatedAmount = function (allocations) {
|
|
5257
|
+
return allocations.getByTransactionsIds(this.getIds()).sumBy('amount');
|
|
5258
|
+
};
|
|
5259
|
+
return TransactionCollection;
|
|
5260
|
+
}(ExportableCollection));
|
|
5261
|
+
|
|
5262
|
+
var TransactionAllocationCollection = /** @class */ (function (_super) {
|
|
5263
|
+
__extends(TransactionAllocationCollection, _super);
|
|
5264
|
+
function TransactionAllocationCollection() {
|
|
5265
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
5266
|
+
}
|
|
5267
|
+
Object.defineProperty(TransactionAllocationCollection.prototype, "amount", {
|
|
5379
5268
|
get: function () {
|
|
5380
|
-
return
|
|
5269
|
+
return this.sumBy('amount');
|
|
5381
5270
|
},
|
|
5382
5271
|
enumerable: false,
|
|
5383
5272
|
configurable: true
|
|
5384
5273
|
});
|
|
5385
|
-
|
|
5386
|
-
return new
|
|
5387
|
-
this.items.map(function (item) { return item.transaction.id; });
|
|
5274
|
+
TransactionAllocationCollection.prototype.getByTransactionsIds = function (ids) {
|
|
5275
|
+
return new TransactionAllocationCollection(this.items.filter(function (allocation) { return ids.includes(allocation.transaction.id); }));
|
|
5388
5276
|
};
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
SoleInvoice.NUMBER_LENGTH = 4;
|
|
5392
|
-
__decorate([
|
|
5393
|
-
classTransformer.Type(function () { return Date; })
|
|
5394
|
-
], SoleInvoice.prototype, "dateFrom", void 0);
|
|
5395
|
-
__decorate([
|
|
5396
|
-
classTransformer.Type(function () { return Date; })
|
|
5397
|
-
], SoleInvoice.prototype, "dateTo", void 0);
|
|
5398
|
-
__decorate([
|
|
5399
|
-
classTransformer.Type(function () { return User; })
|
|
5400
|
-
], SoleInvoice.prototype, "user", void 0);
|
|
5401
|
-
__decorate([
|
|
5402
|
-
classTransformer.Type(function () { return SoleBusiness; })
|
|
5403
|
-
], SoleInvoice.prototype, "business", void 0);
|
|
5404
|
-
__decorate([
|
|
5405
|
-
classTransformer.Type(function () { return SoleInvoiceItem; })
|
|
5406
|
-
], SoleInvoice.prototype, "items", void 0);
|
|
5407
|
-
__decorate([
|
|
5408
|
-
classTransformer.Type(function () { return SoleContact; })
|
|
5409
|
-
], SoleInvoice.prototype, "payer", void 0);
|
|
5410
|
-
__decorate([
|
|
5411
|
-
classTransformer.Type(function () { return SoleInvoiceTemplate; })
|
|
5412
|
-
], SoleInvoice.prototype, "template", void 0);
|
|
5413
|
-
__decorate([
|
|
5414
|
-
classTransformer.Type(function () { return BankAccount; })
|
|
5415
|
-
], SoleInvoice.prototype, "bankAccount", void 0);
|
|
5416
|
-
|
|
5417
|
-
/**
|
|
5418
|
-
* Class contains traveled kilometers and work usage percent in 12 weeks date range
|
|
5419
|
-
* @TODO Vik: Best period: move this and related logic to backend
|
|
5420
|
-
* @TODO Alex: check if we need this class when calculation refactored with backend
|
|
5421
|
-
*/
|
|
5422
|
-
var LogbookPeriod = /** @class */ (function () {
|
|
5423
|
-
function LogbookPeriod() {
|
|
5424
|
-
}
|
|
5425
|
-
LogbookPeriod.prototype.isEndOfYear = function () {
|
|
5426
|
-
return this.to === new FinancialYear().endDate;
|
|
5277
|
+
TransactionAllocationCollection.prototype.getByBankTransactionsIds = function (ids) {
|
|
5278
|
+
return new TransactionAllocationCollection(this.items.filter(function (allocation) { return ids.includes(allocation.bankTransaction.id); }));
|
|
5427
5279
|
};
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5280
|
+
/**
|
|
5281
|
+
* Group allocations by bank account via bank transactions collection
|
|
5282
|
+
*/
|
|
5283
|
+
TransactionAllocationCollection.prototype.groupByBankAccount = function (bankTransactions) {
|
|
5284
|
+
var _this = this;
|
|
5285
|
+
// Group bank transactions by bank account id
|
|
5286
|
+
var bankTransactionsByBankAccount = new CollectionDictionary(bankTransactions, 'bankAccount.id');
|
|
5287
|
+
// Create empty dictionary of transaction allocations
|
|
5288
|
+
var allocationsByBankAccount = new CollectionDictionary(new TransactionAllocationCollection([]));
|
|
5289
|
+
// Fill allocations dictionary with bank transactions dictionary keys and allocations related with each bank transaction collection
|
|
5290
|
+
bankTransactionsByBankAccount.keys.forEach(function (key) {
|
|
5291
|
+
allocationsByBankAccount.add(key, _this.getByBankTransactionsIds(bankTransactionsByBankAccount.get(key).getIds()));
|
|
5292
|
+
});
|
|
5293
|
+
return allocationsByBankAccount;
|
|
5431
5294
|
};
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5295
|
+
/**
|
|
5296
|
+
* check if collection includes allocation of passed transaction
|
|
5297
|
+
*/
|
|
5298
|
+
TransactionAllocationCollection.prototype.hasTransaction = function (transaction) {
|
|
5299
|
+
return !!this.items.find(function (allocation) { return allocation.transaction.id === transaction.id; });
|
|
5300
|
+
};
|
|
5301
|
+
/**
|
|
5302
|
+
* Check if bank transaction is related with current allocations
|
|
5303
|
+
*/
|
|
5304
|
+
TransactionAllocationCollection.prototype.hasBankTransaction = function (bankTransaction) {
|
|
5305
|
+
return !!this.items.find(function (allocation) { return allocation.bankTransaction.id === bankTransaction.id; });
|
|
5306
|
+
};
|
|
5307
|
+
return TransactionAllocationCollection;
|
|
5308
|
+
}(Collection));
|
|
5440
5309
|
|
|
5441
|
-
var
|
|
5442
|
-
__extends(
|
|
5443
|
-
function
|
|
5310
|
+
var Depreciation$1 = /** @class */ (function (_super) {
|
|
5311
|
+
__extends(Depreciation, _super);
|
|
5312
|
+
function Depreciation() {
|
|
5444
5313
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
5445
5314
|
}
|
|
5446
|
-
return
|
|
5315
|
+
return Depreciation;
|
|
5316
|
+
}(TransactionBase));
|
|
5317
|
+
|
|
5318
|
+
var DepreciationCapitalProject$1 = /** @class */ (function (_super) {
|
|
5319
|
+
__extends(DepreciationCapitalProject, _super);
|
|
5320
|
+
function DepreciationCapitalProject() {
|
|
5321
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
5322
|
+
}
|
|
5323
|
+
return DepreciationCapitalProject;
|
|
5447
5324
|
}(AbstractModel));
|
|
5448
5325
|
|
|
5449
|
-
var
|
|
5450
|
-
__extends(
|
|
5451
|
-
function
|
|
5326
|
+
var DepreciationCapitalProject = /** @class */ (function (_super) {
|
|
5327
|
+
__extends(DepreciationCapitalProject, _super);
|
|
5328
|
+
function DepreciationCapitalProject() {
|
|
5452
5329
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
5453
5330
|
}
|
|
5454
|
-
return
|
|
5331
|
+
return DepreciationCapitalProject;
|
|
5332
|
+
}(DepreciationCapitalProject$1));
|
|
5333
|
+
__decorate([
|
|
5334
|
+
classTransformer.Type(function () { return Date; })
|
|
5335
|
+
], DepreciationCapitalProject.prototype, "effectiveDate", void 0);
|
|
5336
|
+
|
|
5337
|
+
var DepreciationForecast$1 = /** @class */ (function (_super) {
|
|
5338
|
+
__extends(DepreciationForecast, _super);
|
|
5339
|
+
function DepreciationForecast() {
|
|
5340
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
5341
|
+
}
|
|
5342
|
+
return DepreciationForecast;
|
|
5455
5343
|
}(AbstractModel));
|
|
5456
5344
|
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
__extends(VehicleLogbook, _super);
|
|
5461
|
-
function VehicleLogbook() {
|
|
5345
|
+
var DepreciationForecast = /** @class */ (function (_super) {
|
|
5346
|
+
__extends(DepreciationForecast, _super);
|
|
5347
|
+
function DepreciationForecast() {
|
|
5462
5348
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
5463
5349
|
}
|
|
5464
|
-
Object.defineProperty(
|
|
5350
|
+
Object.defineProperty(DepreciationForecast.prototype, "dailyClaimAmount", {
|
|
5351
|
+
get: function () {
|
|
5352
|
+
return this.claimAmount / this.daysApplied;
|
|
5353
|
+
},
|
|
5354
|
+
enumerable: false,
|
|
5355
|
+
configurable: true
|
|
5356
|
+
});
|
|
5357
|
+
Object.defineProperty(DepreciationForecast.prototype, "daysApplied", {
|
|
5358
|
+
get: function () {
|
|
5359
|
+
return moment__namespace(this.toDate).diff(moment__namespace(this.fromDate), 'days');
|
|
5360
|
+
},
|
|
5361
|
+
enumerable: false,
|
|
5362
|
+
configurable: true
|
|
5363
|
+
});
|
|
5364
|
+
DepreciationForecast.prototype.getDaysByMonth = function (month) {
|
|
5365
|
+
// @TODO find a better place
|
|
5366
|
+
var year = this.financialYear - (month > 5 ? 1 : 0);
|
|
5367
|
+
// forecast date intersect by month
|
|
5368
|
+
var range = new momentRange.DateRange(this.fromDate, this.toDate).intersect(new momentRange.DateRange(new Date(year, month, 1), new Date(year, month + 1, 0)));
|
|
5369
|
+
return range ? range.duration('days') + 1 : 0;
|
|
5370
|
+
};
|
|
5371
|
+
Object.defineProperty(DepreciationForecast.prototype, "claimOpenBalance", {
|
|
5372
|
+
get: function () {
|
|
5373
|
+
return this.openBalance * this.claimRate;
|
|
5374
|
+
},
|
|
5375
|
+
enumerable: false,
|
|
5376
|
+
configurable: true
|
|
5377
|
+
});
|
|
5378
|
+
Object.defineProperty(DepreciationForecast.prototype, "claimCloseBalance", {
|
|
5465
5379
|
get: function () {
|
|
5466
|
-
return this.
|
|
5380
|
+
return this.closeBalance * this.claimRate;
|
|
5467
5381
|
},
|
|
5468
5382
|
enumerable: false,
|
|
5469
5383
|
configurable: true
|
|
5470
5384
|
});
|
|
5471
|
-
Object.defineProperty(
|
|
5385
|
+
Object.defineProperty(DepreciationForecast.prototype, "claimAmount", {
|
|
5472
5386
|
get: function () {
|
|
5473
|
-
return this.
|
|
5387
|
+
return this.amount * this.claimRate;
|
|
5474
5388
|
},
|
|
5475
5389
|
enumerable: false,
|
|
5476
5390
|
configurable: true
|
|
5477
5391
|
});
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
VehicleLogbook.prototype.getPeriod = function () {
|
|
5488
|
-
return moment.rangeFromInterval('milliseconds', VehicleLogbook.bestPeriodDuration, this.date);
|
|
5392
|
+
Object.defineProperty(DepreciationForecast.prototype, "claimRate", {
|
|
5393
|
+
get: function () {
|
|
5394
|
+
return this.claimPercent / 100;
|
|
5395
|
+
},
|
|
5396
|
+
enumerable: false,
|
|
5397
|
+
configurable: true
|
|
5398
|
+
});
|
|
5399
|
+
DepreciationForecast.prototype.getClaimAmountByMonth = function (month) {
|
|
5400
|
+
return this.getDaysByMonth(month) * this.dailyClaimAmount;
|
|
5489
5401
|
};
|
|
5490
|
-
return
|
|
5491
|
-
}(
|
|
5402
|
+
return DepreciationForecast;
|
|
5403
|
+
}(DepreciationForecast$1));
|
|
5404
|
+
|
|
5492
5405
|
/**
|
|
5493
|
-
*
|
|
5494
|
-
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/211517441/Logbook+Vehicle
|
|
5406
|
+
* Enum with income amount types (Net or Gross)
|
|
5495
5407
|
*/
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
classTransformer.Type(function () { return SoleBusiness; })
|
|
5502
|
-
], VehicleLogbook.prototype, "business", void 0);
|
|
5503
|
-
|
|
5504
|
-
var Vehicle = /** @class */ (function (_super) {
|
|
5505
|
-
__extends(Vehicle, _super);
|
|
5506
|
-
function Vehicle() {
|
|
5507
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
5508
|
-
}
|
|
5509
|
-
return Vehicle;
|
|
5510
|
-
}(Vehicle$1));
|
|
5511
|
-
__decorate([
|
|
5512
|
-
classTransformer.Type(function () { return VehicleLogbook; })
|
|
5513
|
-
], Vehicle.prototype, "logbook", void 0);
|
|
5514
|
-
|
|
5515
|
-
var VehicleClaim$1 = /** @class */ (function (_super) {
|
|
5516
|
-
__extends(VehicleClaim, _super);
|
|
5517
|
-
function VehicleClaim() {
|
|
5518
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
5519
|
-
}
|
|
5520
|
-
return VehicleClaim;
|
|
5521
|
-
}(AbstractModel));
|
|
5522
|
-
|
|
5523
|
-
var VehicleClaimDetails$1 = /** @class */ (function (_super) {
|
|
5524
|
-
__extends(VehicleClaimDetails, _super);
|
|
5525
|
-
function VehicleClaimDetails() {
|
|
5526
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
5527
|
-
}
|
|
5528
|
-
return VehicleClaimDetails;
|
|
5529
|
-
}(AbstractModel));
|
|
5408
|
+
exports.IncomeAmountTypeEnum = void 0;
|
|
5409
|
+
(function (IncomeAmountTypeEnum) {
|
|
5410
|
+
IncomeAmountTypeEnum[IncomeAmountTypeEnum["NET"] = 0] = "NET";
|
|
5411
|
+
IncomeAmountTypeEnum[IncomeAmountTypeEnum["GROSS"] = 1] = "GROSS";
|
|
5412
|
+
})(exports.IncomeAmountTypeEnum || (exports.IncomeAmountTypeEnum = {}));
|
|
5530
5413
|
|
|
5531
|
-
exports.
|
|
5532
|
-
(function (
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5414
|
+
exports.TransactionCategoryEnum = void 0;
|
|
5415
|
+
(function (TransactionCategoryEnum) {
|
|
5416
|
+
TransactionCategoryEnum[TransactionCategoryEnum["PROPERTY"] = 0] = "PROPERTY";
|
|
5417
|
+
TransactionCategoryEnum[TransactionCategoryEnum["WORK"] = 1] = "WORK";
|
|
5418
|
+
TransactionCategoryEnum[TransactionCategoryEnum["SOLE"] = 2] = "SOLE";
|
|
5419
|
+
TransactionCategoryEnum[TransactionCategoryEnum["PERSONAL"] = 3] = "PERSONAL";
|
|
5420
|
+
})(exports.TransactionCategoryEnum || (exports.TransactionCategoryEnum = {}));
|
|
5536
5421
|
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5422
|
+
/**
|
|
5423
|
+
* @TODO Alex: clarify grouping rules and refactor
|
|
5424
|
+
*/
|
|
5425
|
+
var Depreciation = /** @class */ (function (_super) {
|
|
5426
|
+
__extends(Depreciation, _super);
|
|
5427
|
+
function Depreciation() {
|
|
5540
5428
|
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
5429
|
+
_this.forecasts = [];
|
|
5430
|
+
_this.type = exports.DepreciationTypeEnum.PLANT_EQUIPMENT;
|
|
5541
5431
|
/**
|
|
5542
|
-
*
|
|
5432
|
+
* @TODO remove after ? signs removed from db models
|
|
5543
5433
|
*/
|
|
5544
|
-
_this.
|
|
5545
|
-
_this.method = exports.VehicleClaimDetailsMethodEnum.KMS;
|
|
5546
|
-
_this.financialYear = new FinancialYear().year;
|
|
5434
|
+
_this.amount = 0;
|
|
5547
5435
|
return _this;
|
|
5548
5436
|
}
|
|
5549
|
-
|
|
5550
|
-
|
|
5437
|
+
// Type checking
|
|
5438
|
+
Depreciation.prototype.isCapital = function () {
|
|
5439
|
+
return this.type === exports.DepreciationTypeEnum.CAPITAL_WORKS;
|
|
5551
5440
|
};
|
|
5552
|
-
|
|
5553
|
-
return this.
|
|
5441
|
+
Depreciation.prototype.isBorrowingExpense = function () {
|
|
5442
|
+
return this.type === exports.DepreciationTypeEnum.BORROWING_EXPENSES;
|
|
5554
5443
|
};
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
__decorate([
|
|
5558
|
-
classTransformer.Type(function () { return User; })
|
|
5559
|
-
], VehicleClaimDetails.prototype, "user", void 0);
|
|
5560
|
-
|
|
5561
|
-
var VehicleClaim = /** @class */ (function (_super) {
|
|
5562
|
-
__extends(VehicleClaim, _super);
|
|
5563
|
-
function VehicleClaim() {
|
|
5564
|
-
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
5565
|
-
_this.kilometers = 0;
|
|
5566
|
-
_this.workUsage = 0;
|
|
5567
|
-
return _this;
|
|
5568
|
-
}
|
|
5569
|
-
VehicleClaim.prototype.isWorkTank = function () {
|
|
5570
|
-
return !this.business;
|
|
5444
|
+
Depreciation.prototype.isAsset = function () {
|
|
5445
|
+
return this.type === exports.DepreciationTypeEnum.PLANT_EQUIPMENT;
|
|
5571
5446
|
};
|
|
5572
|
-
|
|
5573
|
-
|
|
5447
|
+
// Calculation checking
|
|
5448
|
+
Depreciation.prototype.isSBPCalculation = function () {
|
|
5449
|
+
return this.calculation === exports.DepreciationCalculationEnum.SBP;
|
|
5574
5450
|
};
|
|
5575
|
-
|
|
5451
|
+
Depreciation.prototype.isPrimeCost = function () {
|
|
5452
|
+
return this.calculation === exports.DepreciationCalculationEnum.PRIME_COST;
|
|
5453
|
+
};
|
|
5454
|
+
Depreciation.prototype.isDiminishing = function () {
|
|
5455
|
+
return this.calculation === exports.DepreciationCalculationEnum.DIMINISHING;
|
|
5456
|
+
};
|
|
5457
|
+
// Pool checking
|
|
5458
|
+
Depreciation.prototype.isPlantEquipmentPool = function () {
|
|
5459
|
+
return this.isAsset() && !this.isSBPCalculation() && !this.isWrittenOff() && !this.isLVP();
|
|
5460
|
+
};
|
|
5461
|
+
Depreciation.prototype.isLVP = function () {
|
|
5462
|
+
return this.isAsset()
|
|
5463
|
+
&& !this.isSBPCalculation()
|
|
5464
|
+
&& this.isDiminishing()
|
|
5465
|
+
&& this.currentYearForecast.closeBalance > Depreciation.WRITTEN_OFF_THRESHOLD
|
|
5466
|
+
&& this.currentYearForecast.closeBalance <= Depreciation.LOW_VALUE_POOL_THRESHOLD;
|
|
5467
|
+
};
|
|
5468
|
+
Depreciation.prototype.isSBP = function () {
|
|
5469
|
+
return this.isAsset() && this.isSBPCalculation() && !this.isWrittenOff();
|
|
5470
|
+
};
|
|
5471
|
+
Depreciation.prototype.isWrittenOff = function () {
|
|
5472
|
+
return this.writeOffYear === new FinancialYear().year;
|
|
5473
|
+
};
|
|
5474
|
+
Object.defineProperty(Depreciation.prototype, "writeOffYear", {
|
|
5576
5475
|
get: function () {
|
|
5577
|
-
|
|
5476
|
+
var _a;
|
|
5477
|
+
if (!this.writeOffManualDate && !this.writeOffDate) {
|
|
5478
|
+
return null;
|
|
5479
|
+
}
|
|
5480
|
+
return (_a = new FinancialYear(this.writeOffManualDate || this.writeOffDate)) === null || _a === void 0 ? void 0 : _a.year;
|
|
5578
5481
|
},
|
|
5579
5482
|
enumerable: false,
|
|
5580
5483
|
configurable: true
|
|
5581
5484
|
});
|
|
5582
5485
|
/**
|
|
5583
|
-
*
|
|
5486
|
+
* Check if depreciation chart accounts heading related to vehicles category
|
|
5584
5487
|
*/
|
|
5585
|
-
|
|
5586
|
-
|
|
5488
|
+
Depreciation.prototype.isVehicleDepreciation = function () {
|
|
5489
|
+
var _a;
|
|
5490
|
+
return ((_a = this.chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id) === exports.ChartAccountsHeadingVehicleListEnum.DEPRECIATION_VEHICLES;
|
|
5587
5491
|
};
|
|
5588
5492
|
/**
|
|
5589
|
-
* Get
|
|
5590
|
-
|
|
5493
|
+
* Get depreciation purchase date
|
|
5494
|
+
*/
|
|
5495
|
+
Depreciation.prototype.getDate = function () {
|
|
5496
|
+
return this.date;
|
|
5497
|
+
};
|
|
5498
|
+
Object.defineProperty(Depreciation.prototype, "currentYearForecast", {
|
|
5499
|
+
/**
|
|
5500
|
+
* @TODO Vik: Research a problem with depreciations without current year forecast
|
|
5501
|
+
*/
|
|
5502
|
+
get: function () {
|
|
5503
|
+
return this.forecasts.find(function (forecast) {
|
|
5504
|
+
return forecast.financialYear === new FinancialYear().year;
|
|
5505
|
+
}) || classTransformer.plainToClass(DepreciationForecast, {
|
|
5506
|
+
financialYear: new FinancialYear().year,
|
|
5507
|
+
openBalance: 0,
|
|
5508
|
+
closeBalance: 0,
|
|
5509
|
+
amount: 0,
|
|
5510
|
+
claimPercent: 0
|
|
5511
|
+
});
|
|
5512
|
+
},
|
|
5513
|
+
enumerable: false,
|
|
5514
|
+
configurable: true
|
|
5515
|
+
});
|
|
5516
|
+
Depreciation.prototype.getForecastByYear = function (year) {
|
|
5517
|
+
return this.forecasts.find(function (forecast) {
|
|
5518
|
+
return forecast.financialYear === year;
|
|
5519
|
+
});
|
|
5520
|
+
};
|
|
5521
|
+
Depreciation.prototype.getClaimAmountByYear = function (year) {
|
|
5522
|
+
var _a;
|
|
5523
|
+
return ((_a = this.getForecastByYear(year)) === null || _a === void 0 ? void 0 : _a.claimAmount) || 0;
|
|
5524
|
+
};
|
|
5525
|
+
Depreciation.prototype.getCloseBalanceByYear = function (year) {
|
|
5526
|
+
var _a;
|
|
5527
|
+
return ((_a = this.getForecastByYear(year)) === null || _a === void 0 ? void 0 : _a.closeBalance) || 0;
|
|
5528
|
+
};
|
|
5529
|
+
Depreciation.prototype.isBuildingAtCost = function () {
|
|
5530
|
+
return this.chartAccounts.id === exports.ChartAccountsListEnum.BUILDING_AT_COST;
|
|
5531
|
+
};
|
|
5532
|
+
/**
|
|
5533
|
+
* Create a new transaction from current depreciation
|
|
5534
|
+
*/
|
|
5535
|
+
Depreciation.prototype.toTransaction = function (params) {
|
|
5536
|
+
if (params === void 0) { params = {}; }
|
|
5537
|
+
var _a, _b;
|
|
5538
|
+
return classTransformer.plainToClass(Transaction, Object.assign(params, this, {
|
|
5539
|
+
amount: -((_a = this.currentYearForecast) === null || _a === void 0 ? void 0 : _a.amount) || 0,
|
|
5540
|
+
claimAmount: -((_b = this.currentYearForecast) === null || _b === void 0 ? void 0 : _b.claimAmount) || 0,
|
|
5541
|
+
}));
|
|
5542
|
+
};
|
|
5543
|
+
Object.defineProperty(Depreciation.prototype, "claimAmount", {
|
|
5544
|
+
/**
|
|
5545
|
+
* @TODO Michael: remove and check everywhere in reports
|
|
5546
|
+
*/
|
|
5547
|
+
get: function () {
|
|
5548
|
+
var _a;
|
|
5549
|
+
return ((_a = this.currentYearForecast) === null || _a === void 0 ? void 0 : _a.claimAmount) || 0;
|
|
5550
|
+
},
|
|
5551
|
+
enumerable: false,
|
|
5552
|
+
configurable: true
|
|
5553
|
+
});
|
|
5554
|
+
Object.defineProperty(Depreciation.prototype, "amountWithGst", {
|
|
5555
|
+
get: function () {
|
|
5556
|
+
// gst applies only to new assets
|
|
5557
|
+
if (this.isNew()) {
|
|
5558
|
+
return _super.prototype.amountWithGst;
|
|
5559
|
+
}
|
|
5560
|
+
return this.amount;
|
|
5561
|
+
},
|
|
5562
|
+
enumerable: false,
|
|
5563
|
+
configurable: true
|
|
5564
|
+
});
|
|
5565
|
+
Object.defineProperty(Depreciation.prototype, "gstClaimAmount", {
|
|
5566
|
+
get: function () {
|
|
5567
|
+
var _a;
|
|
5568
|
+
return this.gstAmount * ((_a = this.currentYearForecast) === null || _a === void 0 ? void 0 : _a.claimRate);
|
|
5569
|
+
},
|
|
5570
|
+
enumerable: false,
|
|
5571
|
+
configurable: true
|
|
5572
|
+
});
|
|
5573
|
+
/**
|
|
5574
|
+
* assets purchased in the current financial year
|
|
5591
5575
|
*/
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
.getByVehicleClaim(this)
|
|
5595
|
-
.getLogbookTransactions()
|
|
5596
|
-
.sumBy('amount');
|
|
5597
|
-
// Math.abs because amount will be negative (because we sum expenses), but we don't want negative percent value
|
|
5598
|
-
return Math.abs(transactionsAmount) * this.workUsage / 100;
|
|
5599
|
-
};
|
|
5600
|
-
VehicleClaim.prototype.getAverageWeeklyKMS = function () {
|
|
5601
|
-
return this.kilometers / FinancialYear.weeksInYear;
|
|
5602
|
-
};
|
|
5603
|
-
VehicleClaim.getKMSChartAccountsIdByTankType = function (tankType) {
|
|
5604
|
-
return tankType === exports.TankTypeEnum.WORK
|
|
5605
|
-
? exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK
|
|
5606
|
-
: exports.ChartAccountsListEnum.KLMS_TRAVELLED;
|
|
5576
|
+
Depreciation.prototype.isNew = function () {
|
|
5577
|
+
return new FinancialYear(this.date).year === new FinancialYear().year;
|
|
5607
5578
|
};
|
|
5608
|
-
return
|
|
5609
|
-
}(
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
*/
|
|
5613
|
-
VehicleClaim.totalKmsLimit = 5000;
|
|
5614
|
-
/**
|
|
5615
|
-
* limit for work usage claim method
|
|
5616
|
-
*/
|
|
5617
|
-
VehicleClaim.totalWorkUsagePercent = 100;
|
|
5618
|
-
__decorate([
|
|
5619
|
-
classTransformer.Type(function () { return VehicleClaimDetails; })
|
|
5620
|
-
], VehicleClaim.prototype, "details", void 0);
|
|
5579
|
+
return Depreciation;
|
|
5580
|
+
}(Depreciation$1));
|
|
5581
|
+
Depreciation.WRITTEN_OFF_THRESHOLD = 300;
|
|
5582
|
+
Depreciation.LOW_VALUE_POOL_THRESHOLD = 1000;
|
|
5621
5583
|
__decorate([
|
|
5622
|
-
classTransformer.Type(function () { return
|
|
5623
|
-
],
|
|
5624
|
-
|
|
5625
|
-
var SoleBusinessActivity$1 = /** @class */ (function (_super) {
|
|
5626
|
-
__extends(SoleBusinessActivity, _super);
|
|
5627
|
-
function SoleBusinessActivity() {
|
|
5628
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
5629
|
-
}
|
|
5630
|
-
return SoleBusinessActivity;
|
|
5631
|
-
}(AbstractModel));
|
|
5632
|
-
|
|
5633
|
-
var SoleBusiness = /** @class */ (function (_super) {
|
|
5634
|
-
__extends(SoleBusiness, _super);
|
|
5635
|
-
function SoleBusiness() {
|
|
5636
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
5637
|
-
}
|
|
5638
|
-
SoleBusiness.prototype.getPhotoPlaceholder = function () {
|
|
5639
|
-
return "" + this.name[0] + this.name[1];
|
|
5640
|
-
};
|
|
5641
|
-
SoleBusiness.prototype.getPhoto = function () {
|
|
5642
|
-
return this.logo;
|
|
5643
|
-
};
|
|
5644
|
-
return SoleBusiness;
|
|
5645
|
-
}(SoleBusiness$1));
|
|
5646
|
-
/**
|
|
5647
|
-
* Maximum number of businesses that a person can have, according to the ATO
|
|
5648
|
-
*/
|
|
5649
|
-
SoleBusiness.businessesLimit = 6;
|
|
5584
|
+
classTransformer.Type(function () { return Date; })
|
|
5585
|
+
], Depreciation.prototype, "purchaseDate", void 0);
|
|
5650
5586
|
__decorate([
|
|
5651
|
-
classTransformer.Type(function () { return
|
|
5652
|
-
],
|
|
5587
|
+
classTransformer.Type(function () { return Date; })
|
|
5588
|
+
], Depreciation.prototype, "date", void 0);
|
|
5653
5589
|
__decorate([
|
|
5654
|
-
classTransformer.Type(function () { return
|
|
5655
|
-
],
|
|
5590
|
+
classTransformer.Type(function () { return Date; })
|
|
5591
|
+
], Depreciation.prototype, "lowValuePoolDate", void 0);
|
|
5656
5592
|
__decorate([
|
|
5657
|
-
classTransformer.Type(function () { return
|
|
5658
|
-
],
|
|
5593
|
+
classTransformer.Type(function () { return Date; })
|
|
5594
|
+
], Depreciation.prototype, "writeOffManualDate", void 0);
|
|
5659
5595
|
__decorate([
|
|
5660
|
-
classTransformer.Type(function () { return
|
|
5661
|
-
],
|
|
5596
|
+
classTransformer.Type(function () { return Date; })
|
|
5597
|
+
], Depreciation.prototype, "writeOffDate", void 0);
|
|
5662
5598
|
__decorate([
|
|
5663
|
-
classTransformer.Type(function () { return
|
|
5664
|
-
],
|
|
5599
|
+
classTransformer.Type(function () { return DepreciationCapitalProject; })
|
|
5600
|
+
], Depreciation.prototype, "depreciationCapitalProject", void 0);
|
|
5665
5601
|
__decorate([
|
|
5666
|
-
classTransformer.Type(function () { return
|
|
5667
|
-
|
|
5602
|
+
classTransformer.Type(function () { return DepreciationForecast; }),
|
|
5603
|
+
classTransformer.Transform(function (_c) {
|
|
5604
|
+
var value = _c.value, obj = _c.obj;
|
|
5605
|
+
// value = array of DepreciationForecast
|
|
5606
|
+
// obj = plain (whole Depreciation object)
|
|
5607
|
+
// Set isLVP flag for each DepreciationForecast
|
|
5608
|
+
// @TODO refactor
|
|
5609
|
+
value.forEach(function (forecast) {
|
|
5610
|
+
forecast.isLVP =
|
|
5611
|
+
forecast.closeBalance < 1000 &&
|
|
5612
|
+
obj.calculation === exports.DepreciationCalculationEnum.DIMINISHING &&
|
|
5613
|
+
obj.type === exports.DepreciationTypeEnum.PLANT_EQUIPMENT &&
|
|
5614
|
+
!(obj.amount > Depreciation.WRITTEN_OFF_THRESHOLD && obj.amount < Depreciation.LOW_VALUE_POOL_THRESHOLD) &&
|
|
5615
|
+
!(obj.writeOffDate && new FinancialYear(new Date(obj.writeOffDate)).year === obj.financialYear);
|
|
5616
|
+
});
|
|
5617
|
+
return value;
|
|
5618
|
+
})
|
|
5619
|
+
], Depreciation.prototype, "forecasts", void 0);
|
|
5668
5620
|
__decorate([
|
|
5669
|
-
classTransformer.Type(function () { return
|
|
5670
|
-
],
|
|
5621
|
+
classTransformer.Type(function () { return ChartAccounts; })
|
|
5622
|
+
], Depreciation.prototype, "chartAccounts", void 0);
|
|
5671
5623
|
__decorate([
|
|
5672
|
-
classTransformer.Type(function () { return
|
|
5673
|
-
],
|
|
5624
|
+
classTransformer.Type(function () { return BankTransaction; })
|
|
5625
|
+
], Depreciation.prototype, "bankTransaction", void 0);
|
|
5674
5626
|
__decorate([
|
|
5675
|
-
classTransformer.
|
|
5676
|
-
],
|
|
5627
|
+
classTransformer.Exclude()
|
|
5628
|
+
], Depreciation.prototype, "amountWithGst", null);
|
|
5677
5629
|
__decorate([
|
|
5678
|
-
classTransformer.
|
|
5679
|
-
],
|
|
5680
|
-
|
|
5681
|
-
var SoleBusinessActivity = /** @class */ (function (_super) {
|
|
5682
|
-
__extends(SoleBusinessActivity, _super);
|
|
5683
|
-
function SoleBusinessActivity() {
|
|
5684
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
5685
|
-
}
|
|
5686
|
-
return SoleBusinessActivity;
|
|
5687
|
-
}(SoleBusinessActivity$1));
|
|
5688
|
-
|
|
5689
|
-
var SoleDepreciationMethod$1 = /** @class */ (function (_super) {
|
|
5690
|
-
__extends(SoleDepreciationMethod, _super);
|
|
5691
|
-
function SoleDepreciationMethod() {
|
|
5692
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
5693
|
-
}
|
|
5694
|
-
return SoleDepreciationMethod;
|
|
5695
|
-
}(AbstractModel));
|
|
5696
|
-
|
|
5697
|
-
exports.SoleDepreciationMethodEnum = void 0;
|
|
5698
|
-
(function (SoleDepreciationMethodEnum) {
|
|
5699
|
-
SoleDepreciationMethodEnum[SoleDepreciationMethodEnum["SBP"] = 1] = "SBP";
|
|
5700
|
-
SoleDepreciationMethodEnum[SoleDepreciationMethodEnum["DEPRECIATION"] = 2] = "DEPRECIATION";
|
|
5701
|
-
})(exports.SoleDepreciationMethodEnum || (exports.SoleDepreciationMethodEnum = {}));
|
|
5630
|
+
classTransformer.Exclude()
|
|
5631
|
+
], Depreciation.prototype, "gstClaimAmount", null);
|
|
5702
5632
|
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5633
|
+
/**
|
|
5634
|
+
* used to combine transactions/depreciations
|
|
5635
|
+
*/
|
|
5636
|
+
var TransactionBaseCollection = /** @class */ (function (_super) {
|
|
5637
|
+
__extends(TransactionBaseCollection, _super);
|
|
5638
|
+
function TransactionBaseCollection() {
|
|
5706
5639
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
5707
5640
|
}
|
|
5708
|
-
|
|
5709
|
-
return this.
|
|
5641
|
+
TransactionBaseCollection.prototype.getClaimAmountByBusinessId = function (businessId) {
|
|
5642
|
+
return +this.filterBy('business.id', businessId).items.map(function (transaction) { return transaction instanceof Depreciation ? -transaction.claimAmount : transaction['claimAmount']; }).reduce(function (sum, claimAmount) { return sum + claimAmount; }, 0).toFixed(2);
|
|
5710
5643
|
};
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
function SoleDetails() {
|
|
5717
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
5718
|
-
}
|
|
5719
|
-
return SoleDetails;
|
|
5720
|
-
}(AbstractModel));
|
|
5721
|
-
|
|
5722
|
-
var SoleDetails = /** @class */ (function (_super) {
|
|
5723
|
-
__extends(SoleDetails, _super);
|
|
5724
|
-
function SoleDetails() {
|
|
5725
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
5726
|
-
}
|
|
5727
|
-
return SoleDetails;
|
|
5728
|
-
}(SoleDetails$1));
|
|
5729
|
-
__decorate([
|
|
5730
|
-
classTransformer.Type(function () { return User; })
|
|
5731
|
-
], SoleDetails.prototype, "user", void 0);
|
|
5644
|
+
TransactionBaseCollection.prototype.getSoleTransactions = function () {
|
|
5645
|
+
return this.filter(function (transaction) { return transaction.isSoleTank(); });
|
|
5646
|
+
};
|
|
5647
|
+
return TransactionBaseCollection;
|
|
5648
|
+
}(Collection));
|
|
5732
5649
|
|
|
5733
|
-
|
|
5734
|
-
__extends(BasReport, _super);
|
|
5735
|
-
function BasReport() {
|
|
5736
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
5737
|
-
}
|
|
5738
|
-
return BasReport;
|
|
5739
|
-
}(AbstractModel));
|
|
5650
|
+
// @TODO Alex move here all collections
|
|
5740
5651
|
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5652
|
+
// @TODO Alex: refactor: move here allocations methods, netAmount = amount, grossAmount calculation, remove unused methods, etc.
|
|
5653
|
+
var Transaction = /** @class */ (function (_super) {
|
|
5654
|
+
__extends(Transaction, _super);
|
|
5655
|
+
function Transaction() {
|
|
5656
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
5657
|
+
// list of child transactions (fees)
|
|
5658
|
+
_this.transactions = [];
|
|
5659
|
+
_this.metadata = [];
|
|
5660
|
+
_this.allocations = [];
|
|
5661
|
+
_this.tax = 0;
|
|
5662
|
+
_this.operation = exports.TransactionOperationEnum.FIND_AND_MATCH;
|
|
5663
|
+
_this.claimPercent = 100;
|
|
5664
|
+
_this.amount = 0;
|
|
5665
|
+
return _this;
|
|
5745
5666
|
}
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5667
|
+
Transaction.prototype.isDebit = function () {
|
|
5668
|
+
return this.type === exports.TransactionTypeEnum.DEBIT;
|
|
5669
|
+
};
|
|
5670
|
+
Transaction.prototype.isCredit = function () {
|
|
5671
|
+
return this.type === exports.TransactionTypeEnum.CREDIT;
|
|
5672
|
+
};
|
|
5673
|
+
/**
|
|
5674
|
+
* @TODO move to base collection
|
|
5675
|
+
*/
|
|
5676
|
+
Transaction.prototype.isIncome = function () {
|
|
5677
|
+
// @TODO not used
|
|
5678
|
+
if (!this.chartAccounts) {
|
|
5679
|
+
return this.isCredit();
|
|
5680
|
+
}
|
|
5681
|
+
return CHART_ACCOUNTS_CATEGORIES.income.includes(this.chartAccounts.category);
|
|
5682
|
+
};
|
|
5683
|
+
/**
|
|
5684
|
+
* @TODO move to base collection
|
|
5685
|
+
*/
|
|
5686
|
+
Transaction.prototype.isExpense = function () {
|
|
5687
|
+
// @TODO not used
|
|
5688
|
+
if (!this.chartAccounts) {
|
|
5689
|
+
return this.isDebit();
|
|
5690
|
+
}
|
|
5691
|
+
return CHART_ACCOUNTS_CATEGORIES.expense.includes(this.chartAccounts.category);
|
|
5692
|
+
};
|
|
5693
|
+
Transaction.prototype.isPersonal = function () {
|
|
5694
|
+
return CHART_ACCOUNTS_CATEGORIES.personal.includes(this.chartAccounts.category);
|
|
5695
|
+
};
|
|
5696
|
+
Transaction.prototype.isInterest = function () {
|
|
5697
|
+
return this.chartAccounts.id === exports.ChartAccountsListEnum.INTEREST_ON_LOAN;
|
|
5698
|
+
};
|
|
5699
|
+
Object.defineProperty(Transaction.prototype, "chartAccountsCategories", {
|
|
5754
5700
|
get: function () {
|
|
5755
|
-
|
|
5701
|
+
switch (true) {
|
|
5702
|
+
case this.isPersonal():
|
|
5703
|
+
return CHART_ACCOUNTS_CATEGORIES.personal;
|
|
5704
|
+
case this.isPropertyTank():
|
|
5705
|
+
return CHART_ACCOUNTS_CATEGORIES.property;
|
|
5706
|
+
case this.isSoleTank():
|
|
5707
|
+
return CHART_ACCOUNTS_CATEGORIES.sole;
|
|
5708
|
+
default:
|
|
5709
|
+
return CHART_ACCOUNTS_CATEGORIES.work;
|
|
5710
|
+
}
|
|
5756
5711
|
},
|
|
5757
5712
|
enumerable: false,
|
|
5758
5713
|
configurable: true
|
|
5759
5714
|
});
|
|
5760
|
-
Object.defineProperty(
|
|
5715
|
+
Object.defineProperty(Transaction.prototype, "isKmsChartAccountsCategory", {
|
|
5716
|
+
/**
|
|
5717
|
+
* Check if transaction has 'Kms travelled for work' chart accounts category
|
|
5718
|
+
*/
|
|
5761
5719
|
get: function () {
|
|
5762
|
-
return this.
|
|
5720
|
+
return this.chartAccounts.id === exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK;
|
|
5763
5721
|
},
|
|
5764
5722
|
enumerable: false,
|
|
5765
5723
|
configurable: true
|
|
5766
5724
|
});
|
|
5767
|
-
|
|
5725
|
+
/**
|
|
5726
|
+
* Get transaction date
|
|
5727
|
+
*/
|
|
5728
|
+
Transaction.prototype.getDate = function () {
|
|
5729
|
+
return this.date;
|
|
5730
|
+
};
|
|
5731
|
+
/**
|
|
5732
|
+
* Check if transaction type is vehicle
|
|
5733
|
+
*/
|
|
5734
|
+
Transaction.prototype.isVehicleTransaction = function () {
|
|
5735
|
+
return this.chartAccounts.isVehicleExpense();
|
|
5736
|
+
};
|
|
5737
|
+
Object.defineProperty(Transaction.prototype, "taxFreeComponent", {
|
|
5768
5738
|
get: function () {
|
|
5769
|
-
return this.
|
|
5739
|
+
return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.TAX_FREE_COMPONENT);
|
|
5770
5740
|
},
|
|
5771
5741
|
enumerable: false,
|
|
5772
5742
|
configurable: true
|
|
5773
5743
|
});
|
|
5774
|
-
Object.defineProperty(
|
|
5744
|
+
Object.defineProperty(Transaction.prototype, "frankingCredit", {
|
|
5775
5745
|
get: function () {
|
|
5776
|
-
return this.
|
|
5746
|
+
return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.FRANKING_CREDIT);
|
|
5777
5747
|
},
|
|
5778
5748
|
enumerable: false,
|
|
5779
5749
|
configurable: true
|
|
5780
5750
|
});
|
|
5781
|
-
Object.defineProperty(
|
|
5751
|
+
Object.defineProperty(Transaction.prototype, "eligibleForReduction", {
|
|
5782
5752
|
get: function () {
|
|
5783
|
-
return this.
|
|
5753
|
+
return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.ELIGIBLE_FOR_REDUCTION);
|
|
5784
5754
|
},
|
|
5785
5755
|
enumerable: false,
|
|
5786
5756
|
configurable: true
|
|
5787
5757
|
});
|
|
5788
|
-
Object.defineProperty(
|
|
5758
|
+
Object.defineProperty(Transaction.prototype, "untaxedElement", {
|
|
5789
5759
|
get: function () {
|
|
5790
|
-
return this.
|
|
5760
|
+
return this.getMetadataFieldValue(exports.ChartAccountsMetadataListEnum.UNTAXED_ELEMENT);
|
|
5791
5761
|
},
|
|
5792
5762
|
enumerable: false,
|
|
5793
5763
|
configurable: true
|
|
5794
5764
|
});
|
|
5795
|
-
Object.defineProperty(
|
|
5765
|
+
Object.defineProperty(Transaction.prototype, "isTransfer", {
|
|
5796
5766
|
/**
|
|
5797
|
-
*
|
|
5767
|
+
* Check if transaction reconcile operation if TRANSFER
|
|
5768
|
+
* @TODO bad usage of get (and all is* methods), getter should sound like a noun
|
|
5798
5769
|
*/
|
|
5799
5770
|
get: function () {
|
|
5800
|
-
return this.
|
|
5801
|
-
},
|
|
5802
|
-
enumerable: false,
|
|
5803
|
-
configurable: true
|
|
5804
|
-
});
|
|
5805
|
-
return BasReport;
|
|
5806
|
-
}(BasReport$1));
|
|
5807
|
-
__decorate([
|
|
5808
|
-
classTransformer.Type(function () { return Date; })
|
|
5809
|
-
], BasReport.prototype, "dateFrom", void 0);
|
|
5810
|
-
__decorate([
|
|
5811
|
-
classTransformer.Type(function () { return Date; })
|
|
5812
|
-
], BasReport.prototype, "dateTo", void 0);
|
|
5813
|
-
|
|
5814
|
-
/**
|
|
5815
|
-
* role hierarchy
|
|
5816
|
-
*/
|
|
5817
|
-
var USER_ROLES = {
|
|
5818
|
-
ROLE_FIRM_OWNER: [exports.UserRolesEnum.FIRM_OWNER, exports.UserRolesEnum.FIRM_MANAGER, exports.UserRolesEnum.ACCOUNTANT, exports.UserRolesEnum.ADVISOR],
|
|
5819
|
-
ROLE_FIRM_MANAGER: [exports.UserRolesEnum.FIRM_MANAGER, exports.UserRolesEnum.ACCOUNTANT, exports.UserRolesEnum.ADVISOR],
|
|
5820
|
-
ROLE_EMPLOYEE: [exports.UserRolesEnum.ACCOUNTANT, exports.UserRolesEnum.ADVISOR],
|
|
5821
|
-
ROLE_ACCOUNTANT: [exports.UserRolesEnum.ACCOUNTANT],
|
|
5822
|
-
ROLE_ADVISOR: [exports.UserRolesEnum.ADVISOR],
|
|
5823
|
-
ROLE_CLIENT: [exports.UserRolesEnum.CLIENT],
|
|
5824
|
-
ROLE_USER_SUBSCRIPTION: [exports.UserRolesEnum.SUBSCRIPTION],
|
|
5825
|
-
ROLE_USER_WORK: [exports.UserRolesEnum.WORK_TANK],
|
|
5826
|
-
ROLE_USER_PROPERTY: [exports.UserRolesEnum.PROPERTY_TANK],
|
|
5827
|
-
ROLE_USER_SOLE: [exports.UserRolesEnum.SOLE_TANK],
|
|
5828
|
-
};
|
|
5829
|
-
|
|
5830
|
-
var User = /** @class */ (function (_super) {
|
|
5831
|
-
__extends(User, _super);
|
|
5832
|
-
function User() {
|
|
5833
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
5834
|
-
}
|
|
5835
|
-
Object.defineProperty(User.prototype, "fullName", {
|
|
5836
|
-
get: function () {
|
|
5837
|
-
return this.firstName + " " + this.lastName;
|
|
5838
|
-
},
|
|
5839
|
-
enumerable: false,
|
|
5840
|
-
configurable: true
|
|
5841
|
-
});
|
|
5842
|
-
Object.defineProperty(User.prototype, "activeSubscription", {
|
|
5843
|
-
get: function () {
|
|
5844
|
-
return this.subscriptions.find(function (ss) { return ss.isActive; });
|
|
5771
|
+
return this.operation === exports.TransactionOperationEnum.TRANSFER;
|
|
5845
5772
|
},
|
|
5846
5773
|
enumerable: false,
|
|
5847
5774
|
configurable: true
|
|
5848
5775
|
});
|
|
5849
|
-
|
|
5776
|
+
Transaction.prototype.isFindAndMatch = function () {
|
|
5777
|
+
return this.operation === exports.TransactionOperationEnum.FIND_AND_MATCH;
|
|
5778
|
+
};
|
|
5779
|
+
Transaction.prototype.isMatchInvoice = function () {
|
|
5780
|
+
return this.operation === exports.TransactionOperationEnum.MATCH_INVOICE;
|
|
5781
|
+
};
|
|
5782
|
+
Object.defineProperty(Transaction.prototype, "debit", {
|
|
5850
5783
|
get: function () {
|
|
5851
|
-
return this.
|
|
5784
|
+
return this.isDebit() ? Math.abs(this.grossAmount) : 0;
|
|
5852
5785
|
},
|
|
5853
5786
|
enumerable: false,
|
|
5854
5787
|
configurable: true
|
|
5855
5788
|
});
|
|
5856
|
-
Object.defineProperty(
|
|
5857
|
-
/**
|
|
5858
|
-
* @TODO refactor
|
|
5859
|
-
*
|
|
5860
|
-
*/
|
|
5789
|
+
Object.defineProperty(Transaction.prototype, "credit", {
|
|
5861
5790
|
get: function () {
|
|
5862
|
-
|
|
5863
|
-
case this.isFirmOwner():
|
|
5864
|
-
return USER_WORK_POSITION[exports.UserRolesEnum.FIRM_OWNER];
|
|
5865
|
-
case this.isManager():
|
|
5866
|
-
return USER_WORK_POSITION[exports.UserRolesEnum.FIRM_MANAGER];
|
|
5867
|
-
case this.isEmployee():
|
|
5868
|
-
return USER_WORK_POSITION[exports.UserRolesEnum.EMPLOYEE];
|
|
5869
|
-
default:
|
|
5870
|
-
return '';
|
|
5871
|
-
}
|
|
5791
|
+
return this.isCredit() ? Math.abs(this.grossAmount) : 0;
|
|
5872
5792
|
},
|
|
5873
5793
|
enumerable: false,
|
|
5874
5794
|
configurable: true
|
|
5875
5795
|
});
|
|
5876
5796
|
/**
|
|
5877
|
-
*
|
|
5797
|
+
* Get value of transaction metadata field
|
|
5798
|
+
* @param field for which value should be returned
|
|
5799
|
+
* @Todo modify 'metadata' property from array to Collection
|
|
5878
5800
|
*/
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
return
|
|
5883
|
-
}
|
|
5884
|
-
roles = flatten__default["default"](roles.map(function (role) { return USER_ROLES[role]; }));
|
|
5885
|
-
return !!intersection__default["default"](this.roles, roles).length;
|
|
5886
|
-
};
|
|
5887
|
-
User.prototype.isOnboarding = function () {
|
|
5888
|
-
return this.status === exports.UserStatusEnum.ON_BOARDING;
|
|
5889
|
-
};
|
|
5890
|
-
User.prototype.hasSubscription = function () {
|
|
5891
|
-
return this.roles.includes(exports.UserRolesEnum.SUBSCRIPTION);
|
|
5892
|
-
};
|
|
5893
|
-
User.prototype.isLoggedIn = function () {
|
|
5894
|
-
return this.id === +localStorage.getItem('userId');
|
|
5895
|
-
};
|
|
5896
|
-
User.prototype.isClient = function () {
|
|
5897
|
-
return this.roles.includes(exports.UserRolesEnum.CLIENT);
|
|
5898
|
-
};
|
|
5899
|
-
User.prototype.isEmployee = function () {
|
|
5900
|
-
return this.isAccountant() || this.isAdvisor();
|
|
5901
|
-
};
|
|
5902
|
-
User.prototype.isAccountant = function () {
|
|
5903
|
-
return this.roles.includes(exports.UserRolesEnum.ACCOUNTANT);
|
|
5904
|
-
};
|
|
5905
|
-
User.prototype.isAdvisor = function () {
|
|
5906
|
-
return this.roles.includes(exports.UserRolesEnum.ADVISOR);
|
|
5801
|
+
Transaction.prototype.getMetadataFieldValue = function (field) {
|
|
5802
|
+
var _a;
|
|
5803
|
+
return +((_a = this.metadata.find(function (transactionMetadata) {
|
|
5804
|
+
return transactionMetadata.chartAccountsMetadata.id === field;
|
|
5805
|
+
})) === null || _a === void 0 ? void 0 : _a.value) || 0;
|
|
5907
5806
|
};
|
|
5908
|
-
|
|
5909
|
-
return this.
|
|
5807
|
+
Transaction.prototype.isCash = function () {
|
|
5808
|
+
return this.source === exports.TransactionSourceEnum.CASH;
|
|
5910
5809
|
};
|
|
5911
5810
|
/**
|
|
5912
|
-
*
|
|
5811
|
+
* Create Depreciation instance based on Transaction
|
|
5913
5812
|
*/
|
|
5914
|
-
|
|
5915
|
-
return
|
|
5813
|
+
Transaction.prototype.toDepreciation = function () {
|
|
5814
|
+
return classTransformer.plainToClass(Depreciation, {
|
|
5815
|
+
date: this.date,
|
|
5816
|
+
amount: this.amount,
|
|
5817
|
+
chartAccounts: this.chartAccounts,
|
|
5818
|
+
description: this.description,
|
|
5819
|
+
type: exports.DepreciationTypeEnum.PLANT_EQUIPMENT,
|
|
5820
|
+
claimPercent: this.claimPercent,
|
|
5821
|
+
property: this.property,
|
|
5822
|
+
calculation: this.property ? this.property.depreciationCalculation : exports.DepreciationCalculationEnum.PRIME_COST
|
|
5823
|
+
});
|
|
5916
5824
|
};
|
|
5917
5825
|
/**
|
|
5918
|
-
* Check if
|
|
5826
|
+
* Check if transaction is completely allocated
|
|
5919
5827
|
*/
|
|
5920
|
-
|
|
5921
|
-
return this.
|
|
5828
|
+
Transaction.prototype.isAllocated = function (allocations) {
|
|
5829
|
+
return this.grossAmount === this.getAllocatedAmount(allocations);
|
|
5922
5830
|
};
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
*/
|
|
5926
|
-
User.prototype.hasPropertyTank = function () {
|
|
5927
|
-
return this.roles ?
|
|
5928
|
-
this.roles.includes(exports.UserRolesEnum.PROPERTY_TANK) :
|
|
5929
|
-
!!this.getSubscriptionRole(exports.UserRolesEnum.PROPERTY_TANK);
|
|
5831
|
+
Transaction.prototype.getAllocatedAmount = function (allocations) {
|
|
5832
|
+
return allocations.filterBy('transaction.id', this.id).sumBy('amount');
|
|
5930
5833
|
};
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
*/
|
|
5934
|
-
User.prototype.hasWorkTank = function () {
|
|
5935
|
-
return this.roles ?
|
|
5936
|
-
this.roles.includes(exports.UserRolesEnum.WORK_TANK) :
|
|
5937
|
-
!!this.getSubscriptionRole(exports.UserRolesEnum.WORK_TANK);
|
|
5834
|
+
Transaction.prototype.getAllocatedClaimAmount = function (allocations) {
|
|
5835
|
+
return this.getAllocatedAmount(allocations) * this.claimRatio;
|
|
5938
5836
|
};
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
User.prototype.getSubscriptionRole = function (roleType) {
|
|
5944
|
-
var _a;
|
|
5837
|
+
Transaction.prototype.getUnallocatedAmount = function (allocations) {
|
|
5838
|
+
return this.netAmount - this.getAllocatedAmount(allocations);
|
|
5839
|
+
};
|
|
5840
|
+
Object.defineProperty(Transaction.prototype, "grossAmount", {
|
|
5945
5841
|
/**
|
|
5946
|
-
*
|
|
5842
|
+
* Total transaction amount including taxes and other additional amounts
|
|
5947
5843
|
*/
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5844
|
+
get: function () {
|
|
5845
|
+
var grossAmount = _super.prototype.grossAmount + this.tax;
|
|
5846
|
+
if (this.isExpense()) {
|
|
5847
|
+
return grossAmount;
|
|
5848
|
+
}
|
|
5849
|
+
// salary included transactions affect parent transaction amount and as a result grossAmount, skip to avoid double sum
|
|
5850
|
+
grossAmount += new Collection(this.transactions)
|
|
5851
|
+
.filter(function (t) { var _a; return !((_a = t.chartAccounts) === null || _a === void 0 ? void 0 : _a.isSalaryIncluded()); })
|
|
5852
|
+
.sumBy('amount');
|
|
5853
|
+
if (this.isWorkTank()) {
|
|
5854
|
+
grossAmount += this.frankingCredit - this.taxFreeComponent - this.eligibleForReduction;
|
|
5855
|
+
}
|
|
5856
|
+
return +(Math.round(grossAmount * 100) / 100).toFixed(2);
|
|
5857
|
+
},
|
|
5858
|
+
enumerable: false,
|
|
5859
|
+
configurable: true
|
|
5860
|
+
});
|
|
5861
|
+
Object.defineProperty(Transaction.prototype, "netAmount", {
|
|
5862
|
+
/**
|
|
5863
|
+
* netAmount matches received payment (bankTransaction amount), includes gst and salary included adjustments
|
|
5864
|
+
* ie user received 1000$ salary including 100$ tips. NetAmount=1000$, amount=900$, tips=100$
|
|
5865
|
+
*/
|
|
5866
|
+
get: function () {
|
|
5867
|
+
return new Collection(this.transactions)
|
|
5868
|
+
.filter(function (t) { var _a; return (_a = t.chartAccounts) === null || _a === void 0 ? void 0 : _a.isSalaryIncluded(); })
|
|
5869
|
+
.sumBy('amount') + this.amountWithGst;
|
|
5870
|
+
},
|
|
5871
|
+
enumerable: false,
|
|
5872
|
+
configurable: true
|
|
5873
|
+
});
|
|
5874
|
+
return Transaction;
|
|
5875
|
+
}(Transaction$1));
|
|
5964
5876
|
__decorate([
|
|
5965
|
-
classTransformer.Type(function () { return
|
|
5966
|
-
],
|
|
5877
|
+
classTransformer.Type(function () { return Transaction; })
|
|
5878
|
+
], Transaction.prototype, "transactions", void 0);
|
|
5879
|
+
__decorate([
|
|
5880
|
+
classTransformer.Type(function () { return Property; })
|
|
5881
|
+
], Transaction.prototype, "property", void 0);
|
|
5882
|
+
__decorate([
|
|
5883
|
+
classTransformer.Type(function () { return TransactionReceipt; })
|
|
5884
|
+
], Transaction.prototype, "receipt", void 0);
|
|
5967
5885
|
__decorate([
|
|
5968
|
-
classTransformer.Type(function () { return
|
|
5969
|
-
],
|
|
5886
|
+
classTransformer.Type(function () { return ChartAccounts; })
|
|
5887
|
+
], Transaction.prototype, "chartAccounts", void 0);
|
|
5970
5888
|
__decorate([
|
|
5971
|
-
classTransformer.Type(function () { return
|
|
5972
|
-
],
|
|
5889
|
+
classTransformer.Type(function () { return IncomeSource; })
|
|
5890
|
+
], Transaction.prototype, "incomeSource", void 0);
|
|
5973
5891
|
__decorate([
|
|
5974
|
-
classTransformer.Type(function () { return
|
|
5975
|
-
],
|
|
5892
|
+
classTransformer.Type(function () { return TransactionMetadata; })
|
|
5893
|
+
], Transaction.prototype, "metadata", void 0);
|
|
5976
5894
|
__decorate([
|
|
5977
|
-
classTransformer.Type(function () { return
|
|
5978
|
-
],
|
|
5895
|
+
classTransformer.Type(function () { return Transaction; })
|
|
5896
|
+
], Transaction.prototype, "transfer", void 0);
|
|
5979
5897
|
__decorate([
|
|
5980
|
-
classTransformer.Type(function () { return
|
|
5981
|
-
],
|
|
5898
|
+
classTransformer.Type(function () { return Loan; })
|
|
5899
|
+
], Transaction.prototype, "loan", void 0);
|
|
5982
5900
|
__decorate([
|
|
5983
5901
|
classTransformer.Type(function () { return Date; })
|
|
5984
|
-
],
|
|
5902
|
+
], Transaction.prototype, "date", void 0);
|
|
5985
5903
|
__decorate([
|
|
5986
|
-
classTransformer.Type(function () { return
|
|
5987
|
-
],
|
|
5904
|
+
classTransformer.Type(function () { return TransactionAllocation; })
|
|
5905
|
+
], Transaction.prototype, "allocations", void 0);
|
|
5988
5906
|
|
|
5989
|
-
var
|
|
5990
|
-
__extends(
|
|
5991
|
-
function
|
|
5992
|
-
|
|
5907
|
+
var SoleInvoiceItem = /** @class */ (function (_super) {
|
|
5908
|
+
__extends(SoleInvoiceItem, _super);
|
|
5909
|
+
function SoleInvoiceItem() {
|
|
5910
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
5911
|
+
_this.isGST = false;
|
|
5912
|
+
return _this;
|
|
5993
5913
|
}
|
|
5994
|
-
|
|
5995
|
-
|
|
5914
|
+
Object.defineProperty(SoleInvoiceItem.prototype, "totalPrice", {
|
|
5915
|
+
get: function () {
|
|
5916
|
+
return this.price * this.quantity;
|
|
5917
|
+
},
|
|
5918
|
+
enumerable: false,
|
|
5919
|
+
configurable: true
|
|
5920
|
+
});
|
|
5921
|
+
return SoleInvoiceItem;
|
|
5922
|
+
}(SoleInvoiceItem$1));
|
|
5996
5923
|
__decorate([
|
|
5997
|
-
classTransformer.Type(function () { return
|
|
5998
|
-
],
|
|
5924
|
+
classTransformer.Type(function () { return SoleInvoice; })
|
|
5925
|
+
], SoleInvoiceItem.prototype, "invoice", void 0);
|
|
5999
5926
|
__decorate([
|
|
6000
|
-
classTransformer.Type(function () { return
|
|
6001
|
-
],
|
|
5927
|
+
classTransformer.Type(function () { return ChartAccounts; })
|
|
5928
|
+
], SoleInvoiceItem.prototype, "chartAccounts", void 0);
|
|
5929
|
+
__decorate([
|
|
5930
|
+
classTransformer.Type(function () { return Transaction; })
|
|
5931
|
+
], SoleInvoiceItem.prototype, "transaction", void 0);
|
|
6002
5932
|
|
|
6003
|
-
var
|
|
6004
|
-
__extends(
|
|
6005
|
-
function
|
|
5933
|
+
var SoleContact$1 = /** @class */ (function (_super) {
|
|
5934
|
+
__extends(SoleContact, _super);
|
|
5935
|
+
function SoleContact() {
|
|
6006
5936
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
6007
5937
|
}
|
|
6008
|
-
return
|
|
5938
|
+
return SoleContact;
|
|
6009
5939
|
}(AbstractModel));
|
|
6010
5940
|
|
|
6011
|
-
|
|
6012
|
-
(function (
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
PropertyCategoryListEnum[PropertyCategoryListEnum["VACANT_LAND"] = 5] = "VACANT_LAND";
|
|
6016
|
-
})(exports.PropertyCategoryListEnum || (exports.PropertyCategoryListEnum = {}));
|
|
6017
|
-
|
|
6018
|
-
var PropertyCategory = /** @class */ (function (_super) {
|
|
6019
|
-
__extends(PropertyCategory, _super);
|
|
6020
|
-
function PropertyCategory() {
|
|
5941
|
+
// @TODO Alex/Vik: Create some base class for User and SoleContact with common methods and properties
|
|
5942
|
+
var SoleContact = /** @class */ (function (_super) {
|
|
5943
|
+
__extends(SoleContact, _super);
|
|
5944
|
+
function SoleContact() {
|
|
6021
5945
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
6022
5946
|
}
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
5947
|
+
Object.defineProperty(SoleContact.prototype, "fullName", {
|
|
5948
|
+
get: function () {
|
|
5949
|
+
return this.firstName + " " + this.lastName;
|
|
5950
|
+
},
|
|
5951
|
+
enumerable: false,
|
|
5952
|
+
configurable: true
|
|
5953
|
+
});
|
|
5954
|
+
SoleContact.prototype.getPhotoPlaceholder = function () {
|
|
5955
|
+
return "" + this.firstName[0].toUpperCase() + this.lastName[0].toUpperCase();
|
|
6029
5956
|
};
|
|
6030
|
-
|
|
6031
|
-
|
|
5957
|
+
// @TODO Vik: add photo field to SoleContact
|
|
5958
|
+
SoleContact.prototype.getPhoto = function () {
|
|
5959
|
+
return '';
|
|
6032
5960
|
};
|
|
6033
|
-
return
|
|
6034
|
-
}(
|
|
5961
|
+
return SoleContact;
|
|
5962
|
+
}(SoleContact$1));
|
|
5963
|
+
__decorate([
|
|
5964
|
+
classTransformer.Type(function () { return User; })
|
|
5965
|
+
], SoleContact.prototype, "user", void 0);
|
|
5966
|
+
__decorate([
|
|
5967
|
+
classTransformer.Type(function () { return Phone; })
|
|
5968
|
+
], SoleContact.prototype, "phone", void 0);
|
|
5969
|
+
__decorate([
|
|
5970
|
+
classTransformer.Type(function () { return Address; })
|
|
5971
|
+
], SoleContact.prototype, "address", void 0);
|
|
5972
|
+
__decorate([
|
|
5973
|
+
classTransformer.Type(function () { return SoleInvoice; })
|
|
5974
|
+
], SoleContact.prototype, "invoices", void 0);
|
|
6035
5975
|
|
|
6036
|
-
var
|
|
6037
|
-
__extends(
|
|
6038
|
-
function
|
|
5976
|
+
var SoleInvoiceTemplate$1 = /** @class */ (function (_super) {
|
|
5977
|
+
__extends(SoleInvoiceTemplate, _super);
|
|
5978
|
+
function SoleInvoiceTemplate() {
|
|
6039
5979
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
6040
5980
|
}
|
|
6041
|
-
return
|
|
5981
|
+
return SoleInvoiceTemplate;
|
|
6042
5982
|
}(AbstractModel));
|
|
6043
5983
|
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
return '';
|
|
6051
|
-
};
|
|
6052
|
-
PropertyDocument.prototype.getEntity = function () {
|
|
6053
|
-
return undefined;
|
|
6054
|
-
};
|
|
6055
|
-
return PropertyDocument;
|
|
6056
|
-
}(AbstractModel));
|
|
5984
|
+
exports.SoleInvoiceTemplateTaxTypeEnum = void 0;
|
|
5985
|
+
(function (SoleInvoiceTemplateTaxTypeEnum) {
|
|
5986
|
+
SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["TAX_EXCLUSIVE"] = 0] = "TAX_EXCLUSIVE";
|
|
5987
|
+
SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["TAX_INCLUSIVE"] = 1] = "TAX_INCLUSIVE";
|
|
5988
|
+
SoleInvoiceTemplateTaxTypeEnum[SoleInvoiceTemplateTaxTypeEnum["NO_TAX"] = 2] = "NO_TAX";
|
|
5989
|
+
})(exports.SoleInvoiceTemplateTaxTypeEnum || (exports.SoleInvoiceTemplateTaxTypeEnum = {}));
|
|
6057
5990
|
|
|
6058
|
-
var
|
|
6059
|
-
__extends(
|
|
6060
|
-
function
|
|
5991
|
+
var SoleInvoiceTemplate = /** @class */ (function (_super) {
|
|
5992
|
+
__extends(SoleInvoiceTemplate, _super);
|
|
5993
|
+
function SoleInvoiceTemplate() {
|
|
6061
5994
|
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
6062
|
-
|
|
6063
|
-
|
|
5995
|
+
/**
|
|
5996
|
+
* Affects to SoleInvoiceItem.isGST flag availability.
|
|
5997
|
+
* When NONE: isGST is unavailable
|
|
5998
|
+
* When EXCLUSIVE: GST amount added additionaly to invoice total price
|
|
5999
|
+
* When INCLUSIVE: GST amount is already included to invoice total price
|
|
6000
|
+
*/
|
|
6001
|
+
_this.taxType = exports.SoleInvoiceTemplateTaxTypeEnum.NO_TAX;
|
|
6064
6002
|
return _this;
|
|
6065
6003
|
}
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6004
|
+
Object.defineProperty(SoleInvoiceTemplate.prototype, "termTime", {
|
|
6005
|
+
/**
|
|
6006
|
+
* Get term duration in milliseconds
|
|
6007
|
+
*/
|
|
6008
|
+
get: function () {
|
|
6009
|
+
return this.term * 24 * 3600 * 1000;
|
|
6010
|
+
},
|
|
6011
|
+
enumerable: false,
|
|
6012
|
+
configurable: true
|
|
6013
|
+
});
|
|
6014
|
+
return SoleInvoiceTemplate;
|
|
6015
|
+
}(SoleInvoiceTemplate$1));
|
|
6016
|
+
__decorate([
|
|
6017
|
+
classTransformer.Type(function () { return SoleBusiness; })
|
|
6018
|
+
], SoleInvoiceTemplate.prototype, "business", void 0);
|
|
6019
|
+
__decorate([
|
|
6020
|
+
classTransformer.Type(function () { return BankAccount; })
|
|
6021
|
+
], SoleInvoiceTemplate.prototype, "bankAccount", void 0);
|
|
6074
6022
|
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6023
|
+
exports.SoleInvoiceStatusesEnum = void 0;
|
|
6024
|
+
(function (SoleInvoiceStatusesEnum) {
|
|
6025
|
+
SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["CANCELED"] = 0] = "CANCELED";
|
|
6026
|
+
SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["DRAFT"] = 1] = "DRAFT";
|
|
6027
|
+
SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PENDING"] = 2] = "PENDING";
|
|
6028
|
+
SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PAID"] = 3] = "PAID";
|
|
6029
|
+
})(exports.SoleInvoiceStatusesEnum || (exports.SoleInvoiceStatusesEnum = {}));
|
|
6030
|
+
|
|
6031
|
+
exports.SoleInvoiceTaxTypeEnum = void 0;
|
|
6032
|
+
(function (SoleInvoiceTaxTypeEnum) {
|
|
6033
|
+
SoleInvoiceTaxTypeEnum[SoleInvoiceTaxTypeEnum["TAX_EXCLUSIVE"] = 0] = "TAX_EXCLUSIVE";
|
|
6034
|
+
SoleInvoiceTaxTypeEnum[SoleInvoiceTaxTypeEnum["TAX_INCLUSIVE"] = 1] = "TAX_INCLUSIVE";
|
|
6035
|
+
SoleInvoiceTaxTypeEnum[SoleInvoiceTaxTypeEnum["NO_TAX"] = 2] = "NO_TAX";
|
|
6036
|
+
})(exports.SoleInvoiceTaxTypeEnum || (exports.SoleInvoiceTaxTypeEnum = {}));
|
|
6037
|
+
|
|
6038
|
+
var SoleInvoiceItemCollection = /** @class */ (function (_super) {
|
|
6039
|
+
__extends(SoleInvoiceItemCollection, _super);
|
|
6040
|
+
function SoleInvoiceItemCollection() {
|
|
6078
6041
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
6079
6042
|
}
|
|
6080
|
-
Object.defineProperty(
|
|
6043
|
+
Object.defineProperty(SoleInvoiceItemCollection.prototype, "gstPrice", {
|
|
6044
|
+
get: function () {
|
|
6045
|
+
return this.filterBy('isGST', true).sumBy('totalPrice');
|
|
6046
|
+
},
|
|
6047
|
+
enumerable: false,
|
|
6048
|
+
configurable: true
|
|
6049
|
+
});
|
|
6050
|
+
return SoleInvoiceItemCollection;
|
|
6051
|
+
}(Collection));
|
|
6052
|
+
|
|
6053
|
+
var SoleInvoice = /** @class */ (function (_super) {
|
|
6054
|
+
__extends(SoleInvoice, _super);
|
|
6055
|
+
function SoleInvoice() {
|
|
6056
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
6057
|
+
_this.status = exports.SoleInvoiceStatusesEnum.DRAFT;
|
|
6058
|
+
_this.taxType = exports.SoleInvoiceTaxTypeEnum.NO_TAX;
|
|
6059
|
+
return _this;
|
|
6060
|
+
}
|
|
6061
|
+
Object.defineProperty(SoleInvoice.prototype, "itemsCollection", {
|
|
6062
|
+
/**
|
|
6063
|
+
* Get items array as collection
|
|
6064
|
+
*/
|
|
6065
|
+
get: function () {
|
|
6066
|
+
return new SoleInvoiceItemCollection(this.items);
|
|
6067
|
+
},
|
|
6068
|
+
enumerable: false,
|
|
6069
|
+
configurable: true
|
|
6070
|
+
});
|
|
6071
|
+
Object.defineProperty(SoleInvoice.prototype, "price", {
|
|
6072
|
+
/**
|
|
6073
|
+
* Total price of all items
|
|
6074
|
+
*/
|
|
6075
|
+
get: function () {
|
|
6076
|
+
return this.itemsCollection.sumBy('totalPrice');
|
|
6077
|
+
},
|
|
6078
|
+
enumerable: false,
|
|
6079
|
+
configurable: true
|
|
6080
|
+
});
|
|
6081
|
+
Object.defineProperty(SoleInvoice.prototype, "netPrice", {
|
|
6082
|
+
/**
|
|
6083
|
+
* Total invoice price without GST
|
|
6084
|
+
*/
|
|
6085
|
+
get: function () {
|
|
6086
|
+
if (this.isTaxInclusive()) {
|
|
6087
|
+
return this.price - this.GSTAmount;
|
|
6088
|
+
}
|
|
6089
|
+
return this.price;
|
|
6090
|
+
},
|
|
6091
|
+
enumerable: false,
|
|
6092
|
+
configurable: true
|
|
6093
|
+
});
|
|
6094
|
+
Object.defineProperty(SoleInvoice.prototype, "grossPrice", {
|
|
6095
|
+
/**
|
|
6096
|
+
* Total final price (net + GST)
|
|
6097
|
+
*/
|
|
6081
6098
|
get: function () {
|
|
6082
|
-
|
|
6099
|
+
if (this.isTaxExclusive()) {
|
|
6100
|
+
return this.price + this.GSTAmount;
|
|
6101
|
+
}
|
|
6102
|
+
return this.price;
|
|
6083
6103
|
},
|
|
6084
6104
|
enumerable: false,
|
|
6085
6105
|
configurable: true
|
|
6086
6106
|
});
|
|
6087
|
-
|
|
6088
|
-
return this.financialYear === new FinancialYear(new Date()).year;
|
|
6089
|
-
};
|
|
6090
|
-
return PropertyValuation;
|
|
6091
|
-
}(PropertyValuation$1));
|
|
6092
|
-
__decorate([
|
|
6093
|
-
classTransformer.Type(function () { return Date; })
|
|
6094
|
-
], PropertyValuation.prototype, "date", void 0);
|
|
6095
|
-
__decorate([
|
|
6096
|
-
classTransformer.Type(function () { return PropertyDocument; })
|
|
6097
|
-
], PropertyValuation.prototype, "document", void 0);
|
|
6098
|
-
__decorate([
|
|
6099
|
-
classTransformer.Exclude()
|
|
6100
|
-
], PropertyValuation.prototype, "documentFile", void 0);
|
|
6101
|
-
|
|
6102
|
-
var PropertyForecast$1 = /** @class */ (function (_super) {
|
|
6103
|
-
__extends(PropertyForecast, _super);
|
|
6104
|
-
function PropertyForecast() {
|
|
6105
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
6106
|
-
}
|
|
6107
|
-
return PropertyForecast;
|
|
6108
|
-
}(AbstractModel));
|
|
6109
|
-
|
|
6110
|
-
var PropertyForecast = /** @class */ (function (_super) {
|
|
6111
|
-
__extends(PropertyForecast, _super);
|
|
6112
|
-
function PropertyForecast() {
|
|
6113
|
-
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
6114
|
-
_this.financialYear = new FinancialYear(new Date()).year;
|
|
6115
|
-
return _this;
|
|
6116
|
-
}
|
|
6117
|
-
Object.defineProperty(PropertyForecast.prototype, "cashPosition", {
|
|
6107
|
+
Object.defineProperty(SoleInvoice.prototype, "GSTAmount", {
|
|
6118
6108
|
/**
|
|
6119
|
-
*
|
|
6120
|
-
* Cash Position = Income - Expense - Interest
|
|
6109
|
+
* Total GST amount
|
|
6121
6110
|
*/
|
|
6122
6111
|
get: function () {
|
|
6123
|
-
|
|
6112
|
+
switch (this.taxType) {
|
|
6113
|
+
case exports.SoleInvoiceTaxTypeEnum.TAX_INCLUSIVE:
|
|
6114
|
+
return this.inclusiveGSTAmount;
|
|
6115
|
+
case exports.SoleInvoiceTaxTypeEnum.TAX_EXCLUSIVE:
|
|
6116
|
+
return this.exclusiveGSTAmount;
|
|
6117
|
+
case exports.SoleInvoiceTaxTypeEnum.NO_TAX:
|
|
6118
|
+
return 0;
|
|
6119
|
+
}
|
|
6124
6120
|
},
|
|
6125
6121
|
enumerable: false,
|
|
6126
6122
|
configurable: true
|
|
6127
6123
|
});
|
|
6128
|
-
Object.defineProperty(
|
|
6124
|
+
Object.defineProperty(SoleInvoice.prototype, "inclusiveGSTAmount", {
|
|
6129
6125
|
/**
|
|
6130
|
-
*
|
|
6131
|
-
* Tax Position = Income - Expense - Interest - Depreciation
|
|
6126
|
+
* When tax inclusive, GST amount is included to total price
|
|
6132
6127
|
*/
|
|
6133
6128
|
get: function () {
|
|
6134
|
-
|
|
6129
|
+
var gstPrice = this.itemsCollection.gstPrice;
|
|
6130
|
+
return +(gstPrice - (gstPrice / (1 + ChartAccounts.GSTRatio))).toFixed(2);
|
|
6135
6131
|
},
|
|
6136
6132
|
enumerable: false,
|
|
6137
6133
|
configurable: true
|
|
6138
6134
|
});
|
|
6139
|
-
Object.defineProperty(
|
|
6135
|
+
Object.defineProperty(SoleInvoice.prototype, "exclusiveGSTAmount", {
|
|
6140
6136
|
/**
|
|
6141
|
-
*
|
|
6142
|
-
* Rental Return = Income / Market Value
|
|
6137
|
+
* When tax exclusive, GST amount should be added additionally to total price
|
|
6143
6138
|
*/
|
|
6144
6139
|
get: function () {
|
|
6145
|
-
return this.
|
|
6140
|
+
return +(this.itemsCollection.gstPrice * ChartAccounts.GSTRatio).toFixed(2);
|
|
6146
6141
|
},
|
|
6147
6142
|
enumerable: false,
|
|
6148
6143
|
configurable: true
|
|
6149
6144
|
});
|
|
6145
|
+
SoleInvoice.prototype.isDraft = function () {
|
|
6146
|
+
return this.status === exports.SoleInvoiceStatusesEnum.DRAFT;
|
|
6147
|
+
};
|
|
6148
|
+
SoleInvoice.prototype.isCancelled = function () {
|
|
6149
|
+
return this.status === exports.SoleInvoiceStatusesEnum.CANCELED;
|
|
6150
|
+
};
|
|
6151
|
+
SoleInvoice.prototype.isPending = function () {
|
|
6152
|
+
return this.status === exports.SoleInvoiceStatusesEnum.PENDING;
|
|
6153
|
+
};
|
|
6154
|
+
SoleInvoice.prototype.isPaid = function () {
|
|
6155
|
+
return this.status === exports.SoleInvoiceStatusesEnum.PAID;
|
|
6156
|
+
};
|
|
6157
|
+
SoleInvoice.prototype.isOverdue = function () {
|
|
6158
|
+
return this.isPending() && this.dateTo < new Date();
|
|
6159
|
+
};
|
|
6160
|
+
SoleInvoice.prototype.isUnpaid = function () {
|
|
6161
|
+
return this.isPending() && this.dateTo >= new Date();
|
|
6162
|
+
};
|
|
6150
6163
|
/**
|
|
6151
|
-
*
|
|
6164
|
+
* GST is not available for invoices without taxes
|
|
6152
6165
|
*/
|
|
6153
|
-
|
|
6154
|
-
return this.
|
|
6166
|
+
SoleInvoice.prototype.isNoTax = function () {
|
|
6167
|
+
return this.taxType === exports.SoleInvoiceTaxTypeEnum.NO_TAX;
|
|
6155
6168
|
};
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
return
|
|
6162
|
-
}
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6169
|
+
/**
|
|
6170
|
+
* GST amount is not included in items prices for invoices with tax exclusive,
|
|
6171
|
+
* we should add GST amount additionaly to subtotal price to get total price
|
|
6172
|
+
*/
|
|
6173
|
+
SoleInvoice.prototype.isTaxExclusive = function () {
|
|
6174
|
+
return this.taxType === exports.SoleInvoiceTaxTypeEnum.TAX_EXCLUSIVE;
|
|
6175
|
+
};
|
|
6176
|
+
/**
|
|
6177
|
+
* GST amount already included in items prices for invoices with tax inclusive,
|
|
6178
|
+
* we should subtract GST amount from total price to get subtotal price
|
|
6179
|
+
*/
|
|
6180
|
+
SoleInvoice.prototype.isTaxInclusive = function () {
|
|
6181
|
+
return this.taxType === exports.SoleInvoiceTaxTypeEnum.TAX_INCLUSIVE;
|
|
6182
|
+
};
|
|
6183
|
+
SoleInvoice.prototype.getNumber = function () {
|
|
6184
|
+
return String(this.number).padStart(SoleInvoice.NUMBER_LENGTH, '0');
|
|
6185
|
+
};
|
|
6186
|
+
Object.defineProperty(SoleInvoice.prototype, "name", {
|
|
6187
|
+
get: function () {
|
|
6188
|
+
return "invoice-" + this.getNumber() + ".pdf";
|
|
6189
|
+
},
|
|
6190
|
+
enumerable: false,
|
|
6191
|
+
configurable: true
|
|
6192
|
+
});
|
|
6193
|
+
SoleInvoice.prototype.getTransactionsIds = function () {
|
|
6194
|
+
return new Collection(this.items).mapBy('transaction.id');
|
|
6195
|
+
this.items.map(function (item) { return item.transaction.id; });
|
|
6196
|
+
};
|
|
6197
|
+
return SoleInvoice;
|
|
6198
|
+
}(SoleInvoice$1));
|
|
6199
|
+
SoleInvoice.NUMBER_LENGTH = 4;
|
|
6170
6200
|
__decorate([
|
|
6171
|
-
classTransformer.
|
|
6172
|
-
|
|
6173
|
-
return -Math.abs(+value);
|
|
6174
|
-
})
|
|
6175
|
-
], PropertyForecast.prototype, "interest", void 0);
|
|
6201
|
+
classTransformer.Type(function () { return Date; })
|
|
6202
|
+
], SoleInvoice.prototype, "dateFrom", void 0);
|
|
6176
6203
|
__decorate([
|
|
6177
|
-
classTransformer.
|
|
6178
|
-
|
|
6179
|
-
return -Math.abs(+value);
|
|
6180
|
-
})
|
|
6181
|
-
], PropertyForecast.prototype, "depreciation", void 0);
|
|
6204
|
+
classTransformer.Type(function () { return Date; })
|
|
6205
|
+
], SoleInvoice.prototype, "dateTo", void 0);
|
|
6182
6206
|
__decorate([
|
|
6183
|
-
classTransformer.
|
|
6184
|
-
|
|
6185
|
-
return +value;
|
|
6186
|
-
})
|
|
6187
|
-
], PropertyForecast.prototype, "loanBalance", void 0);
|
|
6207
|
+
classTransformer.Type(function () { return User; })
|
|
6208
|
+
], SoleInvoice.prototype, "user", void 0);
|
|
6188
6209
|
__decorate([
|
|
6189
|
-
classTransformer.
|
|
6190
|
-
|
|
6191
|
-
return +value;
|
|
6192
|
-
})
|
|
6193
|
-
], PropertyForecast.prototype, "marketValue", void 0);
|
|
6194
|
-
|
|
6195
|
-
var PropertyCategoryMovement$1 = /** @class */ (function (_super) {
|
|
6196
|
-
__extends(PropertyCategoryMovement, _super);
|
|
6197
|
-
function PropertyCategoryMovement() {
|
|
6198
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
6199
|
-
}
|
|
6200
|
-
return PropertyCategoryMovement;
|
|
6201
|
-
}(AbstractModel));
|
|
6202
|
-
|
|
6203
|
-
var PropertyCategoryMovement = /** @class */ (function (_super) {
|
|
6204
|
-
__extends(PropertyCategoryMovement, _super);
|
|
6205
|
-
function PropertyCategoryMovement() {
|
|
6206
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
6207
|
-
}
|
|
6208
|
-
return PropertyCategoryMovement;
|
|
6209
|
-
}(PropertyCategoryMovement$1));
|
|
6210
|
+
classTransformer.Type(function () { return SoleBusiness; })
|
|
6211
|
+
], SoleInvoice.prototype, "business", void 0);
|
|
6210
6212
|
__decorate([
|
|
6211
|
-
classTransformer.Type(function () { return
|
|
6212
|
-
],
|
|
6213
|
+
classTransformer.Type(function () { return SoleInvoiceItem; })
|
|
6214
|
+
], SoleInvoice.prototype, "items", void 0);
|
|
6213
6215
|
__decorate([
|
|
6214
|
-
classTransformer.Type(function () { return
|
|
6215
|
-
],
|
|
6216
|
+
classTransformer.Type(function () { return SoleContact; })
|
|
6217
|
+
], SoleInvoice.prototype, "payer", void 0);
|
|
6216
6218
|
__decorate([
|
|
6217
|
-
classTransformer.Type(function () { return
|
|
6218
|
-
],
|
|
6219
|
+
classTransformer.Type(function () { return SoleInvoiceTemplate; })
|
|
6220
|
+
], SoleInvoice.prototype, "template", void 0);
|
|
6219
6221
|
__decorate([
|
|
6220
|
-
classTransformer.Type(function () { return
|
|
6221
|
-
],
|
|
6222
|
-
|
|
6223
|
-
exports.TaxExemptionEnum = void 0;
|
|
6224
|
-
(function (TaxExemptionEnum) {
|
|
6225
|
-
TaxExemptionEnum[TaxExemptionEnum["ONE_YEAR_RULE"] = 1] = "ONE_YEAR_RULE";
|
|
6226
|
-
// principle place of residence
|
|
6227
|
-
TaxExemptionEnum[TaxExemptionEnum["PPR"] = 2] = "PPR";
|
|
6228
|
-
TaxExemptionEnum[TaxExemptionEnum["SIX_YEARS_RULE"] = 3] = "SIX_YEARS_RULE";
|
|
6229
|
-
TaxExemptionEnum[TaxExemptionEnum["INVESTMENT_TO_PPR"] = 4] = "INVESTMENT_TO_PPR";
|
|
6230
|
-
TaxExemptionEnum[TaxExemptionEnum["PPR_TO_INVESTMENT"] = 5] = "PPR_TO_INVESTMENT";
|
|
6231
|
-
TaxExemptionEnum[TaxExemptionEnum["TRANSFER"] = 6] = "TRANSFER";
|
|
6232
|
-
TaxExemptionEnum[TaxExemptionEnum["OTHER"] = 7] = "OTHER";
|
|
6233
|
-
})(exports.TaxExemptionEnum || (exports.TaxExemptionEnum = {}));
|
|
6234
|
-
|
|
6235
|
-
exports.TaxExemptionMetadataEnum = void 0;
|
|
6236
|
-
(function (TaxExemptionMetadataEnum) {
|
|
6237
|
-
// principle place of residence
|
|
6238
|
-
TaxExemptionMetadataEnum[TaxExemptionMetadataEnum["PPR_DAYS"] = 1] = "PPR_DAYS";
|
|
6239
|
-
// market value once it was moved, decimal
|
|
6240
|
-
TaxExemptionMetadataEnum[TaxExemptionMetadataEnum["MARKET_VALUE"] = 2] = "MARKET_VALUE";
|
|
6241
|
-
TaxExemptionMetadataEnum[TaxExemptionMetadataEnum["CLAIM_PERCENT"] = 3] = "CLAIM_PERCENT";
|
|
6242
|
-
})(exports.TaxExemptionMetadataEnum || (exports.TaxExemptionMetadataEnum = {}));
|
|
6222
|
+
classTransformer.Type(function () { return BankAccount; })
|
|
6223
|
+
], SoleInvoice.prototype, "bankAccount", void 0);
|
|
6243
6224
|
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6225
|
+
/**
|
|
6226
|
+
* Class contains traveled kilometers and work usage percent in 12 weeks date range
|
|
6227
|
+
* @TODO Vik: Best period: move this and related logic to backend
|
|
6228
|
+
* @TODO Alex: check if we need this class when calculation refactored with backend
|
|
6229
|
+
*/
|
|
6230
|
+
var LogbookPeriod = /** @class */ (function () {
|
|
6231
|
+
function LogbookPeriod() {
|
|
6248
6232
|
}
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
return (_b = (_a = this.getByMetadataId(exports.TaxExemptionMetadataEnum.PPR_DAYS)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0;
|
|
6252
|
-
};
|
|
6253
|
-
PropertySaleTaxExemptionMetadataCollection.prototype.getMarketValue = function () {
|
|
6254
|
-
var _a, _b;
|
|
6255
|
-
return (_b = (_a = this.getByMetadataId(exports.TaxExemptionMetadataEnum.MARKET_VALUE)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0;
|
|
6256
|
-
};
|
|
6257
|
-
PropertySaleTaxExemptionMetadataCollection.prototype.getClaimPercent = function () {
|
|
6258
|
-
var _a, _b;
|
|
6259
|
-
return (_b = (_a = this.getByMetadataId(exports.TaxExemptionMetadataEnum.CLAIM_PERCENT)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 100;
|
|
6233
|
+
LogbookPeriod.prototype.isEndOfYear = function () {
|
|
6234
|
+
return this.to === new FinancialYear().endDate;
|
|
6260
6235
|
};
|
|
6261
|
-
|
|
6262
|
-
|
|
6236
|
+
LogbookPeriod.prototype.getWorkUsageByClaim = function (claim) {
|
|
6237
|
+
var claimKilometers = this.logbooks.getByVehicleClaim(claim).getClaimableLogbooks().kilometers;
|
|
6238
|
+
return Math.round(this.workUsage * (claimKilometers / this.kilometers));
|
|
6263
6239
|
};
|
|
6264
|
-
return
|
|
6265
|
-
}(
|
|
6240
|
+
return LogbookPeriod;
|
|
6241
|
+
}());
|
|
6242
|
+
__decorate([
|
|
6243
|
+
classTransformer.Type(function () { return Date; })
|
|
6244
|
+
], LogbookPeriod.prototype, "from", void 0);
|
|
6245
|
+
__decorate([
|
|
6246
|
+
classTransformer.Type(function () { return Date; })
|
|
6247
|
+
], LogbookPeriod.prototype, "to", void 0);
|
|
6266
6248
|
|
|
6267
|
-
var
|
|
6268
|
-
__extends(
|
|
6269
|
-
function
|
|
6249
|
+
var Vehicle$1 = /** @class */ (function (_super) {
|
|
6250
|
+
__extends(Vehicle, _super);
|
|
6251
|
+
function Vehicle() {
|
|
6270
6252
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
6271
6253
|
}
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
return this.create(this.items.filter(function (propertySale) { return propertySale.grossCGT > 0; })).sumBy('grossCGT');
|
|
6275
|
-
},
|
|
6276
|
-
enumerable: false,
|
|
6277
|
-
configurable: true
|
|
6278
|
-
});
|
|
6279
|
-
/**
|
|
6280
|
-
* Property sales are CGT applicable unless it has "Principle place of residence" exemption type
|
|
6281
|
-
*/
|
|
6282
|
-
PropertySaleCollection.prototype.getCGTApplicable = function () {
|
|
6283
|
-
return this.create(this.items.filter(function (propertySale) { return propertySale.isCGTApplicable(); }));
|
|
6284
|
-
};
|
|
6285
|
-
PropertySaleCollection.prototype.getByPropertyShareIds = function (ids) {
|
|
6286
|
-
return this.filterBy('share.id', ids);
|
|
6287
|
-
};
|
|
6288
|
-
return PropertySaleCollection;
|
|
6289
|
-
}(Collection));
|
|
6254
|
+
return Vehicle;
|
|
6255
|
+
}(AbstractModel));
|
|
6290
6256
|
|
|
6291
|
-
var
|
|
6292
|
-
__extends(
|
|
6293
|
-
function
|
|
6257
|
+
var VehicleLogbook$1 = /** @class */ (function (_super) {
|
|
6258
|
+
__extends(VehicleLogbook, _super);
|
|
6259
|
+
function VehicleLogbook() {
|
|
6294
6260
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
6295
6261
|
}
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
return new PropertyCollection(this.items.filter(function (property) { return property.isActive; }));
|
|
6308
|
-
};
|
|
6309
|
-
PropertyCollection.prototype.getCreatedProperties = function () {
|
|
6310
|
-
return new PropertyCollection(this.items.filter(function (property) { return property.isOwn(); }));
|
|
6311
|
-
};
|
|
6312
|
-
/**
|
|
6313
|
-
* Get new property collection filtered by shared
|
|
6314
|
-
*/
|
|
6315
|
-
PropertyCollection.prototype.getSharedProperties = function () {
|
|
6316
|
-
return new PropertyCollection(this.items.filter(function (property) { return !property.isOwn(); }));
|
|
6317
|
-
};
|
|
6318
|
-
/**
|
|
6319
|
-
* Properties that are taxed and will be included in reports (Tax summary, My tax report, e.t.c.)
|
|
6320
|
-
*/
|
|
6321
|
-
PropertyCollection.prototype.getTaxInclusive = function () {
|
|
6322
|
-
return this.create(this.items.filter(function (property) { return property.category.isTaxInclusive; }));
|
|
6323
|
-
};
|
|
6324
|
-
PropertyCollection.prototype.getUnsold = function () {
|
|
6325
|
-
return this.create(this.items.filter(function (property) { return !property.isSold(); }));
|
|
6326
|
-
};
|
|
6327
|
-
Object.defineProperty(PropertyCollection.prototype, "purchasePrice", {
|
|
6328
|
-
/**
|
|
6329
|
-
* Get total purchase price for all properties in the collection
|
|
6330
|
-
*/
|
|
6331
|
-
get: function () {
|
|
6332
|
-
return this.sumBy('purchasePrice');
|
|
6333
|
-
},
|
|
6334
|
-
enumerable: false,
|
|
6335
|
-
configurable: true
|
|
6336
|
-
});
|
|
6337
|
-
Object.defineProperty(PropertyCollection.prototype, "growthPercent", {
|
|
6338
|
-
get: function () {
|
|
6339
|
-
return this.sumBy('growthPercent');
|
|
6340
|
-
},
|
|
6341
|
-
enumerable: false,
|
|
6342
|
-
configurable: true
|
|
6343
|
-
});
|
|
6344
|
-
Object.defineProperty(PropertyCollection.prototype, "marketValue", {
|
|
6345
|
-
get: function () {
|
|
6346
|
-
return this.sumBy('marketValue');
|
|
6347
|
-
},
|
|
6348
|
-
enumerable: false,
|
|
6349
|
-
configurable: true
|
|
6350
|
-
});
|
|
6351
|
-
Object.defineProperty(PropertyCollection.prototype, "firstForecastYear", {
|
|
6352
|
-
get: function () {
|
|
6353
|
-
return this.items.reduce(function (min, property) {
|
|
6354
|
-
var current = property.firstForecastYear;
|
|
6355
|
-
return min > current ? current : min;
|
|
6356
|
-
}, new FinancialYear().year);
|
|
6357
|
-
},
|
|
6358
|
-
enumerable: false,
|
|
6359
|
-
configurable: true
|
|
6360
|
-
});
|
|
6361
|
-
Object.defineProperty(PropertyCollection.prototype, "marketValueGrowth", {
|
|
6262
|
+
return VehicleLogbook;
|
|
6263
|
+
}(AbstractModel));
|
|
6264
|
+
|
|
6265
|
+
// problem with DateRange and typescript. See more https://github.com/rotaready/moment-range/issues/263
|
|
6266
|
+
var moment = momentRange.extendMoment(moment__namespace);
|
|
6267
|
+
var VehicleLogbook = /** @class */ (function (_super) {
|
|
6268
|
+
__extends(VehicleLogbook, _super);
|
|
6269
|
+
function VehicleLogbook() {
|
|
6270
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6271
|
+
}
|
|
6272
|
+
Object.defineProperty(VehicleLogbook.prototype, "kilometers", {
|
|
6362
6273
|
get: function () {
|
|
6363
|
-
return
|
|
6274
|
+
return this.odometerEnd - this.odometerStart;
|
|
6364
6275
|
},
|
|
6365
6276
|
enumerable: false,
|
|
6366
6277
|
configurable: true
|
|
6367
6278
|
});
|
|
6368
|
-
|
|
6369
|
-
* list of properties
|
|
6370
|
-
*/
|
|
6371
|
-
PropertyCollection.prototype.getCGTApplicable = function () {
|
|
6372
|
-
return this.create(this.items.filter(function (property) { return property.isCGTApplicable(); }));
|
|
6373
|
-
};
|
|
6374
|
-
PropertyCollection.prototype.getOwnerOccupiedProperties = function () {
|
|
6375
|
-
return new PropertyCollection(this.items.filter(function (property) { return property.category.isOwnerOccupied(); }));
|
|
6376
|
-
};
|
|
6377
|
-
Object.defineProperty(PropertyCollection.prototype, "earliestContractDate", {
|
|
6279
|
+
Object.defineProperty(VehicleLogbook.prototype, "tankType", {
|
|
6378
6280
|
get: function () {
|
|
6379
|
-
return this.
|
|
6380
|
-
return min < property.contractDate ? min : property.contractDate;
|
|
6381
|
-
}, new FinancialYear(new Date()).startDate);
|
|
6281
|
+
return this.isSoleTank() ? exports.TankTypeEnum.SOLE : exports.TankTypeEnum.WORK;
|
|
6382
6282
|
},
|
|
6383
6283
|
enumerable: false,
|
|
6384
6284
|
configurable: true
|
|
6385
6285
|
});
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
*/
|
|
6389
|
-
PropertyCollection.prototype.getCategories = function () {
|
|
6390
|
-
return uniqBy__default["default"](this.items.map(function (property) { return property.category; }), 'id');
|
|
6391
|
-
};
|
|
6392
|
-
/**
|
|
6393
|
-
* Get property with the highest growth percent
|
|
6394
|
-
*/
|
|
6395
|
-
PropertyCollection.prototype.getBestPerformanceGrowthProperty = function () {
|
|
6396
|
-
return this.items.reduce(function (max, current) {
|
|
6397
|
-
return max.growthPercent < current.growthPercent ? current : max;
|
|
6398
|
-
}, this.first);
|
|
6286
|
+
VehicleLogbook.prototype.isWorkTank = function () {
|
|
6287
|
+
return !this.business;
|
|
6399
6288
|
};
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
*/
|
|
6403
|
-
PropertyCollection.prototype.getBestPerformanceTaxProperty = function (transactions, depreciations) {
|
|
6404
|
-
var transactionsByProperty = transactions.groupBy('property.id');
|
|
6405
|
-
var depreciationsByProperty = depreciations.groupBy('property.id');
|
|
6406
|
-
return this.items.reduce(function (min, current) {
|
|
6407
|
-
var minTaxPosition = min.getTaxPosition(transactionsByProperty.get(min.id), depreciationsByProperty.get(min.id));
|
|
6408
|
-
var currentTaxPosition = current.getTaxPosition(transactionsByProperty.get(current.id), depreciationsByProperty.get(current.id));
|
|
6409
|
-
return minTaxPosition > currentTaxPosition ? current : min;
|
|
6410
|
-
}, this.first);
|
|
6289
|
+
VehicleLogbook.prototype.isSoleTank = function () {
|
|
6290
|
+
return !!this.business;
|
|
6411
6291
|
};
|
|
6412
6292
|
/**
|
|
6413
|
-
*
|
|
6414
|
-
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/217677997/Property+Tank+Dashboard
|
|
6293
|
+
* Get logbook period date range from logbook date and weeksInPeriod duration
|
|
6415
6294
|
*/
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
// nothing to sort when no active properties
|
|
6419
|
-
if (!activeProperties.length) {
|
|
6420
|
-
return this;
|
|
6421
|
-
}
|
|
6422
|
-
var bestProperties = uniqBy__default["default"](this.create([
|
|
6423
|
-
activeProperties.getBestPerformanceGrowthProperty(),
|
|
6424
|
-
activeProperties.getBestPerformanceTaxProperty(transactions, depreciations)
|
|
6425
|
-
]).toArray(), 'id');
|
|
6426
|
-
var newItems = this.remove(bestProperties).toArray();
|
|
6427
|
-
newItems.unshift.apply(newItems, __spreadArray([], __read(bestProperties)));
|
|
6428
|
-
return this.create(newItems);
|
|
6295
|
+
VehicleLogbook.prototype.getPeriod = function () {
|
|
6296
|
+
return moment.rangeFromInterval('milliseconds', VehicleLogbook.bestPeriodDuration, this.date);
|
|
6429
6297
|
};
|
|
6430
|
-
return
|
|
6431
|
-
}(
|
|
6298
|
+
return VehicleLogbook;
|
|
6299
|
+
}(VehicleLogbook$1));
|
|
6300
|
+
/**
|
|
6301
|
+
* Logbook period duration in milliseconds.
|
|
6302
|
+
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/211517441/Logbook+Vehicle
|
|
6303
|
+
*/
|
|
6304
|
+
VehicleLogbook.bestPeriodDuration = 12 * 7 * 24 * 3600 * 1000;
|
|
6305
|
+
__decorate([
|
|
6306
|
+
classTransformer.Type(function () { return Date; })
|
|
6307
|
+
], VehicleLogbook.prototype, "date", void 0);
|
|
6308
|
+
__decorate([
|
|
6309
|
+
classTransformer.Type(function () { return SoleBusiness; })
|
|
6310
|
+
], VehicleLogbook.prototype, "business", void 0);
|
|
6432
6311
|
|
|
6433
|
-
var
|
|
6434
|
-
__extends(
|
|
6435
|
-
function
|
|
6312
|
+
var Vehicle = /** @class */ (function (_super) {
|
|
6313
|
+
__extends(Vehicle, _super);
|
|
6314
|
+
function Vehicle() {
|
|
6436
6315
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
6437
6316
|
}
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
return this.filterBy('property.id', property.id).filter(function (movement) {
|
|
6444
|
-
return movement.fromDate <= financialYear.endDate && !movement.toDate || movement.toDate >= financialYear.startDate;
|
|
6445
|
-
});
|
|
6446
|
-
};
|
|
6447
|
-
PropertyCategoryMovementCollection.prototype.hasCategory = function (categoryId) {
|
|
6448
|
-
return !!this.findBy('propertyCategory.id', categoryId);
|
|
6449
|
-
};
|
|
6450
|
-
return PropertyCategoryMovementCollection;
|
|
6451
|
-
}(Collection));
|
|
6317
|
+
return Vehicle;
|
|
6318
|
+
}(Vehicle$1));
|
|
6319
|
+
__decorate([
|
|
6320
|
+
classTransformer.Type(function () { return VehicleLogbook; })
|
|
6321
|
+
], Vehicle.prototype, "logbook", void 0);
|
|
6452
6322
|
|
|
6453
|
-
var
|
|
6454
|
-
__extends(
|
|
6455
|
-
function
|
|
6323
|
+
var VehicleClaim$1 = /** @class */ (function (_super) {
|
|
6324
|
+
__extends(VehicleClaim, _super);
|
|
6325
|
+
function VehicleClaim() {
|
|
6456
6326
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
6457
6327
|
}
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6328
|
+
return VehicleClaim;
|
|
6329
|
+
}(AbstractModel));
|
|
6330
|
+
|
|
6331
|
+
var VehicleClaimDetails$1 = /** @class */ (function (_super) {
|
|
6332
|
+
__extends(VehicleClaimDetails, _super);
|
|
6333
|
+
function VehicleClaimDetails() {
|
|
6334
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6335
|
+
}
|
|
6336
|
+
return VehicleClaimDetails;
|
|
6337
|
+
}(AbstractModel));
|
|
6338
|
+
|
|
6339
|
+
exports.VehicleClaimDetailsMethodEnum = void 0;
|
|
6340
|
+
(function (VehicleClaimDetailsMethodEnum) {
|
|
6341
|
+
VehicleClaimDetailsMethodEnum[VehicleClaimDetailsMethodEnum["KMS"] = 1] = "KMS";
|
|
6342
|
+
VehicleClaimDetailsMethodEnum[VehicleClaimDetailsMethodEnum["LOGBOOK"] = 2] = "LOGBOOK";
|
|
6343
|
+
})(exports.VehicleClaimDetailsMethodEnum || (exports.VehicleClaimDetailsMethodEnum = {}));
|
|
6344
|
+
|
|
6345
|
+
var VehicleClaimDetails = /** @class */ (function (_super) {
|
|
6346
|
+
__extends(VehicleClaimDetails, _super);
|
|
6347
|
+
function VehicleClaimDetails() {
|
|
6348
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
6349
|
+
/**
|
|
6350
|
+
* Init default values for the new instances
|
|
6351
|
+
*/
|
|
6352
|
+
_this.isManual = true;
|
|
6353
|
+
_this.method = exports.VehicleClaimDetailsMethodEnum.KMS;
|
|
6354
|
+
_this.financialYear = new FinancialYear().year;
|
|
6355
|
+
return _this;
|
|
6356
|
+
}
|
|
6357
|
+
VehicleClaimDetails.prototype.isLogbookMethod = function () {
|
|
6358
|
+
return this.method === exports.VehicleClaimDetailsMethodEnum.LOGBOOK;
|
|
6467
6359
|
};
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
*/
|
|
6471
|
-
VehicleClaimCollection.prototype.getWorkUsageLimitForClaim = function (claim) {
|
|
6472
|
-
var collection = this;
|
|
6473
|
-
if (claim) {
|
|
6474
|
-
collection = collection.removeBy('id', claim.id);
|
|
6475
|
-
}
|
|
6476
|
-
return VehicleClaim.totalWorkUsagePercent - collection.sumBy('workUsage');
|
|
6360
|
+
VehicleClaimDetails.prototype.isKmsMethod = function () {
|
|
6361
|
+
return this.method === exports.VehicleClaimDetailsMethodEnum.KMS;
|
|
6477
6362
|
};
|
|
6478
|
-
return
|
|
6479
|
-
}(
|
|
6363
|
+
return VehicleClaimDetails;
|
|
6364
|
+
}(VehicleClaimDetails$1));
|
|
6365
|
+
__decorate([
|
|
6366
|
+
classTransformer.Type(function () { return User; })
|
|
6367
|
+
], VehicleClaimDetails.prototype, "user", void 0);
|
|
6480
6368
|
|
|
6481
|
-
var
|
|
6482
|
-
__extends(
|
|
6483
|
-
function
|
|
6484
|
-
|
|
6369
|
+
var VehicleClaim = /** @class */ (function (_super) {
|
|
6370
|
+
__extends(VehicleClaim, _super);
|
|
6371
|
+
function VehicleClaim() {
|
|
6372
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
6373
|
+
_this.kilometers = 0;
|
|
6374
|
+
_this.workUsage = 0;
|
|
6375
|
+
return _this;
|
|
6485
6376
|
}
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
* @TODO Vik: Best period: move this and related logic to backend
|
|
6489
|
-
*/
|
|
6490
|
-
VehicleLogbookCollection.prototype.isBestPeriodExist = function () {
|
|
6491
|
-
if (this.items.length < 2) {
|
|
6492
|
-
return false;
|
|
6493
|
-
}
|
|
6494
|
-
return VehicleLogbook.bestPeriodDuration < (this.last.date.getTime() - this.first.date.getTime());
|
|
6495
|
-
};
|
|
6496
|
-
/**
|
|
6497
|
-
* Get collection of non-personal logbooks (work-related, sole-related).
|
|
6498
|
-
* @TODO Vik: Best period: move this and related logic to backend
|
|
6499
|
-
*/
|
|
6500
|
-
VehicleLogbookCollection.prototype.getClaimableLogbooks = function () {
|
|
6501
|
-
return this.filterBy('isPersonal', false);
|
|
6377
|
+
VehicleClaim.prototype.isWorkTank = function () {
|
|
6378
|
+
return !this.business;
|
|
6502
6379
|
};
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
* Best period duration is defined as VehicleLogbook.bestPeriodWeeks by the ATO
|
|
6506
|
-
* @TODO Vik: Best period: move this and related logic to backend
|
|
6507
|
-
*/
|
|
6508
|
-
VehicleLogbookCollection.prototype.getBestPeriod = function () {
|
|
6509
|
-
if (!this.isBestPeriodExist()) {
|
|
6510
|
-
return null;
|
|
6511
|
-
}
|
|
6512
|
-
var bestPeriod;
|
|
6513
|
-
// get list of all logbooks available for best period calculation
|
|
6514
|
-
var claimableLogbooks = this.getClaimableLogbooks().toArray();
|
|
6515
|
-
for (var i = 0; i < claimableLogbooks.length; i++) {
|
|
6516
|
-
// no sense to check next logbooks because we already get the end of the year
|
|
6517
|
-
if (bestPeriod && bestPeriod.isEndOfYear()) {
|
|
6518
|
-
break;
|
|
6519
|
-
}
|
|
6520
|
-
// get date range started from current handling logbook date
|
|
6521
|
-
var dateRange = claimableLogbooks[i].getPeriod();
|
|
6522
|
-
// get all logbooks included in current logbook period
|
|
6523
|
-
var logbooksInRange = this.filterByRange('date', dateRange.start, dateRange.end);
|
|
6524
|
-
var currentPeriod = classTransformer.plainToClass(LogbookPeriod, {
|
|
6525
|
-
from: dateRange.start,
|
|
6526
|
-
to: dateRange.end,
|
|
6527
|
-
kilometers: logbooksInRange.getClaimableLogbooks().kilometers,
|
|
6528
|
-
workUsage: logbooksInRange.getWorkUsage(),
|
|
6529
|
-
logbooks: logbooksInRange
|
|
6530
|
-
});
|
|
6531
|
-
// compare with previous best period and overwrite if needs
|
|
6532
|
-
if (!bestPeriod || currentPeriod.workUsage > bestPeriod.workUsage) {
|
|
6533
|
-
bestPeriod = currentPeriod;
|
|
6534
|
-
}
|
|
6535
|
-
else if (currentPeriod.workUsage === bestPeriod.workUsage) {
|
|
6536
|
-
// if work usage is the same then get period with the biggest work usage for work tank
|
|
6537
|
-
var oldWorkUsage = bestPeriod.logbooks.filterBy('tankType', exports.TankTypeEnum.WORK).getWorkUsage();
|
|
6538
|
-
var currentWorkUsage = currentPeriod.logbooks.filterBy('tankType', exports.TankTypeEnum.WORK).getWorkUsage();
|
|
6539
|
-
if (oldWorkUsage < currentWorkUsage) {
|
|
6540
|
-
bestPeriod = currentPeriod;
|
|
6541
|
-
}
|
|
6542
|
-
}
|
|
6543
|
-
}
|
|
6544
|
-
return bestPeriod;
|
|
6380
|
+
VehicleClaim.prototype.isSoleTank = function () {
|
|
6381
|
+
return !!this.business;
|
|
6545
6382
|
};
|
|
6546
|
-
Object.defineProperty(
|
|
6547
|
-
/**
|
|
6548
|
-
* Calculate total kilometers traveled
|
|
6549
|
-
*/
|
|
6383
|
+
Object.defineProperty(VehicleClaim.prototype, "tankType", {
|
|
6550
6384
|
get: function () {
|
|
6551
|
-
return this.
|
|
6385
|
+
return this.isSoleTank() ? exports.TankTypeEnum.SOLE : exports.TankTypeEnum.WORK;
|
|
6552
6386
|
},
|
|
6553
6387
|
enumerable: false,
|
|
6554
6388
|
configurable: true
|
|
6555
6389
|
});
|
|
6556
6390
|
/**
|
|
6557
|
-
*
|
|
6558
|
-
* @TODO Alex: TT-2089 replace with getter
|
|
6391
|
+
* Claim amount for KMs method. Exists only for KMs method.
|
|
6559
6392
|
*/
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
return Math.round(workKilometers / this.kilometers * 100);
|
|
6393
|
+
VehicleClaim.prototype.getKMSClaimAmount = function (vehicleClaimRate) {
|
|
6394
|
+
return +(this.kilometers * vehicleClaimRate).toFixed(2);
|
|
6563
6395
|
};
|
|
6564
6396
|
/**
|
|
6565
|
-
* Get
|
|
6397
|
+
* Get logbook claim amount. Exists only for logbook method.
|
|
6398
|
+
* ClaimAmount = WorkUsage * transaction/depreciation amount
|
|
6566
6399
|
*/
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6400
|
+
VehicleClaim.prototype.getLogbookClaimAmount = function (transactions) {
|
|
6401
|
+
var transactionsAmount = transactions
|
|
6402
|
+
.getByVehicleClaim(this)
|
|
6403
|
+
.getLogbookTransactions()
|
|
6404
|
+
.sumBy('amount');
|
|
6405
|
+
// Math.abs because amount will be negative (because we sum expenses), but we don't want negative percent value
|
|
6406
|
+
return Math.abs(transactionsAmount) * this.workUsage / 100;
|
|
6573
6407
|
};
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6408
|
+
VehicleClaim.prototype.getAverageWeeklyKMS = function () {
|
|
6409
|
+
return this.kilometers / FinancialYear.weeksInYear;
|
|
6410
|
+
};
|
|
6411
|
+
VehicleClaim.getKMSChartAccountsIdByTankType = function (tankType) {
|
|
6412
|
+
return tankType === exports.TankTypeEnum.WORK
|
|
6413
|
+
? exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK
|
|
6414
|
+
: exports.ChartAccountsListEnum.KLMS_TRAVELLED;
|
|
6415
|
+
};
|
|
6416
|
+
return VehicleClaim;
|
|
6417
|
+
}(VehicleClaim$1));
|
|
6577
6418
|
/**
|
|
6578
|
-
*
|
|
6419
|
+
* limit for kms claim method
|
|
6579
6420
|
*/
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6421
|
+
VehicleClaim.totalKmsLimit = 5000;
|
|
6422
|
+
/**
|
|
6423
|
+
* limit for work usage claim method
|
|
6424
|
+
*/
|
|
6425
|
+
VehicleClaim.totalWorkUsagePercent = 100;
|
|
6426
|
+
__decorate([
|
|
6427
|
+
classTransformer.Type(function () { return VehicleClaimDetails; })
|
|
6428
|
+
], VehicleClaim.prototype, "details", void 0);
|
|
6429
|
+
__decorate([
|
|
6430
|
+
classTransformer.Type(function () { return SoleBusiness; })
|
|
6431
|
+
], VehicleClaim.prototype, "business", void 0);
|
|
6432
|
+
|
|
6433
|
+
var SoleBusinessActivity$1 = /** @class */ (function (_super) {
|
|
6434
|
+
__extends(SoleBusinessActivity, _super);
|
|
6435
|
+
function SoleBusinessActivity() {
|
|
6436
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6592
6437
|
}
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6438
|
+
return SoleBusinessActivity;
|
|
6439
|
+
}(AbstractModel));
|
|
6440
|
+
|
|
6441
|
+
var SoleBusiness = /** @class */ (function (_super) {
|
|
6442
|
+
__extends(SoleBusiness, _super);
|
|
6443
|
+
function SoleBusiness() {
|
|
6444
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6445
|
+
}
|
|
6446
|
+
SoleBusiness.prototype.getPhotoPlaceholder = function () {
|
|
6447
|
+
return "" + this.name[0] + this.name[1];
|
|
6598
6448
|
};
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
items.forEach(function (item) {
|
|
6602
|
-
var key = get__default["default"](item, path);
|
|
6603
|
-
// if object does not have property for grouping it will be grouped as 'other'
|
|
6604
|
-
if (key === undefined) {
|
|
6605
|
-
key = 'other';
|
|
6606
|
-
}
|
|
6607
|
-
_this.items[key] = item;
|
|
6608
|
-
});
|
|
6449
|
+
SoleBusiness.prototype.getPhoto = function () {
|
|
6450
|
+
return this.logo;
|
|
6609
6451
|
};
|
|
6610
|
-
return
|
|
6611
|
-
}());
|
|
6452
|
+
return SoleBusiness;
|
|
6453
|
+
}(SoleBusiness$1));
|
|
6454
|
+
/**
|
|
6455
|
+
* Maximum number of businesses that a person can have, according to the ATO
|
|
6456
|
+
*/
|
|
6457
|
+
SoleBusiness.businessesLimit = 6;
|
|
6458
|
+
__decorate([
|
|
6459
|
+
classTransformer.Type(function () { return User; })
|
|
6460
|
+
], SoleBusiness.prototype, "user", void 0);
|
|
6461
|
+
__decorate([
|
|
6462
|
+
classTransformer.Type(function () { return SoleBusinessAllocation; })
|
|
6463
|
+
], SoleBusiness.prototype, "allocations", void 0);
|
|
6464
|
+
__decorate([
|
|
6465
|
+
classTransformer.Type(function () { return SoleBusinessLoss; })
|
|
6466
|
+
], SoleBusiness.prototype, "losses", void 0);
|
|
6467
|
+
__decorate([
|
|
6468
|
+
classTransformer.Type(function () { return SoleInvoice; })
|
|
6469
|
+
], SoleBusiness.prototype, "invoices", void 0);
|
|
6470
|
+
__decorate([
|
|
6471
|
+
classTransformer.Type(function () { return SoleInvoiceTemplate; })
|
|
6472
|
+
], SoleBusiness.prototype, "invoiceTemplates", void 0);
|
|
6473
|
+
__decorate([
|
|
6474
|
+
classTransformer.Type(function () { return VehicleClaim; })
|
|
6475
|
+
], SoleBusiness.prototype, "vehicleClaims", void 0);
|
|
6476
|
+
__decorate([
|
|
6477
|
+
classTransformer.Type(function () { return Transaction; })
|
|
6478
|
+
], SoleBusiness.prototype, "transactions", void 0);
|
|
6479
|
+
__decorate([
|
|
6480
|
+
classTransformer.Type(function () { return Depreciation; })
|
|
6481
|
+
], SoleBusiness.prototype, "depreciations", void 0);
|
|
6482
|
+
__decorate([
|
|
6483
|
+
classTransformer.Type(function () { return SoleBusinessActivity$1; })
|
|
6484
|
+
], SoleBusiness.prototype, "activity", void 0);
|
|
6485
|
+
__decorate([
|
|
6486
|
+
classTransformer.Type(function () { return IncomeSource; })
|
|
6487
|
+
], SoleBusiness.prototype, "incomeSource", void 0);
|
|
6488
|
+
|
|
6489
|
+
var SoleBusinessActivity = /** @class */ (function (_super) {
|
|
6490
|
+
__extends(SoleBusinessActivity, _super);
|
|
6491
|
+
function SoleBusinessActivity() {
|
|
6492
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6493
|
+
}
|
|
6494
|
+
return SoleBusinessActivity;
|
|
6495
|
+
}(SoleBusinessActivity$1));
|
|
6496
|
+
|
|
6497
|
+
var SoleDepreciationMethod$1 = /** @class */ (function (_super) {
|
|
6498
|
+
__extends(SoleDepreciationMethod, _super);
|
|
6499
|
+
function SoleDepreciationMethod() {
|
|
6500
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6501
|
+
}
|
|
6502
|
+
return SoleDepreciationMethod;
|
|
6503
|
+
}(AbstractModel));
|
|
6504
|
+
|
|
6505
|
+
exports.SoleDepreciationMethodEnum = void 0;
|
|
6506
|
+
(function (SoleDepreciationMethodEnum) {
|
|
6507
|
+
SoleDepreciationMethodEnum[SoleDepreciationMethodEnum["SBP"] = 1] = "SBP";
|
|
6508
|
+
SoleDepreciationMethodEnum[SoleDepreciationMethodEnum["DEPRECIATION"] = 2] = "DEPRECIATION";
|
|
6509
|
+
})(exports.SoleDepreciationMethodEnum || (exports.SoleDepreciationMethodEnum = {}));
|
|
6612
6510
|
|
|
6613
|
-
var
|
|
6614
|
-
__extends(
|
|
6615
|
-
function
|
|
6511
|
+
var SoleDepreciationMethod = /** @class */ (function (_super) {
|
|
6512
|
+
__extends(SoleDepreciationMethod, _super);
|
|
6513
|
+
function SoleDepreciationMethod() {
|
|
6616
6514
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
6617
6515
|
}
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
*/
|
|
6621
|
-
SoleBusinessLossesCollection.prototype.calculateBusinessLossApplied = function (transactions) {
|
|
6622
|
-
var _this = this;
|
|
6623
|
-
// claim amounts for businesses that can be applied to be reduced by prior year business losses
|
|
6624
|
-
var claimAmountsByBusinessId = this.getClaimAmountsByBusinessId(transactions);
|
|
6625
|
-
return Object.keys(claimAmountsByBusinessId.items).reduce(function (sum, businessId) {
|
|
6626
|
-
var loss = _this.findBy('business.id', +businessId);
|
|
6627
|
-
var lossOpenBalance = (loss === null || loss === void 0 ? void 0 : loss.openBalance) || 0;
|
|
6628
|
-
// business loss can be applied to business profit or other income types profit in case in offset rule met
|
|
6629
|
-
return sum + ((loss === null || loss === void 0 ? void 0 : loss.offsetRule) ? lossOpenBalance : Math.min(lossOpenBalance, claimAmountsByBusinessId.get(businessId)));
|
|
6630
|
-
}, 0);
|
|
6631
|
-
};
|
|
6632
|
-
/**
|
|
6633
|
-
* Get business claim amounts that can be applied to be reduced by prior year business losses:
|
|
6634
|
-
* businesses with income or businesses with a loss, but which met the non-commercial loss rules
|
|
6635
|
-
* https://www.ato.gov.au/Business/Non-commercial-losses/
|
|
6636
|
-
*/
|
|
6637
|
-
SoleBusinessLossesCollection.prototype.getClaimAmountsByBusinessId = function (transactions) {
|
|
6638
|
-
var _this = this;
|
|
6639
|
-
var claimAmountsByBusinessId = new Dictionary([]);
|
|
6640
|
-
var transactionsByBusinessId = new CollectionDictionary(transactions, 'business.id');
|
|
6641
|
-
transactionsByBusinessId.keys.forEach(function (businessId) {
|
|
6642
|
-
var _a;
|
|
6643
|
-
// business loss may not exist if, when creating a business, user didn't add losses for previous years
|
|
6644
|
-
var lossOffsetRule = (_a = _this.findBy('business.id', +businessId)) === null || _a === void 0 ? void 0 : _a.offsetRule;
|
|
6645
|
-
var businessClaimAmount = transactionsByBusinessId
|
|
6646
|
-
.get(businessId)
|
|
6647
|
-
.getClaimAmountByBusinessId(+businessId);
|
|
6648
|
-
// no way to apply loss for business without profit if offset rules not met
|
|
6649
|
-
if (businessClaimAmount < 0 && !lossOffsetRule) {
|
|
6650
|
-
return;
|
|
6651
|
-
}
|
|
6652
|
-
claimAmountsByBusinessId.add(businessId, businessClaimAmount);
|
|
6653
|
-
});
|
|
6654
|
-
return claimAmountsByBusinessId;
|
|
6516
|
+
SoleDepreciationMethod.prototype.isSBP = function () {
|
|
6517
|
+
return this.method === exports.SoleDepreciationMethodEnum.SBP;
|
|
6655
6518
|
};
|
|
6656
|
-
return
|
|
6657
|
-
}(
|
|
6519
|
+
return SoleDepreciationMethod;
|
|
6520
|
+
}(SoleDepreciationMethod$1));
|
|
6658
6521
|
|
|
6659
|
-
var
|
|
6660
|
-
__extends(
|
|
6661
|
-
function
|
|
6522
|
+
var SoleDetails$1 = /** @class */ (function (_super) {
|
|
6523
|
+
__extends(SoleDetails, _super);
|
|
6524
|
+
function SoleDetails() {
|
|
6662
6525
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
6663
6526
|
}
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
};
|
|
6667
|
-
SoleInvoiceCollection.prototype.getUnpaid = function () {
|
|
6668
|
-
return this.filter(function (invoice) { return invoice.isUnpaid(); });
|
|
6669
|
-
};
|
|
6670
|
-
SoleInvoiceCollection.prototype.getPaid = function () {
|
|
6671
|
-
return this.filter(function (invoice) { return invoice.isPaid(); });
|
|
6672
|
-
};
|
|
6673
|
-
SoleInvoiceCollection.prototype.getPending = function () {
|
|
6674
|
-
return this.filter(function (invoice) { return invoice.isPending(); });
|
|
6675
|
-
};
|
|
6676
|
-
SoleInvoiceCollection.prototype.getTransactionsIds = function () {
|
|
6677
|
-
return flatten__default["default"](this.items.map(function (invoice) { return invoice.getTransactionsIds(); }));
|
|
6678
|
-
};
|
|
6679
|
-
return SoleInvoiceCollection;
|
|
6680
|
-
}(Collection));
|
|
6681
|
-
|
|
6682
|
-
/**
|
|
6683
|
-
* Chart serie class: chart data item
|
|
6684
|
-
* @TODO consider rename to ChartSerieData
|
|
6685
|
-
*/
|
|
6686
|
-
var ChartSerie = /** @class */ (function () {
|
|
6687
|
-
function ChartSerie() {
|
|
6688
|
-
}
|
|
6689
|
-
return ChartSerie;
|
|
6690
|
-
}());
|
|
6527
|
+
return SoleDetails;
|
|
6528
|
+
}(AbstractModel));
|
|
6691
6529
|
|
|
6692
|
-
/**
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
var ChartData = /** @class */ (function () {
|
|
6697
|
-
function ChartData() {
|
|
6530
|
+
var SoleDetails = /** @class */ (function (_super) {
|
|
6531
|
+
__extends(SoleDetails, _super);
|
|
6532
|
+
function SoleDetails() {
|
|
6533
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6698
6534
|
}
|
|
6699
|
-
return
|
|
6700
|
-
}());
|
|
6535
|
+
return SoleDetails;
|
|
6536
|
+
}(SoleDetails$1));
|
|
6701
6537
|
__decorate([
|
|
6702
|
-
classTransformer.Type(function () { return
|
|
6703
|
-
],
|
|
6538
|
+
classTransformer.Type(function () { return User; })
|
|
6539
|
+
], SoleDetails.prototype, "user", void 0);
|
|
6704
6540
|
|
|
6705
|
-
var
|
|
6541
|
+
var BasReport$1 = /** @class */ (function (_super) {
|
|
6542
|
+
__extends(BasReport, _super);
|
|
6543
|
+
function BasReport() {
|
|
6544
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6545
|
+
}
|
|
6546
|
+
return BasReport;
|
|
6547
|
+
}(AbstractModel));
|
|
6706
6548
|
|
|
6707
|
-
/**
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
var TransactionCollection = /** @class */ (function (_super) {
|
|
6712
|
-
__extends(TransactionCollection, _super);
|
|
6713
|
-
/**
|
|
6714
|
-
* @TODO use TransactionBaseCollection instead
|
|
6715
|
-
* we use depreciations as expense transactions a lot
|
|
6716
|
-
*/
|
|
6717
|
-
function TransactionCollection(transactions, depreciations) {
|
|
6718
|
-
if (transactions === void 0) { transactions = []; }
|
|
6719
|
-
if (depreciations === void 0) { depreciations = []; }
|
|
6720
|
-
return _super.call(this, __spreadArray(__spreadArray([], __read(transactions)), __read(depreciations.map(function (depreciation) { return depreciation.toTransaction(); })))) || this;
|
|
6549
|
+
var BasReport = /** @class */ (function (_super) {
|
|
6550
|
+
__extends(BasReport, _super);
|
|
6551
|
+
function BasReport() {
|
|
6552
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6721
6553
|
}
|
|
6722
|
-
|
|
6723
|
-
return this.filter(function (transaction) { return transaction.isSoleTank(); });
|
|
6724
|
-
};
|
|
6725
|
-
Object.defineProperty(TransactionCollection.prototype, "amount", {
|
|
6554
|
+
Object.defineProperty(BasReport.prototype, "taxWithheldTotal", {
|
|
6726
6555
|
get: function () {
|
|
6727
|
-
return this.
|
|
6556
|
+
return this.taxWithheldSalary + this.taxWithheldNoABN;
|
|
6728
6557
|
},
|
|
6729
6558
|
enumerable: false,
|
|
6730
6559
|
configurable: true
|
|
6731
6560
|
});
|
|
6732
|
-
|
|
6733
|
-
* Difference between allocated amount and total amount
|
|
6734
|
-
*/
|
|
6735
|
-
TransactionCollection.prototype.getUnallocatedAmount = function (allocations) {
|
|
6736
|
-
return this.items.reduce(function (sum, transaction) {
|
|
6737
|
-
return sum + transaction.getUnallocatedAmount(allocations.filterBy('transaction.id', transaction.id));
|
|
6738
|
-
}, 0);
|
|
6739
|
-
};
|
|
6740
|
-
/**
|
|
6741
|
-
* get date of the last transaction
|
|
6742
|
-
*/
|
|
6743
|
-
TransactionCollection.prototype.getLastTransactionDate = function () {
|
|
6744
|
-
return new Date(Math.max.apply(Math, this.items.map(function (transaction) { return transaction.date; })));
|
|
6745
|
-
};
|
|
6746
|
-
Object.defineProperty(TransactionCollection.prototype, "claimAmount", {
|
|
6561
|
+
Object.defineProperty(BasReport.prototype, "paygTaxInstalmentOwedToATO", {
|
|
6747
6562
|
get: function () {
|
|
6748
|
-
return this.
|
|
6563
|
+
return this.paygTaxInstalment > 0 ? this.paygTaxInstalment : 0;
|
|
6749
6564
|
},
|
|
6750
6565
|
enumerable: false,
|
|
6751
6566
|
configurable: true
|
|
6752
6567
|
});
|
|
6753
|
-
Object.defineProperty(
|
|
6568
|
+
Object.defineProperty(BasReport.prototype, "paygTaxInstalmentOwedByATO", {
|
|
6754
6569
|
get: function () {
|
|
6755
|
-
return this.
|
|
6570
|
+
return this.paygTaxInstalment < 0 ? Math.abs(this.paygTaxInstalment) : 0;
|
|
6756
6571
|
},
|
|
6757
6572
|
enumerable: false,
|
|
6758
6573
|
configurable: true
|
|
6759
6574
|
});
|
|
6760
|
-
Object.defineProperty(
|
|
6575
|
+
Object.defineProperty(BasReport.prototype, "fuelTaxCreditOwedToATO", {
|
|
6761
6576
|
get: function () {
|
|
6762
|
-
return this.
|
|
6577
|
+
return this.fuelTaxCredit < 0 ? this.fuelTaxCredit : 0;
|
|
6763
6578
|
},
|
|
6764
6579
|
enumerable: false,
|
|
6765
6580
|
configurable: true
|
|
6766
6581
|
});
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
}
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6582
|
+
Object.defineProperty(BasReport.prototype, "fuelTaxCreditOwedByATO", {
|
|
6583
|
+
get: function () {
|
|
6584
|
+
return this.fuelTaxCredit > 0 ? Math.abs(this.fuelTaxCredit) : 0;
|
|
6585
|
+
},
|
|
6586
|
+
enumerable: false,
|
|
6587
|
+
configurable: true
|
|
6588
|
+
});
|
|
6589
|
+
Object.defineProperty(BasReport.prototype, "owesToATO", {
|
|
6590
|
+
get: function () {
|
|
6591
|
+
return this.incomeGST + this.taxWithheldTotal + this.paygTaxInstalmentOwedToATO + this.fuelTaxCreditOwedToATO;
|
|
6592
|
+
},
|
|
6593
|
+
enumerable: false,
|
|
6594
|
+
configurable: true
|
|
6595
|
+
});
|
|
6596
|
+
Object.defineProperty(BasReport.prototype, "owedByATO", {
|
|
6597
|
+
get: function () {
|
|
6598
|
+
return this.expenseGST + this.paygTaxInstalmentOwedByATO + this.fuelTaxCreditOwedByATO;
|
|
6599
|
+
},
|
|
6600
|
+
enumerable: false,
|
|
6601
|
+
configurable: true
|
|
6602
|
+
});
|
|
6603
|
+
Object.defineProperty(BasReport.prototype, "gst", {
|
|
6604
|
+
/**
|
|
6605
|
+
* GST payable to the ATO, or refundable from the ATO in case it's negative
|
|
6606
|
+
*/
|
|
6607
|
+
get: function () {
|
|
6608
|
+
return this.incomeGST + this.expenseGST + this.taxWithheldTotal + this.paygTaxInstalment - this.fuelTaxCredit;
|
|
6609
|
+
},
|
|
6610
|
+
enumerable: false,
|
|
6611
|
+
configurable: true
|
|
6612
|
+
});
|
|
6613
|
+
return BasReport;
|
|
6614
|
+
}(BasReport$1));
|
|
6615
|
+
__decorate([
|
|
6616
|
+
classTransformer.Type(function () { return Date; })
|
|
6617
|
+
], BasReport.prototype, "dateFrom", void 0);
|
|
6618
|
+
__decorate([
|
|
6619
|
+
classTransformer.Type(function () { return Date; })
|
|
6620
|
+
], BasReport.prototype, "dateTo", void 0);
|
|
6621
|
+
|
|
6622
|
+
/**
|
|
6623
|
+
* role hierarchy
|
|
6624
|
+
*/
|
|
6625
|
+
var USER_ROLES = {
|
|
6626
|
+
ROLE_FIRM_OWNER: [exports.UserRolesEnum.FIRM_OWNER, exports.UserRolesEnum.FIRM_MANAGER, exports.UserRolesEnum.ACCOUNTANT, exports.UserRolesEnum.ADVISOR],
|
|
6627
|
+
ROLE_FIRM_MANAGER: [exports.UserRolesEnum.FIRM_MANAGER, exports.UserRolesEnum.ACCOUNTANT, exports.UserRolesEnum.ADVISOR],
|
|
6628
|
+
ROLE_EMPLOYEE: [exports.UserRolesEnum.ACCOUNTANT, exports.UserRolesEnum.ADVISOR],
|
|
6629
|
+
ROLE_ACCOUNTANT: [exports.UserRolesEnum.ACCOUNTANT],
|
|
6630
|
+
ROLE_ADVISOR: [exports.UserRolesEnum.ADVISOR],
|
|
6631
|
+
ROLE_CLIENT: [exports.UserRolesEnum.CLIENT],
|
|
6632
|
+
ROLE_USER_SUBSCRIPTION: [exports.UserRolesEnum.SUBSCRIPTION],
|
|
6633
|
+
ROLE_USER_WORK: [exports.UserRolesEnum.WORK_TANK],
|
|
6634
|
+
ROLE_USER_PROPERTY: [exports.UserRolesEnum.PROPERTY_TANK],
|
|
6635
|
+
ROLE_USER_SOLE: [exports.UserRolesEnum.SOLE_TANK],
|
|
6636
|
+
};
|
|
6637
|
+
|
|
6638
|
+
var User = /** @class */ (function (_super) {
|
|
6639
|
+
__extends(User, _super);
|
|
6640
|
+
function User() {
|
|
6641
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6642
|
+
}
|
|
6643
|
+
Object.defineProperty(User.prototype, "fullName", {
|
|
6644
|
+
get: function () {
|
|
6645
|
+
return this.firstName + " " + this.lastName;
|
|
6646
|
+
},
|
|
6647
|
+
enumerable: false,
|
|
6648
|
+
configurable: true
|
|
6649
|
+
});
|
|
6650
|
+
Object.defineProperty(User.prototype, "activeSubscription", {
|
|
6794
6651
|
get: function () {
|
|
6795
|
-
return this.
|
|
6652
|
+
return this.subscriptions.find(function (ss) { return ss.isActive; });
|
|
6796
6653
|
},
|
|
6797
6654
|
enumerable: false,
|
|
6798
6655
|
configurable: true
|
|
6799
6656
|
});
|
|
6800
|
-
Object.defineProperty(
|
|
6657
|
+
Object.defineProperty(User.prototype, "lastSubscription", {
|
|
6801
6658
|
get: function () {
|
|
6802
|
-
return this.
|
|
6659
|
+
return this.subscriptions[this.subscriptions.length - 1];
|
|
6803
6660
|
},
|
|
6804
6661
|
enumerable: false,
|
|
6805
6662
|
configurable: true
|
|
6806
6663
|
});
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6664
|
+
Object.defineProperty(User.prototype, "position", {
|
|
6665
|
+
/**
|
|
6666
|
+
* @TODO refactor
|
|
6667
|
+
*
|
|
6668
|
+
*/
|
|
6811
6669
|
get: function () {
|
|
6812
|
-
|
|
6670
|
+
switch (true) {
|
|
6671
|
+
case this.isFirmOwner():
|
|
6672
|
+
return USER_WORK_POSITION[exports.UserRolesEnum.FIRM_OWNER];
|
|
6673
|
+
case this.isManager():
|
|
6674
|
+
return USER_WORK_POSITION[exports.UserRolesEnum.FIRM_MANAGER];
|
|
6675
|
+
case this.isEmployee():
|
|
6676
|
+
return USER_WORK_POSITION[exports.UserRolesEnum.EMPLOYEE];
|
|
6677
|
+
default:
|
|
6678
|
+
return '';
|
|
6679
|
+
}
|
|
6813
6680
|
},
|
|
6814
6681
|
enumerable: false,
|
|
6815
6682
|
configurable: true
|
|
6816
6683
|
});
|
|
6817
6684
|
/**
|
|
6818
|
-
*
|
|
6819
|
-
* @param ids Ids of properties for filter
|
|
6685
|
+
* search roles including hierarchy
|
|
6820
6686
|
*/
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
return
|
|
6825
|
-
}
|
|
6687
|
+
User.prototype.hasRoles = function (roles) {
|
|
6688
|
+
roles = roles instanceof Array ? roles : [roles];
|
|
6689
|
+
if (!roles.length) {
|
|
6690
|
+
return true;
|
|
6691
|
+
}
|
|
6692
|
+
roles = flatten__default["default"](roles.map(function (role) { return USER_ROLES[role]; }));
|
|
6693
|
+
return !!intersection__default["default"](this.roles, roles).length;
|
|
6826
6694
|
};
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
* @param id id of income source for filter
|
|
6830
|
-
*/
|
|
6831
|
-
TransactionCollection.prototype.getByIncomeSourceId = function (id) {
|
|
6832
|
-
return new TransactionCollection(this.items.filter(function (transaction) { var _a; return ((_a = transaction.incomeSource) === null || _a === void 0 ? void 0 : _a.id) === id; }));
|
|
6695
|
+
User.prototype.isOnboarding = function () {
|
|
6696
|
+
return this.status === exports.UserStatusEnum.ON_BOARDING;
|
|
6833
6697
|
};
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
* @param category Chart accounts category value
|
|
6837
|
-
*/
|
|
6838
|
-
TransactionCollection.prototype.getByChartAccountsCategory = function (category) {
|
|
6839
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.chartAccounts.category === category; }));
|
|
6698
|
+
User.prototype.hasSubscription = function () {
|
|
6699
|
+
return this.roles.includes(exports.UserRolesEnum.SUBSCRIPTION);
|
|
6840
6700
|
};
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
*/
|
|
6844
|
-
TransactionCollection.prototype.getPropertyTransactions = function () {
|
|
6845
|
-
return new TransactionCollection(this.items.filter(function (transaction) { return transaction.isPropertyTank(); }));
|
|
6701
|
+
User.prototype.isLoggedIn = function () {
|
|
6702
|
+
return this.id === +localStorage.getItem('userId');
|
|
6846
6703
|
};
|
|
6847
|
-
|
|
6848
|
-
return
|
|
6704
|
+
User.prototype.isClient = function () {
|
|
6705
|
+
return this.roles.includes(exports.UserRolesEnum.CLIENT);
|
|
6849
6706
|
};
|
|
6850
|
-
|
|
6851
|
-
return
|
|
6707
|
+
User.prototype.isEmployee = function () {
|
|
6708
|
+
return this.isAccountant() || this.isAdvisor();
|
|
6852
6709
|
};
|
|
6853
|
-
|
|
6854
|
-
return
|
|
6710
|
+
User.prototype.isAccountant = function () {
|
|
6711
|
+
return this.roles.includes(exports.UserRolesEnum.ACCOUNTANT);
|
|
6712
|
+
};
|
|
6713
|
+
User.prototype.isAdvisor = function () {
|
|
6714
|
+
return this.roles.includes(exports.UserRolesEnum.ADVISOR);
|
|
6715
|
+
};
|
|
6716
|
+
User.prototype.isImpersonator = function () {
|
|
6717
|
+
return this.roles.includes(exports.UserRolesEnum.SWITCH_USER);
|
|
6855
6718
|
};
|
|
6856
6719
|
/**
|
|
6857
|
-
*
|
|
6720
|
+
* Check if current user is firm owner
|
|
6858
6721
|
*/
|
|
6859
|
-
|
|
6860
|
-
return this.
|
|
6861
|
-
return transaction.isVehicleTransaction();
|
|
6862
|
-
}));
|
|
6722
|
+
User.prototype.isFirmOwner = function () {
|
|
6723
|
+
return this.roles.includes(exports.UserRolesEnum.FIRM_OWNER);
|
|
6863
6724
|
};
|
|
6864
6725
|
/**
|
|
6865
|
-
*
|
|
6726
|
+
* Check if current user is firm manager
|
|
6866
6727
|
*/
|
|
6867
|
-
|
|
6868
|
-
return this.
|
|
6869
|
-
switch (tankType) {
|
|
6870
|
-
case exports.TankTypeEnum.PROPERTY:
|
|
6871
|
-
return transaction.isPropertyTank();
|
|
6872
|
-
case exports.TankTypeEnum.WORK:
|
|
6873
|
-
return transaction.isWorkTank();
|
|
6874
|
-
case exports.TankTypeEnum.SOLE:
|
|
6875
|
-
return transaction.isSoleTank();
|
|
6876
|
-
// Transaction may be not related to any tank type (personal)
|
|
6877
|
-
default:
|
|
6878
|
-
return false;
|
|
6879
|
-
}
|
|
6880
|
-
}));
|
|
6881
|
-
};
|
|
6882
|
-
TransactionCollection.prototype.getExportHeader = function () {
|
|
6883
|
-
return ['Date', 'Description', 'Debit', 'Credit'];
|
|
6728
|
+
User.prototype.isManager = function () {
|
|
6729
|
+
return this.roles.includes(exports.UserRolesEnum.FIRM_MANAGER) || this.roles.includes(exports.UserRolesEnum.FIRM_OWNER);
|
|
6884
6730
|
};
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6731
|
+
/**
|
|
6732
|
+
* check if user has property tank access
|
|
6733
|
+
*/
|
|
6734
|
+
User.prototype.hasPropertyTank = function () {
|
|
6735
|
+
return this.roles ?
|
|
6736
|
+
this.roles.includes(exports.UserRolesEnum.PROPERTY_TANK) :
|
|
6737
|
+
!!this.getSubscriptionRole(exports.UserRolesEnum.PROPERTY_TANK);
|
|
6892
6738
|
};
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
];
|
|
6901
|
-
});
|
|
6739
|
+
/**
|
|
6740
|
+
* check if user has property tank access
|
|
6741
|
+
*/
|
|
6742
|
+
User.prototype.hasWorkTank = function () {
|
|
6743
|
+
return this.roles ?
|
|
6744
|
+
this.roles.includes(exports.UserRolesEnum.WORK_TANK) :
|
|
6745
|
+
!!this.getSubscriptionRole(exports.UserRolesEnum.WORK_TANK);
|
|
6902
6746
|
};
|
|
6903
6747
|
/**
|
|
6904
|
-
* Get
|
|
6748
|
+
* Get user subscription role by provided role type
|
|
6749
|
+
* @param roleType by which role should be returned
|
|
6905
6750
|
*/
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
? this.getVehicleTransactions().filterBy('business.id', vehicleClaim.business.id)
|
|
6913
|
-
// work tank may have only one vehicle claim, so we need to filter by tank type
|
|
6914
|
-
: this.getVehicleTransactions().filterBy('tankType', exports.TankTypeEnum.WORK);
|
|
6751
|
+
User.prototype.getSubscriptionRole = function (roleType) {
|
|
6752
|
+
var _a;
|
|
6753
|
+
/**
|
|
6754
|
+
* Add @TODO for Alex to check if we should use getLastSubscription here
|
|
6755
|
+
*/
|
|
6756
|
+
return (_a = this.activeSubscription) === null || _a === void 0 ? void 0 : _a.items.find(function (subscriptionItem) { return subscriptionItem.price.product.role.includes(roleType); });
|
|
6915
6757
|
};
|
|
6916
6758
|
/**
|
|
6917
|
-
* Get
|
|
6759
|
+
* Get user's photo link
|
|
6918
6760
|
*/
|
|
6919
|
-
|
|
6920
|
-
return this
|
|
6921
|
-
.getVehicleTransactions()
|
|
6922
|
-
.removeBy('chartAccounts.id', [exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK, exports.ChartAccountsListEnum.KLMS_TRAVELLED]);
|
|
6761
|
+
User.prototype.getPhoto = function () {
|
|
6762
|
+
return this.photo;
|
|
6923
6763
|
};
|
|
6924
6764
|
/**
|
|
6925
|
-
*
|
|
6926
|
-
* Cash position = Income - Expenses (include depreciations)
|
|
6927
|
-
* Chart data for each month from fin year start till current month
|
|
6765
|
+
* get user's initials
|
|
6928
6766
|
*/
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6767
|
+
User.prototype.getPhotoPlaceholder = function () {
|
|
6768
|
+
return "" + this.firstName[0].toUpperCase() + this.lastName[0].toUpperCase();
|
|
6769
|
+
};
|
|
6770
|
+
return User;
|
|
6771
|
+
}(User$1));
|
|
6772
|
+
__decorate([
|
|
6773
|
+
classTransformer.Type(function () { return ServiceSubscription; })
|
|
6774
|
+
], User.prototype, "subscriptions", void 0);
|
|
6775
|
+
__decorate([
|
|
6776
|
+
classTransformer.Type(function () { return ClientDetails; })
|
|
6777
|
+
], User.prototype, "clientDetails", void 0);
|
|
6778
|
+
__decorate([
|
|
6779
|
+
classTransformer.Type(function () { return EmployeeDetails; })
|
|
6780
|
+
], User.prototype, "employeeDetails", void 0);
|
|
6781
|
+
__decorate([
|
|
6782
|
+
classTransformer.Type(function () { return SoleDetails; })
|
|
6783
|
+
], User.prototype, "soleDetails", void 0);
|
|
6784
|
+
__decorate([
|
|
6785
|
+
classTransformer.Type(function () { return Address; })
|
|
6786
|
+
], User.prototype, "address", void 0);
|
|
6787
|
+
__decorate([
|
|
6788
|
+
classTransformer.Type(function () { return Phone; })
|
|
6789
|
+
], User.prototype, "phone", void 0);
|
|
6790
|
+
__decorate([
|
|
6791
|
+
classTransformer.Type(function () { return Date; })
|
|
6792
|
+
], User.prototype, "createdAt", void 0);
|
|
6793
|
+
__decorate([
|
|
6794
|
+
classTransformer.Type(function () { return User; })
|
|
6795
|
+
], User.prototype, "clients", void 0);
|
|
6796
|
+
|
|
6797
|
+
var PropertySubscription = /** @class */ (function (_super) {
|
|
6798
|
+
__extends(PropertySubscription, _super);
|
|
6799
|
+
function PropertySubscription() {
|
|
6800
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6801
|
+
}
|
|
6802
|
+
return PropertySubscription;
|
|
6803
|
+
}(PropertySubscription$1));
|
|
6804
|
+
__decorate([
|
|
6805
|
+
classTransformer.Type(function () { return Date; })
|
|
6806
|
+
], PropertySubscription.prototype, "createdAt", void 0);
|
|
6807
|
+
__decorate([
|
|
6808
|
+
classTransformer.Type(function () { return User; })
|
|
6809
|
+
], PropertySubscription.prototype, "user", void 0);
|
|
6810
|
+
|
|
6811
|
+
var PropertyCategory$1 = /** @class */ (function (_super) {
|
|
6812
|
+
__extends(PropertyCategory, _super);
|
|
6813
|
+
function PropertyCategory() {
|
|
6814
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6815
|
+
}
|
|
6816
|
+
return PropertyCategory;
|
|
6817
|
+
}(AbstractModel));
|
|
6818
|
+
|
|
6819
|
+
exports.PropertyCategoryListEnum = void 0;
|
|
6820
|
+
(function (PropertyCategoryListEnum) {
|
|
6821
|
+
PropertyCategoryListEnum[PropertyCategoryListEnum["OWNER_OCCUPIED"] = 3] = "OWNER_OCCUPIED";
|
|
6822
|
+
PropertyCategoryListEnum[PropertyCategoryListEnum["SHARED"] = 4] = "SHARED";
|
|
6823
|
+
PropertyCategoryListEnum[PropertyCategoryListEnum["VACANT_LAND"] = 5] = "VACANT_LAND";
|
|
6824
|
+
})(exports.PropertyCategoryListEnum || (exports.PropertyCategoryListEnum = {}));
|
|
6825
|
+
|
|
6826
|
+
var PropertyCategory = /** @class */ (function (_super) {
|
|
6827
|
+
__extends(PropertyCategory, _super);
|
|
6828
|
+
function PropertyCategory() {
|
|
6829
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6830
|
+
}
|
|
6831
|
+
// @Todo check if category is Owner Occupied. If will be needed to check more categories - move the checking to the backend
|
|
6832
|
+
PropertyCategory.prototype.isOwnerOccupied = function () {
|
|
6833
|
+
return this.id === exports.PropertyCategoryListEnum.OWNER_OCCUPIED;
|
|
6834
|
+
};
|
|
6835
|
+
PropertyCategory.prototype.isVacantLand = function () {
|
|
6836
|
+
return this.id === exports.PropertyCategoryListEnum.VACANT_LAND;
|
|
6946
6837
|
};
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
*/
|
|
6950
|
-
TransactionCollection.prototype.calculateAllocatedClaimAmount = function (allocations) {
|
|
6951
|
-
var allocatedClaimAmount = 0;
|
|
6952
|
-
this.filterBy('isGST', true).toArray().forEach(function (transaction) {
|
|
6953
|
-
allocatedClaimAmount += transaction.getAllocatedClaimAmount(allocations);
|
|
6954
|
-
});
|
|
6955
|
-
return allocatedClaimAmount;
|
|
6838
|
+
PropertyCategory.prototype.isShared = function () {
|
|
6839
|
+
return this.id === exports.PropertyCategoryListEnum.SHARED;
|
|
6956
6840
|
};
|
|
6957
|
-
|
|
6958
|
-
|
|
6841
|
+
return PropertyCategory;
|
|
6842
|
+
}(PropertyCategory$1));
|
|
6843
|
+
|
|
6844
|
+
var PropertyValuation$1 = /** @class */ (function (_super) {
|
|
6845
|
+
__extends(PropertyValuation, _super);
|
|
6846
|
+
function PropertyValuation() {
|
|
6847
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6848
|
+
}
|
|
6849
|
+
return PropertyValuation;
|
|
6850
|
+
}(AbstractModel));
|
|
6851
|
+
|
|
6852
|
+
var PropertyDocument$1 = /** @class */ (function (_super) {
|
|
6853
|
+
__extends(PropertyDocument, _super);
|
|
6854
|
+
function PropertyDocument() {
|
|
6855
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6856
|
+
}
|
|
6857
|
+
PropertyDocument.prototype.getApiUrlPrefix = function () {
|
|
6858
|
+
return '';
|
|
6959
6859
|
};
|
|
6960
|
-
|
|
6961
|
-
return
|
|
6860
|
+
PropertyDocument.prototype.getEntity = function () {
|
|
6861
|
+
return undefined;
|
|
6962
6862
|
};
|
|
6963
|
-
return
|
|
6964
|
-
}(
|
|
6863
|
+
return PropertyDocument;
|
|
6864
|
+
}(AbstractModel));
|
|
6965
6865
|
|
|
6966
|
-
var
|
|
6967
|
-
__extends(
|
|
6968
|
-
function
|
|
6866
|
+
var PropertyDocument = /** @class */ (function (_super) {
|
|
6867
|
+
__extends(PropertyDocument, _super);
|
|
6868
|
+
function PropertyDocument() {
|
|
6869
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
6870
|
+
_this.type = exports.AssetTypeEnum.DOCUMENT;
|
|
6871
|
+
_this.entityType = exports.AssetEntityTypeEnum.PROPERTIES;
|
|
6872
|
+
return _this;
|
|
6873
|
+
}
|
|
6874
|
+
PropertyDocument.prototype.getApiUrlPrefix = function () {
|
|
6875
|
+
return '';
|
|
6876
|
+
};
|
|
6877
|
+
PropertyDocument.prototype.getEntity = function () {
|
|
6878
|
+
return this.property;
|
|
6879
|
+
};
|
|
6880
|
+
return PropertyDocument;
|
|
6881
|
+
}(PropertyDocument$1));
|
|
6882
|
+
|
|
6883
|
+
var PropertyValuation = /** @class */ (function (_super) {
|
|
6884
|
+
__extends(PropertyValuation, _super);
|
|
6885
|
+
function PropertyValuation() {
|
|
6969
6886
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
6970
6887
|
}
|
|
6971
|
-
Object.defineProperty(
|
|
6888
|
+
Object.defineProperty(PropertyValuation.prototype, "financialYear", {
|
|
6972
6889
|
get: function () {
|
|
6973
|
-
return this.
|
|
6890
|
+
return new FinancialYear(this.date).year;
|
|
6974
6891
|
},
|
|
6975
6892
|
enumerable: false,
|
|
6976
6893
|
configurable: true
|
|
6977
6894
|
});
|
|
6978
|
-
|
|
6979
|
-
return
|
|
6980
|
-
};
|
|
6981
|
-
TransactionAllocationCollection.prototype.getByBankTransactionsIds = function (ids) {
|
|
6982
|
-
return new TransactionAllocationCollection(this.items.filter(function (allocation) { return ids.includes(allocation.bankTransaction.id); }));
|
|
6983
|
-
};
|
|
6984
|
-
/**
|
|
6985
|
-
* Group allocations by bank account via bank transactions collection
|
|
6986
|
-
*/
|
|
6987
|
-
TransactionAllocationCollection.prototype.groupByBankAccount = function (bankTransactions) {
|
|
6988
|
-
var _this = this;
|
|
6989
|
-
// Group bank transactions by bank account id
|
|
6990
|
-
var bankTransactionsByBankAccount = new CollectionDictionary(bankTransactions, 'bankAccount.id');
|
|
6991
|
-
// Create empty dictionary of transaction allocations
|
|
6992
|
-
var allocationsByBankAccount = new CollectionDictionary(new TransactionAllocationCollection([]));
|
|
6993
|
-
// Fill allocations dictionary with bank transactions dictionary keys and allocations related with each bank transaction collection
|
|
6994
|
-
bankTransactionsByBankAccount.keys.forEach(function (key) {
|
|
6995
|
-
allocationsByBankAccount.add(key, _this.getByBankTransactionsIds(bankTransactionsByBankAccount.get(key).getIds()));
|
|
6996
|
-
});
|
|
6997
|
-
return allocationsByBankAccount;
|
|
6998
|
-
};
|
|
6999
|
-
/**
|
|
7000
|
-
* check if collection includes allocation of passed transaction
|
|
7001
|
-
*/
|
|
7002
|
-
TransactionAllocationCollection.prototype.hasTransaction = function (transaction) {
|
|
7003
|
-
return !!this.items.find(function (allocation) { return allocation.transaction.id === transaction.id; });
|
|
6895
|
+
PropertyValuation.prototype.isCurrentYear = function () {
|
|
6896
|
+
return this.financialYear === new FinancialYear(new Date()).year;
|
|
7004
6897
|
};
|
|
6898
|
+
return PropertyValuation;
|
|
6899
|
+
}(PropertyValuation$1));
|
|
6900
|
+
__decorate([
|
|
6901
|
+
classTransformer.Type(function () { return Date; })
|
|
6902
|
+
], PropertyValuation.prototype, "date", void 0);
|
|
6903
|
+
__decorate([
|
|
6904
|
+
classTransformer.Type(function () { return PropertyDocument; })
|
|
6905
|
+
], PropertyValuation.prototype, "document", void 0);
|
|
6906
|
+
__decorate([
|
|
6907
|
+
classTransformer.Exclude()
|
|
6908
|
+
], PropertyValuation.prototype, "documentFile", void 0);
|
|
6909
|
+
|
|
6910
|
+
var PropertyForecast$1 = /** @class */ (function (_super) {
|
|
6911
|
+
__extends(PropertyForecast, _super);
|
|
6912
|
+
function PropertyForecast() {
|
|
6913
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
6914
|
+
}
|
|
6915
|
+
return PropertyForecast;
|
|
6916
|
+
}(AbstractModel));
|
|
6917
|
+
|
|
6918
|
+
var PropertyForecast = /** @class */ (function (_super) {
|
|
6919
|
+
__extends(PropertyForecast, _super);
|
|
6920
|
+
function PropertyForecast() {
|
|
6921
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
6922
|
+
_this.financialYear = new FinancialYear(new Date()).year;
|
|
6923
|
+
return _this;
|
|
6924
|
+
}
|
|
6925
|
+
Object.defineProperty(PropertyForecast.prototype, "cashPosition", {
|
|
6926
|
+
/**
|
|
6927
|
+
* Get cash position
|
|
6928
|
+
* Cash Position = Income - Expense - Interest
|
|
6929
|
+
*/
|
|
6930
|
+
get: function () {
|
|
6931
|
+
return this.income + this.expense + this.interest;
|
|
6932
|
+
},
|
|
6933
|
+
enumerable: false,
|
|
6934
|
+
configurable: true
|
|
6935
|
+
});
|
|
6936
|
+
Object.defineProperty(PropertyForecast.prototype, "taxPosition", {
|
|
6937
|
+
/**
|
|
6938
|
+
* Get tax position
|
|
6939
|
+
* Tax Position = Income - Expense - Interest - Depreciation
|
|
6940
|
+
*/
|
|
6941
|
+
get: function () {
|
|
6942
|
+
return this.cashPosition + this.depreciation;
|
|
6943
|
+
},
|
|
6944
|
+
enumerable: false,
|
|
6945
|
+
configurable: true
|
|
6946
|
+
});
|
|
6947
|
+
Object.defineProperty(PropertyForecast.prototype, "rentalReturn", {
|
|
6948
|
+
/**
|
|
6949
|
+
* Get rental return percent
|
|
6950
|
+
* Rental Return = Income / Market Value
|
|
6951
|
+
*/
|
|
6952
|
+
get: function () {
|
|
6953
|
+
return this.income / this.marketValue;
|
|
6954
|
+
},
|
|
6955
|
+
enumerable: false,
|
|
6956
|
+
configurable: true
|
|
6957
|
+
});
|
|
7005
6958
|
/**
|
|
7006
|
-
* Check if
|
|
6959
|
+
* Check if forecast is for real current fin year (not selected in the sidebar)
|
|
7007
6960
|
*/
|
|
7008
|
-
|
|
7009
|
-
return
|
|
6961
|
+
PropertyForecast.prototype.isCurrentYear = function () {
|
|
6962
|
+
return this.financialYear === new FinancialYear(new Date()).year;
|
|
7010
6963
|
};
|
|
7011
|
-
return
|
|
7012
|
-
}(
|
|
6964
|
+
return PropertyForecast;
|
|
6965
|
+
}(PropertyForecast$1));
|
|
6966
|
+
__decorate([
|
|
6967
|
+
classTransformer.Transform(function (_a) {
|
|
6968
|
+
var value = _a.value;
|
|
6969
|
+
return +value;
|
|
6970
|
+
})
|
|
6971
|
+
], PropertyForecast.prototype, "income", void 0);
|
|
6972
|
+
__decorate([
|
|
6973
|
+
classTransformer.Transform(function (_a) {
|
|
6974
|
+
var value = _a.value;
|
|
6975
|
+
return -Math.abs(+value);
|
|
6976
|
+
})
|
|
6977
|
+
], PropertyForecast.prototype, "expense", void 0);
|
|
6978
|
+
__decorate([
|
|
6979
|
+
classTransformer.Transform(function (_a) {
|
|
6980
|
+
var value = _a.value;
|
|
6981
|
+
return -Math.abs(+value);
|
|
6982
|
+
})
|
|
6983
|
+
], PropertyForecast.prototype, "interest", void 0);
|
|
6984
|
+
__decorate([
|
|
6985
|
+
classTransformer.Transform(function (_a) {
|
|
6986
|
+
var value = _a.value;
|
|
6987
|
+
return -Math.abs(+value);
|
|
6988
|
+
})
|
|
6989
|
+
], PropertyForecast.prototype, "depreciation", void 0);
|
|
6990
|
+
__decorate([
|
|
6991
|
+
classTransformer.Transform(function (_a) {
|
|
6992
|
+
var value = _a.value;
|
|
6993
|
+
return +value;
|
|
6994
|
+
})
|
|
6995
|
+
], PropertyForecast.prototype, "loanBalance", void 0);
|
|
6996
|
+
__decorate([
|
|
6997
|
+
classTransformer.Transform(function (_a) {
|
|
6998
|
+
var value = _a.value;
|
|
6999
|
+
return +value;
|
|
7000
|
+
})
|
|
7001
|
+
], PropertyForecast.prototype, "marketValue", void 0);
|
|
7013
7002
|
|
|
7014
|
-
/**
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
var TransactionBaseCollection = /** @class */ (function (_super) {
|
|
7018
|
-
__extends(TransactionBaseCollection, _super);
|
|
7019
|
-
function TransactionBaseCollection() {
|
|
7003
|
+
var PropertyCategoryMovement$1 = /** @class */ (function (_super) {
|
|
7004
|
+
__extends(PropertyCategoryMovement, _super);
|
|
7005
|
+
function PropertyCategoryMovement() {
|
|
7020
7006
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
7021
7007
|
}
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
};
|
|
7025
|
-
TransactionBaseCollection.prototype.getSoleTransactions = function () {
|
|
7026
|
-
return this.filter(function (transaction) { return transaction.isSoleTank(); });
|
|
7027
|
-
};
|
|
7028
|
-
return TransactionBaseCollection;
|
|
7029
|
-
}(Collection));
|
|
7008
|
+
return PropertyCategoryMovement;
|
|
7009
|
+
}(AbstractModel));
|
|
7030
7010
|
|
|
7031
|
-
|
|
7011
|
+
var PropertyCategoryMovement = /** @class */ (function (_super) {
|
|
7012
|
+
__extends(PropertyCategoryMovement, _super);
|
|
7013
|
+
function PropertyCategoryMovement() {
|
|
7014
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
7015
|
+
}
|
|
7016
|
+
return PropertyCategoryMovement;
|
|
7017
|
+
}(PropertyCategoryMovement$1));
|
|
7018
|
+
__decorate([
|
|
7019
|
+
classTransformer.Type(function () { return PropertyValuation; })
|
|
7020
|
+
], PropertyCategoryMovement.prototype, "valuation", void 0);
|
|
7021
|
+
__decorate([
|
|
7022
|
+
classTransformer.Type(function () { return PropertyCategory; })
|
|
7023
|
+
], PropertyCategoryMovement.prototype, "propertyCategory", void 0);
|
|
7024
|
+
__decorate([
|
|
7025
|
+
classTransformer.Type(function () { return Date; })
|
|
7026
|
+
], PropertyCategoryMovement.prototype, "fromDate", void 0);
|
|
7027
|
+
__decorate([
|
|
7028
|
+
classTransformer.Type(function () { return Date; })
|
|
7029
|
+
], PropertyCategoryMovement.prototype, "toDate", void 0);
|
|
7030
|
+
|
|
7031
|
+
exports.TaxExemptionEnum = void 0;
|
|
7032
|
+
(function (TaxExemptionEnum) {
|
|
7033
|
+
TaxExemptionEnum[TaxExemptionEnum["ONE_YEAR_RULE"] = 1] = "ONE_YEAR_RULE";
|
|
7034
|
+
// principle place of residence
|
|
7035
|
+
TaxExemptionEnum[TaxExemptionEnum["PPR"] = 2] = "PPR";
|
|
7036
|
+
TaxExemptionEnum[TaxExemptionEnum["SIX_YEARS_RULE"] = 3] = "SIX_YEARS_RULE";
|
|
7037
|
+
TaxExemptionEnum[TaxExemptionEnum["INVESTMENT_TO_PPR"] = 4] = "INVESTMENT_TO_PPR";
|
|
7038
|
+
TaxExemptionEnum[TaxExemptionEnum["PPR_TO_INVESTMENT"] = 5] = "PPR_TO_INVESTMENT";
|
|
7039
|
+
TaxExemptionEnum[TaxExemptionEnum["TRANSFER"] = 6] = "TRANSFER";
|
|
7040
|
+
TaxExemptionEnum[TaxExemptionEnum["OTHER"] = 7] = "OTHER";
|
|
7041
|
+
})(exports.TaxExemptionEnum || (exports.TaxExemptionEnum = {}));
|
|
7032
7042
|
|
|
7033
7043
|
/**
|
|
7034
7044
|
* propertySale docs - https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/4209508353/Property+Sold+button
|
|
@@ -21105,13 +21115,15 @@
|
|
|
21105
21115
|
}, forms.Validators.required),
|
|
21106
21116
|
incomeSource: new forms.FormControl(transaction.incomeSource, [forms.Validators.required, autocompleteValidator()]),
|
|
21107
21117
|
}) || this;
|
|
21108
|
-
//
|
|
21118
|
+
// @TODO we use amount field as netAmount to avoid extra watcher for amount recalculation
|
|
21109
21119
|
if (transaction.id) {
|
|
21110
|
-
_this.get('amount').setValue(
|
|
21120
|
+
_this.get('amount').setValue(transaction.netAmount);
|
|
21111
21121
|
}
|
|
21122
|
+
// forbid to edit some fields for allocated transaction
|
|
21112
21123
|
if (allocations.length) {
|
|
21113
21124
|
_this.get('chartAccounts').disable();
|
|
21114
21125
|
}
|
|
21126
|
+
// adjustments allowed only for salary
|
|
21115
21127
|
if (!((_a = transaction.chartAccounts) === null || _a === void 0 ? void 0 : _a.isSalary())) {
|
|
21116
21128
|
_this.get('transactions').disable();
|
|
21117
21129
|
}
|
|
@@ -21174,27 +21186,20 @@
|
|
|
21174
21186
|
});
|
|
21175
21187
|
};
|
|
21176
21188
|
/**
|
|
21177
|
-
*
|
|
21178
|
-
* @param includeAdjustments reduce result by adjustments included in salary if false or increase amount with included salary adjustments to match received payment if true,
|
|
21179
|
-
* salary/wage comes to bankAccount together with related chartAccounts like tips (kind of salary, but reported in different tax summary section),
|
|
21189
|
+
* salary comes to bankAccount together with related transactions like tips (kind of salary, but reported in different tax summary section),
|
|
21180
21190
|
* adjustments used to clarify received payment by separating it into multiple transactions,
|
|
21181
|
-
*
|
|
21182
|
-
*
|
|
21183
|
-
*
|
|
21184
|
-
|
|
21185
|
-
|
|
21186
|
-
|
|
21187
|
-
|
|
21188
|
-
|
|
21189
|
-
if (!transaction.chartAccounts || !transaction.chartAccounts.isSalary()) {
|
|
21190
|
-
return transaction.amount;
|
|
21191
|
-
}
|
|
21192
|
-
var includedTransactions = new Collection(transaction.transactions).filter(function (t) { return t.chartAccounts.isSalaryIncluded(); });
|
|
21193
|
-
return transaction.amount + includedTransactions.sumBy('amount') * (includeAdjustments ? 1 : -1);
|
|
21191
|
+
* netAmount always match received payment and includes related adjustments
|
|
21192
|
+
* amount calculated as netAmount - salary included adjustments
|
|
21193
|
+
* ie bankTransaction=1000$ with 900$ salary and 100$ tips will create 2 transactions with 900$ and 100$
|
|
21194
|
+
*/
|
|
21195
|
+
WorkIncomeForm.prototype.getAmount = function () {
|
|
21196
|
+
return this.get('amount').value - new Collection(this.currentValue.transactions)
|
|
21197
|
+
.filter(function (t) { var _a; return (_a = t.chartAccounts) === null || _a === void 0 ? void 0 : _a.isSalaryIncluded(); })
|
|
21198
|
+
.sumBy('amount');
|
|
21194
21199
|
};
|
|
21195
21200
|
WorkIncomeForm.prototype.submit = function (data) {
|
|
21196
21201
|
if (data === void 0) { data = {}; }
|
|
21197
|
-
return _super.prototype.submit.call(this, Object.assign(data, { amount: this.getAmount(
|
|
21202
|
+
return _super.prototype.submit.call(this, Object.assign(data, { amount: this.getAmount() }));
|
|
21198
21203
|
};
|
|
21199
21204
|
return WorkIncomeForm;
|
|
21200
21205
|
}(TransactionForm));
|