Can an Amount Be Negative? Business Rules vs Type Rules

writes all amount fields as minimum: 0, though seemingly rigorous on the surface, ends up blocking legitimate refund records. Whether the amount has been conver

Negative amounts are often legitimate, especially for refunds and credit memos. Rules that force every amount to be zero or above can reject valid records, so it helps to separate two questions: whether the value has been read as a number, and whether this transaction type allows negative numbers.

This guide is for anyone who validates financial data from forms, APIs or scanned documents. It explains how to decide what a minus sign means, how to choose the right JSON Schema keyword, and how to report errors without losing the clues you need to fix them.

Start by settling the meaning of the sign for each field. Then write the constraint to match. You will also see how to keep error reports useful and how to check amounts and types together before delivery.

Can an amount be negative? The short answer

Only if the business meaning of the field allows it: refunds may be negative, while standard charges are usually non-negative, so define the convention for each field before you write the rule.

Your situationWhat to doWhy
Refunds are recorded as negative numbersDefine the sign convention for each field before writing the ruleminimum: 0 blocks legitimate refund records
The business requires strictly positive amountsUse exclusiveMinimumIt excludes the boundary, unlike minimum
Free items, write-offs or estimated values existList these scenarios and allow zeroOtherwise they are misclassified as errors
The amount is a string or the type is missingReject the record and check the sourceThe document type should not be inferred from the sign of the amount

Start by deciding what the minus sign means

Before you write any rule, confirm what a negative number represents in the document.

  • The sample protocol: standard charges are non-negative, and refunds are represented by negative amounts.
  • The alternative: some systems use "positive amounts plus refund types" instead.
  • Both are valid, but you must not leave the choice to the reader within the same interface.
  • The zero boundary in this sample is a protocol choice, not a unified industry standard.

Whether the amount has been converted into a numeric value and whether this transaction permits negative numbers are two separate issues. Check the meaning of the document first, then define the scope rules.

Let the transaction type set the constraint

Choose the keyword based on the business rule, not on habit.

  • minimum includes the boundary, so minimum: 0 accepts zero.
  • exclusiveMinimum excludes the boundary. If the business requirement is strictly positive, do not use minimum: 0.
  • Before you choose, list every scenario that permits zero values, such as free items, write-offs and estimated values. This stops you from flagging them as errors.
from jsonschema import Draft202012Validator

schema = {
    "type": "object", "required": ["kind", "amount"],
    "additionalProperties": False,
    "properties": {"kind": {"enum": ["charge", "refund"]},
                   "amount": {"type": "number"}},
    "allOf": [
        {"if": {"properties": {"kind": {"const": "charge"}}},
         "then": {"properties": {"amount": {"minimum": 0}}}},
        {"if": {"properties": {"kind": {"const": "refund"}}},
         "then": {"properties": {"amount": {"exclusiveMaximum": 0}}}}
    ]
}
v = Draft202012Validator(schema)
valid = lambda x: not list(v.iter_errors(x))
assert valid({"kind": "charge", "amount": 0})
assert valid({"kind": "refund", "amount": -12.5})
assert not valid({"kind": "refund", "amount": 12.5})
assert not valid({"kind": "charge", "amount": True})
assert not valid({"amount": 12.5})

The example depends on jsonschema and is validated against Draft 2020-12. It does not perform currency conversion, and it does not check that subtotals match totals.

Currency calculations need explicit precision and rounding rules. Do not accumulate values with floating-point arithmetic just because the data passes the schema.

Report errors with business context

Each error should explain what was observed, what this process does with it, and what still needs checking.

ObservationWhat this process doesWhat still needs to be verified
Refund is a positive numberRejects itWhether a minus sign was lost, or whether the source uses another convention
Charge is zeroAccepts the structureWhether it is a free item
Amount is a stringRejects it as the wrong typeThousand separator, currency and decimal rules
Type is missingRejects itDoes not infer the document type from the sign of the amount

Do not mask errors with an automatic absolute value

It can be tempting to wrap every amount in an absolute value function. Do not do it.

  • OCR can miss hyphens, or read a negative sign as a different character.
  • Your business may use the opposite sign convention, which can produce the same anomaly.
  • Calling abs() removes the most important diagnostic clue.

Keep the original text segment, the page number and the pre-parsing string. Then decide whether to re-extract the data or review it manually.

Check amounts and types together at delivery

When you process documents that contain monetary amounts, use this rule table as part of post-editing validation. Checking that no numbers are missing is not enough. Also confirm that context such as refunds and credit memos has not changed.

Tools such as OmniDoc can help with translation, but the business side should still explicitly confirm the agreed monetary terms.

Before you process important files

The code and examples here use synthetic samples and were checked in an isolated environment. That does not guarantee they will work for every real file or product.

  • Keep the original copies of any important files.
  • Verify results against the boundaries and acceptance criteria in this document.

📊 At a glance

QuestionOption A: minus sign for refundsOption B: positive amounts plus refund typeOption C: strictly positive (exclusiveMinimum)
How is a refund shown?As a negative amountAs a positive amount with a refund typeNot as a negative amount
Keyword that fitsDepends on the field's rulesDepends on the field's rulesexclusiveMinimum excludes zero
Main watch-outDefine the convention for each fieldKeep the type and amount consistentZero must be handled as a special case

🎯 Which approach fits you?

If you record refunds as negative numbers

Define the sign convention for each refund field and avoid a blanket minimum: 0 rule, which would reject those records.

If you record positive amounts and mark refunds with a type

Make sure the refund type is always present, and do not infer the type from the sign of the amount.

If the business requires strictly positive amounts

Use exclusiveMinimum and list the scenarios that need special handling.

❓ FAQ

1. Why does minimum: 0 cause problems for refunds?

It accepts zero and positive values only, so legitimate negative refund records are rejected.

2. What is the difference between minimum and exclusiveMinimum?

minimum includes the boundary value, while exclusiveMinimum excludes it.

3. Should I use abs() to fix a negative sign that looks wrong?

No. It hides the evidence you need, so keep the original text and page number and decide whether to re-extract or review.

4. Does this schema check that totals add up?

No. It does not perform currency conversion or verify the relationship between subtotals and totals.

📝 Summary

Decide what a negative amount means for each field, then choose minimum or exclusiveMinimum to match that meaning. Keep the original context whenever a value looks wrong.

Try it now: upload a document and get it translated with the layout intact

Reference: JSON Schema numeric constraints

Updated 2026-11-04