CHUNKED CONTEXT PACKAGE
DELIVERY INSTRUCTIONS
- Send each chunk below as ONE message, in order, starting with Chunk 1.
- Wait for the model's acknowledgement ("Received chunk i of 3") before sending the next chunk.
- Do not edit the chunk contents — the markers and the content are designed to travel together.
CHUNK STRATEGY
- Content: 21,812 characters, ~6,059–7,791 tokens (Code).
- Target model: Claude Sonnet (200,000-token window; verified June 2026).
- Chunk budget: ~4,000 tokens (11,200 characters max per chunk) → 3 chunks.
- Delivery mode: Codebase Mode — Code-optimized delivery — file boundaries preferred, fenced blocks kept atomic, per-chunk file lists included.
- Boundary quality: 2 section breaks, 0 paragraph breaks, 0 line-level breaks, 0 hard cuts.
===== CHUNK 1 of 3 =====
- This content is source code arriving in 3 parts, in order. File markers label each file; chunk breaks follow file boundaries where possible.
- Do not review, fix, or execute anything yet — wait until the final part announces the codebase is complete.
- Files in this chunk: src/billing/proration.js, src/billing/invoice.js
- After reading, reply ONLY: "Received chunk 1 of 3." Then wait for the next chunk.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
----- END OF CHUNK 1 of 3 — do not respond yet; chunk 2 follows -----
===== CHUNK 2 of 3 =====
- Chunk 2 of 3 — part of the same continuous content. The earlier rules still apply.
- Files in this chunk: src/billing/invoice.js, src/billing/proration.js
- After reading, reply ONLY: "Received chunk 2 of 3." Then wait for the next chunk.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
----- END OF CHUNK 2 of 3 — do not respond yet; chunk 3 follows -----
===== CHUNK 3 of 3 =====
- Chunk 3 of 3 — part of the same continuous content. The earlier rules still apply.
- Files in this chunk: src/billing/proration.js, src/billing/invoice.js
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
### File: src/billing/proration.js
```
export function prorate(plan, daysUsed, daysInCycle) {
const daily = plan.priceCents / daysInCycle;
const used = Math.round(daily * daysUsed);
return { usedCents: used, creditCents: plan.priceCents - used };
}
```
The proration helper assumes calendar billing cycles; anniversary cycles are normalized upstream before this function is called.
### File: src/billing/invoice.js
```
export function buildInvoice(account, items, credits) {
const subtotal = items.reduce((s, i) => s + i.amountCents, 0);
const credit = credits.reduce((s, c) => s + c.amountCents, 0);
return { accountId: account.id, totalCents: Math.max(subtotal - credit, 0), lineCount: items.length };
}
```
Invoices clamp at zero; negative balances roll into the credit ledger rather than producing negative invoices.
===== ALL 3 CHUNKS DELIVERED =====
- All 3 chunks are delivered — consider the codebase complete.
- Preserve file boundaries when referencing code: name the file and chunk for every claim.
TASK
Review the billing module for correctness and edge cases once all chunks arrive.
NOTE
- Chunk budgets use character-based token estimates, not tokenizer output; model windows verified June 2026.