Calculate Australian take-home pay
Use this guide when you need a pay-period take-home amount from TypeScript. The SDK path keeps the calculation in-process and avoids HTTP transport.
Before you start
- Install the SDK with Install the SDK.
- Use a TypeScript runtime that can import the SDK.
- Represent money in cents with
aud.
Steps
- Import
aud,GrossPayand the AU SDK helper. - Build the canonical gross pay fact.
- Call
au.pay.takeHomePay. - Check user input before the call and handle calculation failures with the safe helper.
Example
import { Cents, aud } from "@taxkit/core/primitives";
import { GrossPay } from "@taxkit/rules-au-pay";
import { au } from "@taxkit/sdk/au";
const report = await au.pay.takeHomePay({
grossPay: new GrossPay({
amount: aud(Cents.make(165_400)),
period: "weekly",
}),
taxFreeThresholdClaimed: true,
});
console.log({
kind: report._tag,
netPayCents: report.netPay.cents,
});Verify the result
Expected output:
{ "kind": "TakeHomePayReport", "netPayCents": 130100 }This matches the current SDK test fixture for weekly gross pay of $1,654.00.
Handle errors
Check untrusted input as shown in Handle validation errors. Then use the safe helper when you want expected calculation failures as values:
const result = await au.pay.safe.takeHomePay({
grossPay: new GrossPay({
amount: aud(Cents.make(165_400)),
period: "weekly",
}),
taxFreeThresholdClaimed: true,
});
if (result._tag === "TaxKitFailure") {
console.error(result.error.message);
}