taxtank-core 0.28.70 → 0.28.73
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 +134 -34
- package/bundles/taxtank-core.umd.js.map +1 -1
- package/esm2015/lib/collections/sole/sole-business-losses.collection.js +28 -14
- package/esm2015/lib/forms/sole/sole-invoice.form.js +45 -25
- package/esm2015/lib/models/sole/bas-report.js +19 -1
- package/esm2015/lib/models/sole/sole-business-loss.js +5 -1
- package/esm2015/lib/services/http/sole/sole-invoice/sole-invoice.service.js +12 -1
- package/fesm2015/taxtank-core.js +101 -34
- package/fesm2015/taxtank-core.js.map +1 -1
- package/lib/collections/sole/sole-business-losses.collection.d.ts +7 -1
- package/lib/forms/sole/sole-invoice.form.d.ts +11 -2
- package/lib/models/sole/bas-report.d.ts +6 -0
- package/lib/models/sole/sole-business-loss.d.ts +4 -0
- package/lib/services/http/sole/sole-invoice/sole-invoice.service.d.ts +5 -0
- package/package.json +1 -1
|
@@ -3179,6 +3179,10 @@
|
|
|
3179
3179
|
classTransformer.Type(function () { return SoleBusinessLossOffsetRule; })
|
|
3180
3180
|
], SoleBusinessLossOffsetRule.prototype, "parent", void 0);
|
|
3181
3181
|
|
|
3182
|
+
/**
|
|
3183
|
+
* If a sole trader business makes a tax loss in a current year, you can generally carry forward that loss and offset profit in future years.
|
|
3184
|
+
* https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/4641357930/Rules+when+a+business+makes+a+loss+Tax+Summary#Offsetting-current-year-business-losses
|
|
3185
|
+
*/
|
|
3182
3186
|
var SoleBusinessLoss = /** @class */ (function (_super) {
|
|
3183
3187
|
__extends(SoleBusinessLoss, _super);
|
|
3184
3188
|
function SoleBusinessLoss() {
|
|
@@ -5456,6 +5460,48 @@
|
|
|
5456
5460
|
enumerable: false,
|
|
5457
5461
|
configurable: true
|
|
5458
5462
|
});
|
|
5463
|
+
Object.defineProperty(BasReport.prototype, "paygTaxInstalmentOwedToATO", {
|
|
5464
|
+
get: function () {
|
|
5465
|
+
return this.paygTaxInstalment > 0 ? this.paygTaxInstalment : 0;
|
|
5466
|
+
},
|
|
5467
|
+
enumerable: false,
|
|
5468
|
+
configurable: true
|
|
5469
|
+
});
|
|
5470
|
+
Object.defineProperty(BasReport.prototype, "paygTaxInstalmentOwedByATO", {
|
|
5471
|
+
get: function () {
|
|
5472
|
+
return this.paygTaxInstalment < 0 ? Math.abs(this.paygTaxInstalment) : 0;
|
|
5473
|
+
},
|
|
5474
|
+
enumerable: false,
|
|
5475
|
+
configurable: true
|
|
5476
|
+
});
|
|
5477
|
+
Object.defineProperty(BasReport.prototype, "fuelTaxCreditOwedToATO", {
|
|
5478
|
+
get: function () {
|
|
5479
|
+
return this.fuelTaxCredit < 0 ? this.fuelTaxCredit : 0;
|
|
5480
|
+
},
|
|
5481
|
+
enumerable: false,
|
|
5482
|
+
configurable: true
|
|
5483
|
+
});
|
|
5484
|
+
Object.defineProperty(BasReport.prototype, "fuelTaxCreditOwedByATO", {
|
|
5485
|
+
get: function () {
|
|
5486
|
+
return this.fuelTaxCredit > 0 ? Math.abs(this.fuelTaxCredit) : 0;
|
|
5487
|
+
},
|
|
5488
|
+
enumerable: false,
|
|
5489
|
+
configurable: true
|
|
5490
|
+
});
|
|
5491
|
+
Object.defineProperty(BasReport.prototype, "owesToATO", {
|
|
5492
|
+
get: function () {
|
|
5493
|
+
return this.incomeGST + this.taxWithheldTotal + this.paygTaxInstalmentOwedToATO + this.fuelTaxCreditOwedToATO;
|
|
5494
|
+
},
|
|
5495
|
+
enumerable: false,
|
|
5496
|
+
configurable: true
|
|
5497
|
+
});
|
|
5498
|
+
Object.defineProperty(BasReport.prototype, "owedByATO", {
|
|
5499
|
+
get: function () {
|
|
5500
|
+
return this.expenseGST + this.paygTaxInstalmentOwedByATO + this.fuelTaxCreditOwedByATO;
|
|
5501
|
+
},
|
|
5502
|
+
enumerable: false,
|
|
5503
|
+
configurable: true
|
|
5504
|
+
});
|
|
5459
5505
|
Object.defineProperty(BasReport.prototype, "gst", {
|
|
5460
5506
|
/**
|
|
5461
5507
|
* GST payable to the ATO, or refundable from the ATO in case it's negative
|
|
@@ -7591,27 +7637,42 @@
|
|
|
7591
7637
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
7592
7638
|
}
|
|
7593
7639
|
/**
|
|
7594
|
-
*
|
|
7640
|
+
* Business loss applied in current year, includes previous year losses and current year losses for businesses matching offset rule
|
|
7595
7641
|
*/
|
|
7596
7642
|
SoleBusinessLossesCollection.prototype.calculateBusinessLossApplied = function (transactions) {
|
|
7597
7643
|
var _this = this;
|
|
7598
|
-
|
|
7599
|
-
|
|
7644
|
+
// claim amounts for businesses that can be applied to be reduced by prior year business losses
|
|
7645
|
+
var claimAmountsByBusinessId = this.getClaimAmountsByBusinessId(transactions);
|
|
7646
|
+
return Object.keys(claimAmountsByBusinessId.items).reduce(function (sum, businessId) {
|
|
7647
|
+
var loss = _this.findBy('business.id', +businessId);
|
|
7648
|
+
var lossOpenBalance = (loss === null || loss === void 0 ? void 0 : loss.openBalance) || 0;
|
|
7649
|
+
// business loss can be applied to business profit or other income types profit in case in offset rule met
|
|
7650
|
+
return sum + (loss.offsetRule ? lossOpenBalance : Math.min(lossOpenBalance, claimAmountsByBusinessId.get(businessId)));
|
|
7651
|
+
}, 0);
|
|
7652
|
+
};
|
|
7653
|
+
/**
|
|
7654
|
+
* Get business claim amounts that can be applied to be reduced by prior year business losses:
|
|
7655
|
+
* businesses with income or businesses with a loss, but which met the non-commercial loss rules
|
|
7656
|
+
* https://www.ato.gov.au/Business/Non-commercial-losses/
|
|
7657
|
+
*/
|
|
7658
|
+
SoleBusinessLossesCollection.prototype.getClaimAmountsByBusinessId = function (transactions) {
|
|
7659
|
+
var _this = this;
|
|
7600
7660
|
var claimAmountsByBusinessId = new Dictionary([]);
|
|
7601
|
-
|
|
7602
|
-
|
|
7661
|
+
var transactionsByBusinessId = new CollectionDictionary(transactions, 'business.id');
|
|
7662
|
+
transactionsByBusinessId.keys.forEach(function (businessId) {
|
|
7663
|
+
var _a;
|
|
7664
|
+
// business loss may not exist if, when creating a business, user didn't add losses for previous years
|
|
7665
|
+
var lossOffsetRule = (_a = _this.findBy('business.id', +businessId)) === null || _a === void 0 ? void 0 : _a.offsetRule;
|
|
7666
|
+
var businessClaimAmount = transactionsByBusinessId
|
|
7603
7667
|
.get(businessId)
|
|
7604
7668
|
.getClaimAmountByBusinessId(+businessId);
|
|
7605
|
-
//
|
|
7606
|
-
if (businessClaimAmount
|
|
7607
|
-
|
|
7669
|
+
// no way to apply loss for business without profit if offset rules not met
|
|
7670
|
+
if (businessClaimAmount < 0 && !lossOffsetRule) {
|
|
7671
|
+
return;
|
|
7608
7672
|
}
|
|
7673
|
+
claimAmountsByBusinessId.add(businessId, businessClaimAmount);
|
|
7609
7674
|
});
|
|
7610
|
-
return
|
|
7611
|
-
var _a;
|
|
7612
|
-
var lossOpenBalance = ((_a = _this.findBy('business.id', +businessId)) === null || _a === void 0 ? void 0 : _a.openBalance) || 0;
|
|
7613
|
-
return sum + Math.min(lossOpenBalance, claimAmountsByBusinessId.get(businessId));
|
|
7614
|
-
}, 0);
|
|
7675
|
+
return claimAmountsByBusinessId;
|
|
7615
7676
|
};
|
|
7616
7677
|
return SoleBusinessLossesCollection;
|
|
7617
7678
|
}(Collection));
|
|
@@ -12916,6 +12977,16 @@
|
|
|
12916
12977
|
SoleInvoiceService.prototype.sendEmail = function (invoice) {
|
|
12917
12978
|
return this.http.post(this.environment.apiV2 + "/" + this.url + "/" + invoice.id + "/send", {});
|
|
12918
12979
|
};
|
|
12980
|
+
/**
|
|
12981
|
+
* Return the next number from the last invoice.
|
|
12982
|
+
* Basically needed to create a new invoice to show its number when the invoice has not yet been sent to the backend
|
|
12983
|
+
*/
|
|
12984
|
+
SoleInvoiceService.prototype.getNewInvoiceNumber = function () {
|
|
12985
|
+
if (!this.cache) {
|
|
12986
|
+
return 0;
|
|
12987
|
+
}
|
|
12988
|
+
return last__default["default"](this.cache).number + 1;
|
|
12989
|
+
};
|
|
12919
12990
|
return SoleInvoiceService;
|
|
12920
12991
|
}(RestService));
|
|
12921
12992
|
SoleInvoiceService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleInvoiceService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
@@ -18978,32 +19049,38 @@
|
|
|
18978
19049
|
return SoleInvoiceItemForm;
|
|
18979
19050
|
}(AbstractForm));
|
|
18980
19051
|
|
|
19052
|
+
/**
|
|
19053
|
+
* Form is divided into two groups, since the creation of Sole invoice takes place in two steps:
|
|
19054
|
+
* a common invoice data and sole invoice items.
|
|
19055
|
+
*/
|
|
18981
19056
|
var SoleInvoiceForm = /** @class */ (function (_super) {
|
|
18982
19057
|
__extends(SoleInvoiceForm, _super);
|
|
18983
19058
|
function SoleInvoiceForm(invoice, soleDetailsGST,
|
|
18984
19059
|
// default template to be preselected
|
|
18985
19060
|
defaultTemplate) {
|
|
18986
19061
|
var _this = _super.call(this, {
|
|
18987
|
-
|
|
18988
|
-
|
|
19062
|
+
commonData: new forms.FormGroup({
|
|
19063
|
+
dateFrom: new forms.FormControl(invoice.dateFrom || new Date(), forms.Validators.required),
|
|
19064
|
+
dateTo: new forms.FormControl(invoice.dateTo, forms.Validators.required),
|
|
19065
|
+
payer: new forms.FormControl(invoice.payer, forms.Validators.required),
|
|
19066
|
+
taxType: new forms.FormControl(invoice.taxType, forms.Validators.required),
|
|
19067
|
+
bankAccount: new forms.FormControl(invoice.bankAccount, forms.Validators.required),
|
|
19068
|
+
reference: new forms.FormControl(invoice.reference)
|
|
19069
|
+
}),
|
|
18989
19070
|
items: new forms.FormArray((invoice.items || [classTransformer.plainToClass(SoleInvoiceItem, {})]).map(function (item) { return new SoleInvoiceItemForm(item); })),
|
|
18990
|
-
payer: new forms.FormControl(invoice.payer, forms.Validators.required),
|
|
18991
|
-
taxType: new forms.FormControl(invoice.taxType, forms.Validators.required),
|
|
18992
|
-
bankAccount: new forms.FormControl(invoice.bankAccount, forms.Validators.required),
|
|
18993
|
-
reference: new forms.FormControl(invoice.reference)
|
|
18994
19071
|
}, invoice) || this;
|
|
18995
19072
|
_this.invoice = invoice;
|
|
18996
19073
|
_this.soleDetailsGST = soleDetailsGST;
|
|
18997
19074
|
_this.defaultTemplate = defaultTemplate;
|
|
18998
19075
|
// we need invoice template only for new invoices
|
|
18999
19076
|
if (!invoice.id) {
|
|
19000
|
-
_this.addControl('template', new forms.FormControl(_this.defaultTemplate));
|
|
19077
|
+
(_this.commonData).addControl('template', new forms.FormControl(_this.defaultTemplate));
|
|
19001
19078
|
_this.updateTemplateRelatedFields(_this.defaultTemplate);
|
|
19002
19079
|
}
|
|
19003
19080
|
// invoice.taxType is always NONE ('No Tax') when soleDetails.isGST === false
|
|
19004
19081
|
if (!_this.soleDetailsGST) {
|
|
19005
|
-
_this.get('taxType').setValue(exports.SoleInvoiceTaxTypeEnum.NO_TAX);
|
|
19006
|
-
_this.get('taxType').disable();
|
|
19082
|
+
_this.commonData.get('taxType').setValue(exports.SoleInvoiceTaxTypeEnum.NO_TAX);
|
|
19083
|
+
_this.commonData.get('taxType').disable();
|
|
19007
19084
|
// Items isGST is not available when invoice.taxType === NONE ('No Tax')
|
|
19008
19085
|
_this.items.controls.forEach(function (itemForm) {
|
|
19009
19086
|
_this.disableItemGST(itemForm);
|
|
@@ -19029,8 +19106,8 @@
|
|
|
19029
19106
|
_this.listenItemChartAccountsChanges(itemForm);
|
|
19030
19107
|
});
|
|
19031
19108
|
}
|
|
19032
|
-
// nothing to listen if template field is not
|
|
19033
|
-
if (this.contains('template')) {
|
|
19109
|
+
// nothing to listen if template field is not exist (edit invoice case)
|
|
19110
|
+
if ((this.commonData).contains('template')) {
|
|
19034
19111
|
this.listenTemplateChanges();
|
|
19035
19112
|
}
|
|
19036
19113
|
};
|
|
@@ -19048,16 +19125,21 @@
|
|
|
19048
19125
|
};
|
|
19049
19126
|
SoleInvoiceForm.prototype.submit = function (data) {
|
|
19050
19127
|
if (data === void 0) { data = {}; }
|
|
19051
|
-
|
|
19052
|
-
|
|
19053
|
-
|
|
19128
|
+
this.submitted = true;
|
|
19129
|
+
this.markAllAsTouched();
|
|
19130
|
+
if (!this.disabled && !this.valid) {
|
|
19131
|
+
return null;
|
|
19132
|
+
}
|
|
19133
|
+
var invoiceInstance = this.currentValue;
|
|
19134
|
+
this.onSubmit.emit(invoiceInstance);
|
|
19135
|
+
return invoiceInstance;
|
|
19054
19136
|
};
|
|
19055
19137
|
/**
|
|
19056
19138
|
* Update default values from selected invoice template
|
|
19057
19139
|
*/
|
|
19058
19140
|
SoleInvoiceForm.prototype.listenTemplateChanges = function () {
|
|
19059
19141
|
var _this = this;
|
|
19060
|
-
this.get('template').valueChanges.subscribe(function (template) {
|
|
19142
|
+
this.commonData.get('template').valueChanges.subscribe(function (template) {
|
|
19061
19143
|
_this.updateTemplateRelatedFields(template);
|
|
19062
19144
|
});
|
|
19063
19145
|
};
|
|
@@ -19066,7 +19148,7 @@
|
|
|
19066
19148
|
*/
|
|
19067
19149
|
SoleInvoiceForm.prototype.listenTaxTypeChanges = function () {
|
|
19068
19150
|
var _this = this;
|
|
19069
|
-
this.get('taxType').valueChanges.subscribe(function (type) {
|
|
19151
|
+
this.commonData.get('taxType').valueChanges.subscribe(function (type) {
|
|
19070
19152
|
_this.items.controls.forEach(function (itemForm) {
|
|
19071
19153
|
var chartAccounts = itemForm.get('chartAccounts').value;
|
|
19072
19154
|
// Item GST is available when invoice.taxType !== NONE ('No Tax')
|
|
@@ -19079,18 +19161,18 @@
|
|
|
19079
19161
|
});
|
|
19080
19162
|
};
|
|
19081
19163
|
SoleInvoiceForm.prototype.updateTemplateRelatedFields = function (template) {
|
|
19082
|
-
this.get('bankAccount').setValue(template.bankAccount);
|
|
19083
|
-
var dateFrom = this.get('dateFrom').value;
|
|
19164
|
+
this.commonData.get('bankAccount').setValue(template.bankAccount);
|
|
19165
|
+
var dateFrom = this.commonData.get('dateFrom').value;
|
|
19084
19166
|
if (dateFrom) {
|
|
19085
|
-
this.get('dateTo').setValue(new Date(dateFrom.getTime() + template.termTime));
|
|
19167
|
+
this.commonData.get('dateTo').setValue(new Date(dateFrom.getTime() + template.termTime));
|
|
19086
19168
|
}
|
|
19087
19169
|
// invoice.taxType is always 'No Tax' when soleDetails.isGST = false and not available for changing
|
|
19088
19170
|
if (this.soleDetailsGST) {
|
|
19089
|
-
this.get('taxType').setValue(template.taxType);
|
|
19171
|
+
this.commonData.get('taxType').setValue(template.taxType);
|
|
19090
19172
|
}
|
|
19091
19173
|
};
|
|
19092
19174
|
/**
|
|
19093
|
-
* GST availability depends
|
|
19175
|
+
* GST availability depends on chart accounts isGST flag
|
|
19094
19176
|
*/
|
|
19095
19177
|
SoleInvoiceForm.prototype.listenItemChartAccountsChanges = function (itemForm) {
|
|
19096
19178
|
var _this = this;
|
|
@@ -19115,6 +19197,24 @@
|
|
|
19115
19197
|
itemForm.get('isGST').setValue(true);
|
|
19116
19198
|
itemForm.get('isGST').enable();
|
|
19117
19199
|
};
|
|
19200
|
+
Object.defineProperty(SoleInvoiceForm.prototype, "commonData", {
|
|
19201
|
+
get: function () {
|
|
19202
|
+
return this.get('commonData');
|
|
19203
|
+
},
|
|
19204
|
+
enumerable: false,
|
|
19205
|
+
configurable: true
|
|
19206
|
+
});
|
|
19207
|
+
Object.defineProperty(SoleInvoiceForm.prototype, "currentValue", {
|
|
19208
|
+
/**
|
|
19209
|
+
* Rewrite abstract form getter to flat "commonData" field, which is not in the class
|
|
19210
|
+
*/
|
|
19211
|
+
get: function () {
|
|
19212
|
+
var formRawValue = this.getRawValue();
|
|
19213
|
+
return classTransformer.plainToClass(SoleInvoice, Object.assign({}, this.model, Object.assign(Object.assign({}, formRawValue.commonData), { items: formRawValue.items })));
|
|
19214
|
+
},
|
|
19215
|
+
enumerable: false,
|
|
19216
|
+
configurable: true
|
|
19217
|
+
});
|
|
19118
19218
|
return SoleInvoiceForm;
|
|
19119
19219
|
}(AbstractForm));
|
|
19120
19220
|
|