taxtank-core 0.6.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/bundles/taxtank-core.umd.js +137 -6
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/collection.js +7 -1
  4. package/esm2015/lib/db/Models/property/property-sale/tax-exemption.js +1 -1
  5. package/esm2015/lib/forms/abstract.form.js +11 -0
  6. package/esm2015/lib/forms/index.js +7 -0
  7. package/esm2015/lib/forms/login/login.form.js +11 -0
  8. package/esm2015/lib/forms/register/register-client.form.js +29 -0
  9. package/esm2015/lib/forms/register/register-firm.form.js +26 -0
  10. package/esm2015/lib/forms/user/password.form.js +11 -0
  11. package/esm2015/lib/forms/user/reset-password.form.js +10 -0
  12. package/esm2015/lib/models/depreciation/depreciation-lvp-rate.enum.js +6 -0
  13. package/esm2015/lib/models/depreciation/depreciation.js +5 -2
  14. package/esm2015/lib/models/property/property.js +4 -3
  15. package/esm2015/lib/services/pdf/pdf.service.js +15 -4
  16. package/esm2015/public-api.js +6 -1
  17. package/fesm2015/taxtank-core.js +117 -8
  18. package/fesm2015/taxtank-core.js.map +1 -1
  19. package/lib/collections/collection.d.ts +4 -0
  20. package/lib/db/Models/property/property-sale/tax-exemption.d.ts +1 -0
  21. package/lib/forms/abstract.form.d.ts +4 -0
  22. package/lib/forms/index.d.ts +6 -0
  23. package/lib/forms/login/login.form.d.ts +4 -0
  24. package/lib/forms/register/register-client.form.d.ts +5 -0
  25. package/lib/forms/register/register-firm.form.d.ts +7 -0
  26. package/lib/forms/user/password.form.d.ts +4 -0
  27. package/lib/forms/user/reset-password.form.d.ts +4 -0
  28. package/lib/models/depreciation/depreciation-lvp-rate.enum.d.ts +4 -0
  29. package/lib/models/depreciation/depreciation.d.ts +1 -0
  30. package/package.json +2 -1
  31. package/public-api.d.ts +5 -0
@@ -1283,6 +1283,12 @@
1283
1283
  Collection.prototype.toArray = function () {
1284
1284
  return __spreadArray([], __read(this.items));
1285
1285
  };
