taxtank-core 0.6.1 → 0.7.3

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 (30) hide show
  1. package/bundles/taxtank-core.umd.js +156 -9
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/collection.js +7 -1
  4. package/esm2015/lib/forms/abstract.form.js +11 -0
  5. package/esm2015/lib/forms/index.js +7 -0
  6. package/esm2015/lib/forms/login/login.form.js +11 -0
  7. package/esm2015/lib/forms/register/register-client.form.js +29 -0
  8. package/esm2015/lib/forms/register/register-firm.form.js +26 -0
  9. package/esm2015/lib/forms/user/password.form.js +11 -0
  10. package/esm2015/lib/forms/user/reset-password.form.js +10 -0
  11. package/esm2015/lib/models/depreciation/depreciation-lvp-rate.enum.js +6 -0
  12. package/esm2015/lib/models/depreciation/depreciation.js +6 -3
  13. package/esm2015/lib/models/pdf/pdf-config.js +11 -3
  14. package/esm2015/lib/services/pdf/pdf.service.js +26 -6
  15. package/esm2015/public-api.js +6 -1
  16. package/fesm2015/taxtank-core.js +136 -11
  17. package/fesm2015/taxtank-core.js.map +1 -1
  18. package/lib/collections/collection.d.ts +4 -0
  19. package/lib/forms/abstract.form.d.ts +4 -0
  20. package/lib/forms/index.d.ts +6 -0
  21. package/lib/forms/login/login.form.d.ts +4 -0
  22. package/lib/forms/register/register-client.form.d.ts +5 -0
  23. package/lib/forms/register/register-firm.form.d.ts +7 -0
  24. package/lib/forms/user/password.form.d.ts +4 -0
  25. package/lib/forms/user/reset-password.form.d.ts +4 -0
  26. package/lib/models/depreciation/depreciation-lvp-rate.enum.d.ts +4 -0
  27. package/lib/models/depreciation/depreciation.d.ts +1 -0
  28. package/lib/services/pdf/pdf.service.d.ts +1 -0
  29. package/package.json +2 -1
  30. 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);
@@ -5600,7 +5606,7 @@
5600
5606
  * @TODO new FinancialYear(this.writeOffDate) === new FinancialYear()
5601
5607
  */
5602
5608
  Depreciation.prototype.isLowValuePool = function () {
5603
- return this.isAsset && !this.isWrittenOff() &&
5609
+ return this.isAsset &&
5604
5610
  this.calculation === exports.DepreciationCalculationEnum.DIMINISHING &&
5605
5611
  this.amount > Depreciation.WRITTEN_OFF_THRESHOLD &&
5606
5612
  this.amount <= Depreciation.LOW_VALUE_POOL_THRESHOLD;
@@ -5694,7 +5700,7 @@
5694
5700
  * Create a new transaction from current depreciation
5695
5701
  */
5696
5702
  Depreciation.prototype.toTransaction = function () {
5697
- return classTransformer.plainToClass(Transaction, this);
5703
+ return classTransformer.plainToClass(Transaction, Object.assign({}, this, { amount: this.getCurrentYearForecastAmount() }));
5698
5704
  };
5699
5705
  return Depreciation;
5700
5706
  }(Depreciation$1));
@@ -5706,6 +5712,9 @@
5706
5712
  __decorate([
5707
5713
  classTransformer.Type(function () { return Date; })
5708
5714
  ], Depreciation.prototype, "date", void 0);
5715
+ __decorate([
5716
+ classTransformer.Type(function () { return Date; })
5717
+ ], Depreciation.prototype, "lowValuePoolDate", void 0);
5709
5718
  __decorate([
5710
5719
  classTransformer.Type(function () { return Date; })
5711
5720
  ], Depreciation.prototype, "writeOffManualDate", void 0);
@@ -6697,6 +6706,12 @@
6697
6706
  return DataTableColumn;
6698
6707
  }());
6699
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
+
6700
6715
  exports.DepreciationGroupEnum = void 0;
