On this page
DocumentationConcepts

Money and branded values

Money is signed AUD in safe integer cents. Constructors name their units. Numeric dollars are not accepted: decimal text converts exactly, and more than two fractional digits fail.

TypeScript
import { calculateSafe } from "taxkit";
import { AuPayTakeHomeCalculation } from "taxkit/au";
import { TakeHomeScenarioInputSchema } from "taxkit/au/schemas";
import { fromDecimal, nonNegative } from "taxkit/money";
import { Result } from "effect";

const input = Result.gen(function* () {
  const grossPay = yield* fromDecimal("1654.00").pipe(
    Result.flatMap(nonNegative)
  );
  return TakeHomeScenarioInputSchema.make({
    grossPay,
    period: "weekly",
    taxFreeThresholdClaimed: true,
  });
});
if (Result.isSuccess(input)) {
  const result = await calculateSafe(AuPayTakeHomeCalculation, input.success);
  if (Result.isSuccess(result)) {
    result.success.netPay.cents;
  } else {
    result.failure._tag;
  }
}

fromCents(number), fromDecimal(string), add and subtract return native Result. nonNegative(money) establishes the refinement required by gross pay, salary sacrifice and annual taxable-income scenarios. The Effect entrypoint lifts these same operations lazily.

format emits two decimal digits and round-trips signed Money. MoneyFromDecimalString and NonNegativeMoneyFromDecimalString are native codecs. Arithmetic checks overflow and subtraction returns signed Money. round requires a named policy; statutory formulas retain Effect BigDecimal and their legal rounding step.