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