1286
+ /**
1287
+ * Filter items by specific provided callback
1288
+ */
1289
+ Collection.prototype.filter = function (callback) {
1290
+ return new Collection(this.items.filter(callback));
1291
+ };
1286
1292
  Object.defineProperty(Collection.prototype, "first", {
1287
1293
  get: function () {
1288
1294
  return first__default["default"](this.items);
@@ -4743,7 +4749,6 @@
4743
4749
  * gross capital gain tax: sale costs - cost base
4744
4750
  */
4745
4751
  Property.prototype.calculateCGT = function (sale) {
4746
- console.log(sale.price, sale.saleCostsTotalAmount, sale.capitalLoss, this.calculateCostBase(sale));
4747
4752
  return sale.price - sale.saleCostsTotalAmount - sale.capitalLoss - this.calculateCostBase(sale);
4748
4753
  };
4749
4754
  /**
@@ -4786,7 +4791,9 @@
4786
4791
  return (ownershipDays - metadata.getPPRDays()) / ownershipDays;
4787
4792
  // main residence become investment (exemption for home office percent usage)
4788
4793
  case TaxExemptionEnum.PPR_TO_INVESTMENT:
4789
- return metadata.getClaimPercent() / 100;
4794
+ // 1 year CGT discount can still apply (on the income producing % if used for 12 months or more)
4795
+ var ratio = this.getOwnershipDuration(sale, 'years') >= 1 ? 0.5 : 1;
4796
+ return metadata.getClaimPercent() / 100 * ratio;
4790
4797
  // full exemption
4791
4798
  case TaxExemptionEnum.PPR:
4792
4799
  case TaxExemptionEnum.SIX_YEARS_RULE:
@@ -5599,7 +5606,7 @@
5599
5606
  * @TODO new FinancialYear(this.writeOffDate) === new FinancialYear()
5600
5607
  */
5601
5608
  Depreciation.prototype.isLowValuePool = function () {
5602
- return this.isAsset && !this.isWrittenOff() &&
5609
+ return this.isAsset &&
5603
5610
  this.calculation === exports.DepreciationCalculationEnum.DIMINISHING &&
5604
5611
  this.amount > Depreciation.WRITTEN_OFF_THRESHOLD &&
5605
5612
  this.amount <= Depreciation.LOW_VALUE_POOL_THRESHOLD;
@@ -5705,6 +5712,9 @@
5705
5712
  __decorate([
5706
5713
  classTransformer.Type(function () { return Date; })
5707
5714
  ], Depreciation.prototype, "date", void 0);
5715
+ __decorate([
5716
+ classTransformer.Type(function () { return Date; })
5717
+ ], Depreciation.prototype, "lowValuePoolDate", void 0);
5708
5718
  __decorate([
5709
5719
  classTransformer.Type(function () { return Date; })
5710
5720
  ], Depreciation.prototype, "writeOffManualDate", void 0);
@@ -6696,6 +6706,12 @@
6696
6706
  return DataTableColumn;
6697
6707
  }());
6698
6708
 
6709
+ exports.DepreciationLvpRateEnum = void 0;
6710
+ (function (DepreciationLvpRateEnum) {
6711
+ DepreciationLvpRateEnum[DepreciationLvpRateEnum["FIRST_YEAR"] = 0.1875] = "FIRST_YEAR";
6712
+ DepreciationLvpRateEnum[DepreciationLvpRateEnum["DEFAULT"] = 0.375] = "DEFAULT";
6713
+ })(exports.DepreciationLvpRateEnum || (exports.DepreciationLvpRateEnum = {}));
6714
+
6699
6715
  exports.DepreciationGroupEnum = void 0;
6700
6716
  (function (DepreciationGroupEnum) {
6701
6717
  DepreciationGroupEnum[DepreciationGroupEnum["BUILDING_IMPROVEMENTS"] = 0] = "BUILDING_IMPROVEMENTS";
@@ -10718,12 +10734,17 @@
10718
10734
  var pdf = new jsPDF__default["default"]();
10719
10735
  this.setDocumentTitle(pdf, title);
10720
10736
  tables.forEach(function (table) {
10721
- var _a, _b;
10737
+ var _a;
10738
+ // Add table caption if not provided
10739
+ if (!table.caption) {
10740
+ table.createCaption();
10741
+ table.caption.innerText = '';
10742
+ }
10722
10743
  // coords of last table
10723
10744
  var lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
10724
- pdf.text((_a = table.caption) === null || _a === void 0 ? void 0 : _a.innerText, PDF_CONFIG.contentCoords.marginLeft, lastTableCoords + PDF_CONFIG.contentCoords.marginTop);
10745
+ pdf.text(table.caption.innerText, PDF_CONFIG.contentCoords.marginLeft, lastTableCoords + PDF_CONFIG.contentCoords.marginTop);
10725
10746
  // get caption height based on caption content height
10726
- var captionHeight = pdf.getTextDimensions(pdf.splitTextToSize((_b = table.caption) === null || _b === void 0 ? void 0 : _b.innerText, pdf.internal.pageSize.width)).h;
10747
+ var captionHeight = pdf.getTextDimensions(pdf.splitTextToSize((_a = table.caption) === null || _a === void 0 ? void 0 : _a.innerText, pdf.internal.pageSize.width)).h;
10727
10748
  // table options
10728
10749
  var options = {
10729
10750
  html: table,
@@ -10731,6 +10752,12 @@
10731
10752
  footStyles: {
10732
10753
  fillColor: PDF_CONFIG.text.fillColor,
10733
10754
  textColor: PDF_CONFIG.text.textColor
10755
+ },
10756
+ didParseCell: function (data) {
10757
+ // Align last column content to right
10758
+ if (data.table.columns.length > 1 && (data.column.index === data.table.columns.length - 1)) {
10759
+ data.cell.styles.halign = 'right';
10760
+ }
10734
10761
  }
10735
10762
  };
10736
10763
  autoTable__default["default"](pdf, options);
@@ -12778,6 +12805,104 @@
12778
12805
  data.employee.fullName.toLowerCase().includes(filter);
12779
12806
  }
12780
12807
 
12808
+ var AbstractForm = /** @class */ (function (_super) {
12809
+ __extends(AbstractForm, _super);
12810
+ function AbstractForm() {
12811
+ return _super !== null && _super.apply(this, arguments) || this;
12812
+ }
12813
+ AbstractForm.prototype.submit = function () {
12814
+ this.markAllAsTouched();
12815
+ if (!this.valid) {
12816
+ return null;
12817
+ }
12818
+ return this.value;
12819
+ };
12820
+ return AbstractForm;
12821
+ }(forms.FormGroup));
12822
+
12823
+ var LoginForm = /** @class */ (function (_super) {
12824
+ __extends(LoginForm, _super);
12825
+ function LoginForm() {
12826
+ return _super.call(this, {
12827
+ email: new forms.FormControl(null, [forms.Validators.required, forms.Validators.email]),
12828
+ password: new forms.FormControl(null, forms.Validators.required)
12829
+ }) || this;
12830
+ }
12831
+ return LoginForm;
12832
+ }(AbstractForm));
12833
+
12834
+ var PasswordForm = /** @class */ (function (_super) {
12835
+ __extends(PasswordForm, _super);
12836
+ function PasswordForm() {
12837
+ return _super.call(this, {
12838
+ password: new forms.FormControl('', forms.Validators.required),
12839
+ confirm: new forms.FormControl('', forms.Validators.required),
12840
+ }) || this;
12841
+ }
12842
+ return PasswordForm;
12843
+ }(AbstractForm));
12844
+
12845
+ var RegisterClientForm = /** @class */ (function (_super) {
12846
+ __extends(RegisterClientForm, _super);
12847
+ function RegisterClientForm(referenceCode) {
12848
+ return _super.call(this, {
12849
+ firstName: new forms.FormControl('', [forms.Validators.required]),
12850
+ lastName: new forms.FormControl('', [forms.Validators.required]),
12851
+ email: new forms.FormControl('', [forms.Validators.required, forms.Validators.email]),
12852
+ password: new PasswordForm(),
12853
+ acceptTerms: new forms.FormControl(false, [forms.Validators.requiredTrue]),
12854
+ referenceCode: new forms.FormControl(referenceCode)
12855
+ }) || this;
12856
+ }
12857
+ RegisterClientForm.prototype.submit = function () {
12858
+ this.markAllAsTouched();
12859
+ if (!this.valid) {
12860
+ return null;
12861
+ }
12862
+ return {
12863
+ firstName: this.value.firstName,
12864
+ lastName: this.value.lastName,
12865
+ email: this.value.email,
12866
+ password: this.value.password.password,
12867
+ referenceCode: this.value.referenceCode
12868
+ };
12869
+ };
12870
+ return RegisterClientForm;
12871
+ }(AbstractForm));
12872
+
12873
+ var RegisterFirmForm = /** @class */ (function (_super) {
12874
+ __extends(RegisterFirmForm, _super);
12875
+ function RegisterFirmForm(firmType, referenceCode) {
12876
+ var _this = _super.call(this, {
12877
+ name: new forms.FormControl('', forms.Validators.required),
12878
+ abn: new forms.FormControl('', forms.Validators.required),
12879
+ tan: new forms.FormControl({ value: '', disabled: firmType !== exports.FirmTypeEnum.ACCOUNTANT }, forms.Validators.required),
12880
+ owner: new RegisterClientForm(referenceCode),
12881
+ type: new forms.FormControl(firmType)
12882
+ }) || this;
12883
+ _this.firmType = firmType;
12884
+ return _this;
12885
+ }
12886
+ RegisterFirmForm.prototype.submit = function () {
12887
+ this.markAllAsTouched();
12888
+ if (!this.valid) {
12889
+ return null;
12890
+ }
12891
+ return classTransformer.plainToClass(Firm, Object.assign({}, this.value, { owner: this.get('owner').submit() }));
12892
+ };
12893
+ return RegisterFirmForm;
12894
+ }(AbstractForm));
12895
+
12896
+ var ResetPasswordForm = /** @class */ (function (_super) {
12897
+ __extends(ResetPasswordForm, _super);
12898
+ function ResetPasswordForm() {
12899
+ return _super.call(this, {
12900
+ email: new forms.FormControl(null, [forms.Validators.required, forms.Validators.email]),
12901
+ }) || this;
12902
+ }
12903
+ return ResetPasswordForm;
12904
+ }(AbstractForm));
12905
+
12781
12906
  /**
12782
12907
  * Public API Surface of tt-core
12783
12908
  */
@@ -12786,6 +12911,7 @@
12786
12911
  * Generated bundle index. Do not edit.
12787
12912
  */
12788
12913
 
12914
+ exports.AbstractForm = AbstractForm;
12789
12915
  exports.Address = Address;
12790
12916
  exports.AddressService = AddressService;
12791
12917
  exports.AppEvent = AppEvent;
@@ -12891,6 +13017,7 @@
12891
13017
  exports.LoanService = LoanService;
12892
13018
  exports.LogbookCollection = LogbookCollection;
12893
13019
  exports.LogbookPeriod = LogbookPeriod;
13020
+ exports.LoginForm = LoginForm;
12894
13021
  exports.MODULE_URL_LIST = MODULE_URL_LIST;
12895
13022
  exports.MONTHS = MONTHS;
12896
13023
  exports.Message = Message;
@@ -12904,6 +13031,7 @@
12904
13031
  exports.NotificationService = NotificationService;
12905
13032
  exports.Occupation = Occupation;
12906
13033
  exports.OccupationService = OccupationService;
13034
+ exports.PasswordForm = PasswordForm;
12907
13035
  exports.PdfService = PdfService;
12908
13036
  exports.Phone = Phone;
12909
13037
  exports.PreloaderService = PreloaderService;
@@ -12927,7 +13055,10 @@
12927
13055
  exports.PropertyService = PropertyService;
12928
13056
  exports.PropertySubscription = PropertySubscription;
12929
13057
  exports.PropertyValuation = PropertyValuation;
13058
+ exports.RegisterClientForm = RegisterClientForm;
13059
+ exports.RegisterFirmForm = RegisterFirmForm;
12930
13060
  exports.RegistrationInvite = RegistrationInvite;
13061
+ exports.ResetPasswordForm = ResetPasswordForm;
12931
13062
  exports.SUBSCRIPTION_DESCRIPTION = SUBSCRIPTION_DESCRIPTION;
12932
13063
  exports.SUBSCRIPTION_TITLE = SUBSCRIPTION_TITLE;
12933
13064
  exports.SalaryForecast = SalaryForecast;