6701
6716
  (function (DepreciationGroupEnum) {
6702
6717
  DepreciationGroupEnum[DepreciationGroupEnum["BUILDING_IMPROVEMENTS"] = 0] = "BUILDING_IMPROVEMENTS";
@@ -10678,8 +10693,16 @@
10678
10693
  fontWeight: 'bold',
10679
10694
  positionX: 14,
10680
10695
  positionY: 10,
10681
- fillColor: 255,
10682
- textColor: 0
10696
+ colorWhite: '#ffffff',
10697
+ colorBlack: '#000000',
10698
+ colorPrimary: '#00b7f0'
10699
+ },
10700
+ logo: {
10701
+ src: '/assets/img/icons/logo.png',
10702
+ width: 30,
10703
+ height: 7,
10704
+ positionX: 168,
10705
+ positionY: 6
10683
10706
  },
10684
10707
  // coords for file section title (group, table, e.t.c.)
10685
10708
  contentTitleCoords: {
@@ -10718,20 +10741,35 @@
10718
10741
  PdfService.prototype.generateFromTables = function (tables, title) {
10719
10742
  var pdf = new jsPDF__default["default"]();
10720
10743
  this.setDocumentTitle(pdf, title);
10744
+ this.setDocumentLogo(pdf);
10721
10745
  tables.forEach(function (table) {
10722
- var _a, _b;
10746
+ var _a;
10747
+ // Add table caption if not provided
10748
+ if (!table.caption) {
10749
+ table.createCaption();
10750
+ table.caption.innerText = '';
10751
+ }
10723
10752
  // coords of last table
10724
10753
  var lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
10725
- pdf.text((_a = table.caption) === null || _a === void 0 ? void 0 : _a.innerText, PDF_CONFIG.contentCoords.marginLeft, lastTableCoords + PDF_CONFIG.contentCoords.marginTop);
10754
+ pdf.text(table.caption.innerText, PDF_CONFIG.contentCoords.marginLeft, lastTableCoords + PDF_CONFIG.contentCoords.marginTop);
10726
10755
  // get caption height based on caption content height
10727
- var captionHeight = pdf.getTextDimensions(pdf.splitTextToSize((_b = table.caption) === null || _b === void 0 ? void 0 : _b.innerText, pdf.internal.pageSize.width)).h;
10756
+ var captionHeight = pdf.getTextDimensions(pdf.splitTextToSize((_a = table.caption) === null || _a === void 0 ? void 0 : _a.innerText, pdf.internal.pageSize.width)).h;
10728
10757
  // table options
10729
10758
  var options = {
10730
10759
  html: table,
10731
10760
  startY: lastTableCoords + captionHeight + PDF_CONFIG.contentTitleCoords.marginTop,
10761
+ headStyles: {
10762
+ fillColor: PDF_CONFIG.text.colorPrimary,
10763
+ },
10732
10764
  footStyles: {
10733
- fillColor: PDF_CONFIG.text.fillColor,
10734
- textColor: PDF_CONFIG.text.textColor
10765
+ fillColor: PDF_CONFIG.text.colorWhite,
10766
+ textColor: PDF_CONFIG.text.colorBlack
10767
+ },
10768
+ didParseCell: function (data) {
10769
+ // Align last column content to right
10770
+ if (data.table.columns.length > 1 && (data.column.index === data.table.columns.length - 1)) {
10771
+ data.cell.styles.halign = 'right';
10772
+ }
10735
10773
  }
10736
10774
  };
10737
10775
  autoTable__default["default"](pdf, options);
@@ -10743,6 +10781,11 @@
10743
10781
  .setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight)
10744
10782
  .text(title, PDF_CONFIG.text.positionX, PDF_CONFIG.text.positionY);
10745
10783
  };
10784
+ PdfService.prototype.setDocumentLogo = function (doc) {
10785
+ var logo = new Image();
10786
+ logo.src = PDF_CONFIG.logo.src;
10787
+ doc.addImage(logo, 'PNG', PDF_CONFIG.logo.positionX, PDF_CONFIG.logo.positionY, PDF_CONFIG.logo.width, PDF_CONFIG.logo.height);
10788
+ };
10746
10789
  /**
10747
10790
  * @Todo remove/refactor when all DataTable dependent methods will be cleared-up
10748
10791
  * Generate PDF file from provided data
@@ -12779,6 +12822,104 @@
12779
12822
  data.employee.fullName.toLowerCase().includes(filter);
12780
12823
  }
12781
12824
 
12825
+ var AbstractForm = /** @class */ (function (_super) {
12826
+ __extends(AbstractForm, _super);
12827
+ function AbstractForm() {
12828
+ return _super !== null && _super.apply(this, arguments) || this;
12829
+ }
12830
+ AbstractForm.prototype.submit = function () {
12831
+ this.markAllAsTouched();
12832
+ if (!this.valid) {
12833
+ return null;
12834
+ }
12835
+ return this.value;
12836
+ };
12837
+ return AbstractForm;
12838
+ }(forms.FormGroup));
12839
+
12840
+ var LoginForm = /** @class */ (function (_super) {
12841
+ __extends(LoginForm, _super);
12842
+ function LoginForm() {
12843
+ return _super.call(this, {
12844
+ email: new forms.FormControl(null, [forms.Validators.required, forms.Validators.email]),
12845
+ password: new forms.FormControl(null, forms.Validators.required)
12846
+ }) || this;
12847
+ }
12848
+ return LoginForm;
12849
+ }(AbstractForm));
12850
+
12851
+ var PasswordForm = /** @class */ (function (_super) {
12852
+ __extends(PasswordForm, _super);
12853
+ function PasswordForm() {
12854
+ return _super.call(this, {
12855
+ password: new forms.FormControl('', forms.Validators.required),
12856
+ confirm: new forms.FormControl('', forms.Validators.required),
12857
+ }) || this;
12858
+ }
12859
+ return PasswordForm;
12860
+ }(AbstractForm));
12861
+
12862
+ var RegisterClientForm = /** @class */ (function (_super) {
12863
+ __extends(RegisterClientForm, _super);
12864
+ function RegisterClientForm(referenceCode) {
12865
+ return _super.call(this, {
12866
+ firstName: new forms.FormControl('', [forms.Validators.required]),
12867
+ lastName: new forms.FormControl('', [forms.Validators.required]),
12868
+ email: new forms.FormControl('', [forms.Validators.required, forms.Validators.email]),
12869
+ password: new PasswordForm(),
12870
+ acceptTerms: new forms.FormControl(false, [forms.Validators.requiredTrue]),
12871
+ referenceCode: new forms.FormControl(referenceCode)
12872
+ }) || this;
12873
+ }
12874
+ RegisterClientForm.prototype.submit = function () {
12875
+ this.markAllAsTouched();
12876
+ if (!this.valid) {
12877
+ return null;
12878
+ }
12879
+ return {
12880
+ firstName: this.value.firstName,
12881
+ lastName: this.value.lastName,
12882
+ email: this.value.email,
12883
+ password: this.value.password.password,
12884
+ referenceCode: this.value.referenceCode
12885
+ };
12886
+ };
12887
+ return RegisterClientForm;
12888
+ }(AbstractForm));
12889
+
12890
+ var RegisterFirmForm = /** @class */ (function (_super) {
12891
+ __extends(RegisterFirmForm, _super);
12892
+ function RegisterFirmForm(firmType, referenceCode) {
12893
+ var _this = _super.call(this, {
12894
+ name: new forms.FormControl('', forms.Validators.required),
12895
+ abn: new forms.FormControl('', forms.Validators.required),
12896
+ tan: new forms.FormControl({ value: '', disabled: firmType !== exports.FirmTypeEnum.ACCOUNTANT }, forms.Validators.required),
12897
+ owner: new RegisterClientForm(referenceCode),
12898
+ type: new forms.FormControl(firmType)
12899
+ }) || this;
12900
+ _this.firmType = firmType;
12901
+ return _this;
12902
+ }
12903
+ RegisterFirmForm.prototype.submit = function () {
12904
+ this.markAllAsTouched();
12905
+ if (!this.valid) {
12906
+ return null;
12907
+ }
12908
+ return classTransformer.plainToClass(Firm, Object.assign({}, this.value, { owner: this.get('owner').submit() }));
12909
+ };
12910
+ return RegisterFirmForm;
12911
+ }(AbstractForm));
12912
+
12913
+ var ResetPasswordForm = /** @class */ (function (_super) {
12914
+ __extends(ResetPasswordForm, _super);
12915
+ function ResetPasswordForm() {
12916
+ return _super.call(this, {
12917
+ email: new forms.FormControl(null, [forms.Validators.required, forms.Validators.email]),
12918
+ }) || this;
12919
+ }
12920
+ return ResetPasswordForm;
12921
+ }(AbstractForm));
12922
+
12782
12923
  /**
12783
12924
  * Public API Surface of tt-core
12784
12925
  */
@@ -12787,6 +12928,7 @@
12787
12928
  * Generated bundle index. Do not edit.
12788
12929
  */
12789
12930
 
12931
+ exports.AbstractForm = AbstractForm;
12790
12932
  exports.Address = Address;
12791
12933
  exports.AddressService = AddressService;
12792
12934
  exports.AppEvent = AppEvent;
@@ -12892,6 +13034,7 @@
12892
13034
  exports.LoanService = LoanService;
12893
13035
  exports.LogbookCollection = LogbookCollection;
12894
13036
  exports.LogbookPeriod = LogbookPeriod;
13037
+ exports.LoginForm = LoginForm;
12895
13038
  exports.MODULE_URL_LIST = MODULE_URL_LIST;
12896
13039
  exports.MONTHS = MONTHS;
12897
13040
  exports.Message = Message;
@@ -12905,6 +13048,7 @@
12905
13048
  exports.NotificationService = NotificationService;
12906
13049
  exports.Occupation = Occupation;
12907
13050
  exports.OccupationService = OccupationService;
13051
+ exports.PasswordForm = PasswordForm;
12908
13052
  exports.PdfService = PdfService;
12909
13053
  exports.Phone = Phone;
12910
13054
  exports.PreloaderService = PreloaderService;
@@ -12928,7 +13072,10 @@
12928
13072
  exports.PropertyService = PropertyService;
12929
13073
  exports.PropertySubscription = PropertySubscription;
12930
13074
  exports.PropertyValuation = PropertyValuation;
13075
+ exports.RegisterClientForm = RegisterClientForm;
13076
+ exports.RegisterFirmForm = RegisterFirmForm;
12931
13077
  exports.RegistrationInvite = RegistrationInvite;
13078
+ exports.ResetPasswordForm = ResetPasswordForm;
12932
13079
  exports.SUBSCRIPTION_DESCRIPTION = SUBSCRIPTION_DESCRIPTION;
12933
13080
  exports.SUBSCRIPTION_TITLE = SUBSCRIPTION_TITLE;
12934
13081
  exports.SalaryForecast = SalaryForecast;