Skip to content

Invoice Split Preview Change Diff Generator #545

Description

@Kingsman-99

Description

When an invoice's split configuration is updated (e.g. a recipient is added, shares are rebalanced), the SDK replaces the entire SplitConfig without showing what changed. Invoice issuers and auditors need to see a typed diff between two split configurations — which recipients were added, removed, or had their ratio changed — before confirming the update. A change diff generator should produce this comparison on demand.

Technical Context

Extend src/splitPreview.ts. Accepts two SplitConfig objects (original and revised). Produces SplitConfigDiff added to src/types.ts with fields: added: RecipientShare[], removed: RecipientShare[], changed: { accountId, oldRatio, newRatio }[], totalRatioDelta. Integrates with src/diff.ts for the generic structural diff utilities. Exposes a generateSplitDiff(original, revised): SplitConfigDiff function exported from src/index.ts.

Acceptance Criteria

  • generateSplitDiff(original, revised) correctly identifies recipients added in revised but absent in original
  • Correctly identifies recipients present in original but absent in revised as removed
  • Correctly identifies recipients present in both with different ratios as changed, with oldRatio and newRatio in the result
  • totalRatioDelta is the signed difference in sum of ratios between the two configs (should be 0 for valid rebalances)
  • Unit tests cover: no change, single add, single remove, ratio rebalance, simultaneous add and remove
  • All CI checks (npm test, npm run build, ESLint/TypeScript) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions