Billing's usage total is labeled at price, and Usage says what part of it was paid for
syntaqx's Billing said $9.14 of usage and its Usage $6.01 spent: the first is at price, the second what was charged after the trial and pools paid their $3.13. Usage now returns covered_micros and its Spent card says so; Billing's total reads Total at price.
6 files+25−70/6 viewed
| 118 | 118 | **This month's usage**: what each kind of usage has come to so far, in | |
| 119 | 119 | dollars and in what was used (*Agents & sandboxes*, *Builds*, *Requests & | |
| 120 | 120 | CPU*, *Custom domains*, *Git operations & storage*, *Search & security | |
| 121 | − | scans*). App traffic, custom domains, storage and git operations are | |
| 122 | − | counted through the month and charged when it closes. **Manage on Stripe** opens the card, invoices and | |
| 121 | + | scans*). Its **Total at price** is before the included usage, the trial or | |
| 122 | + | a pool paid their part, so it can be more than what was charged; the | |
| 123 | + | workspace's **Usage** page shows what was charged as **Spent**, and how much | |
| 124 | + | of the total those paid. App traffic, custom domains, storage and git | |
| 125 | + | operations are counted through the month and charged when it closes. **Manage on Stripe** opens the card, invoices and | |
| 123 | 126 | billing details. **End at the end of the period** ends the plan then, with | |
| 124 | 127 | nothing more charged after; **Keep the plan** takes that back until then. | |
| 125 | 128 | If a renewal payment fails, the card says **Payment failed**, with |
| 346 | 346 | ))} | |
| 347 | 347 | </ul> | |
| 348 | 348 | <div className="mt-1 flex items-baseline justify-between gap-4 border-t border-line pt-2.5 text-sm"> | |
| 349 | − | <span className="font-medium">Total</span> | |
| 349 | + | {/* At price, before the plan's included usage, the trial and the pools paid | |
| 350 | + | their part: Usage shows what was charged. */} | |
| 351 | + | <span className="font-medium">Total at price</span> | |
| 350 | 352 | <span className="font-medium tabular-nums">{dollars(total)}</span> | |
| 351 | 353 | </div> | |
| 352 | 354 | <p className="mt-2 text-xs text-faint"> | |
| 354 | 356 | ? "What this workspace's usage would cost. g1t covers it." | |
| 355 | 357 | : on | |
| 356 | 358 | ? `Drawn from the included usage first, then charged up to your spend limit. Projects, previews and repositories are never charged, and the first ${freeStorage} of private storage and ${freeGit} git operations a month are free. App traffic, custom domains, storage and git operations are counted through the month and charged when it closes.` | |
| 357 | − | : `The forge is free: ${freeStorage} of private storage and ${freeGit} git operations a month. Agents run from the trial or the open-source pool.`} | |
| 359 | + | : `The forge is free: ${freeStorage} of private storage and ${freeGit} git operations a month. Agents run from the trial or the open-source pool, which pay part of this total: Usage shows what was charged.`} | |
| 358 | 360 | </p> | |
| 359 | 361 | </div> | |
| 360 | 362 | ); |
| 228 | 228 | label="Spent" | |
| 229 | 229 | value={dollars(usage.spentMicros)} | |
| 230 | 230 | note={ | |
| 231 | − | usage.providerMicros > 0 | |
| 232 | − | ? `Plus about ${dollars(usage.providerMicros)} billed by your own model provider` | |
| 233 | − | : `${dollars(usage.costMicros)} of it the model provider's` | |
| 231 | + | (usage.coveredMicros ?? 0) > 0 | |
| 232 | + | ? `Of ${dollars(usage.spentMicros + (usage.coveredMicros ?? 0))} at price: ${dollars(usage.coveredMicros ?? 0)} of it was paid by the included usage, the trial or a pool` | |
| 233 | + | : usage.providerMicros > 0 | |
| 234 | + | ? `Plus about ${dollars(usage.providerMicros)} billed by your own model provider` | |
| 235 | + | : `${dollars(usage.costMicros)} of it the model provider's` | |
| 234 | 236 | } | |
| 235 | 237 | /> | |
| 236 | 238 | )} |
| 324 | 324 | pub since: String, | |
| 325 | 325 | /// Charged, including g1t's margin. | |
| 326 | 326 | pub spent_micros: i64, | |
| 327 | + | /// What paid for usage before it was charged, at price: the plan's | |
| 328 | + | /// included usage, the trial, the open-source pool and what g1t | |
| 329 | + | /// covered. Usage at price is `spent_micros` plus this. | |
| 330 | + | #[serde(default)] | |
| 331 | + | pub covered_micros: i64, | |
| 327 | 332 | /// What g1t's model provider charged, before the margin. | |
| 328 | 333 | pub cost_micros: i64, | |
| 329 | 334 | /// What runs on the workspace's own provider cost there, as the harness |
| 1014 | 1014 | since: string; | |
| 1015 | 1015 | /** Charged, including g1t's margin. */ | |
| 1016 | 1016 | spentMicros: number; | |
| 1017 | + | /** What paid for usage before it was charged, at price: the plan's included usage, the trial, the open-source pool, what g1t covered. Usage at price is `spentMicros` plus this. */ | |
| 1018 | + | coveredMicros?: number; | |
| 1017 | 1019 | /** What g1t's model provider charged, before the margin. */ | |
| 1018 | 1020 | costMicros: number; | |
| 1019 | 1021 | /** What runs on the workspace's own provider cost there, estimated. Not charged by g1t. */ |
| 428 | 428 | #[derive(serde::Deserialize)] | |
| 429 | 429 | struct Totals { | |
| 430 | 430 | spent: Option<i64>, | |
| 431 | + | covered: Option<i64>, | |
| 431 | 432 | cost: Option<i64>, | |
| 432 | 433 | provider: Option<i64>, | |
| 433 | 434 | runs: Option<u32>, | |
| 438 | 439 | .prepare( | |
| 439 | 440 | "SELECT | |
| 440 | 441 | -SUM(CASE WHEN kind = 'usage' THEN amount_micros END) AS spent, | |
| 442 | + | SUM(CASE WHEN kind = 'usage' THEN credit_micros + trial_micros + oss_micros + given_micros END) AS covered, | |
| 441 | 443 | SUM(CASE WHEN kind = 'usage' AND COALESCE(billed_to, 'g1t') = 'g1t' THEN cost_micros END) AS cost, | |
| 442 | 444 | SUM(CASE WHEN kind = 'usage' AND billed_to = 'workspace' THEN cost_micros END) AS provider, | |
| 443 | 445 | SUM(CASE WHEN kind = 'usage' THEN 1 ELSE 0 END) AS runs, | |
| 463 | 465 | .await?; | |
| 464 | 466 | let totals = totals.unwrap_or(Totals { | |
| 465 | 467 | spent: None, | |
| 468 | + | covered: None, | |
| 466 | 469 | cost: None, | |
| 467 | 470 | provider: None, | |
| 468 | 471 | runs: None, | |
| 470 | 473 | }); | |
| 471 | 474 | Ok(Outcome::Ok(Usage { | |
| 472 | 475 | spent_micros: totals.spent.unwrap_or_default(), | |
| 476 | + | covered_micros: totals.covered.unwrap_or_default(), | |
| 473 | 477 | cost_micros: totals.cost.unwrap_or_default(), | |
| 474 | 478 | provider_micros: totals.provider.unwrap_or_default(), | |
| 475 | 479 | used_micros: totals.cost.unwrap_or_default() + totals.provider.unwrap_or_default(), |