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

  1. Import aud, GrossPay and the AU SDK helper.
  2. Build the canonical gross pay fact.
  3. Call au.pay.takeHomePay.
  4. Check user input before the call and handle calculation failures with the safe helper.

Example

ts
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:

json
{ "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:

ts
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);
}