Repository navigation
feat: hourly billing, credit-only hourly plans, owner VM delete with credit refunds - #428
Merged
Merged
Conversation
- Refund unused time to credit for every interval and every payment method: credit parts as debited, cash parts at today's rate - Deactivate only the deleted VM's line item on a shared subscription (new subscription_line_item.deactivated_at); end the subscription when nothing on it is active, and skip deactivated items in renewals - Book each refund row and its credit event in one transaction, once - No notification for successful hourly credit renewals - Refuse hourly orders up front when credit cannot cover the first hour - Hourly VM LNURL payments top up account credit - Owner refunds are not logged as admin actions
subscription_line_item.parent_line_item_id marks an add-on (e.g. paid VM snapshots). Deleting a VM deactivates its line and every add-on below it, ends the subscription when nothing independent of the VM is left, and refunds the add-ons' share with the VM's.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an hourly billing interval so a VM can run on account credit, and lets users delete a VM, stop its billing and get the unused time back as credit.
IntervalType::Hour(= 3, sameSMALLINTcolumn). Handled in pricing, expiry,mysql.rs, worker, discount engine, admin MRR report,MockDb, and the API enum ("hour").POST /api/v1/vmrefuses an hourly order up front when credit can't cover the first hour (the unpaid VM is removed at once). Successful hourly renewals send no notification; failures still do. A payment to an hourly VM's LNURL tops up the owner's credit.DELETE /api/v1/vm/{id}: queuesDeleteVmwith a newby_ownerflag (defaultfalse).409while an open abuse case names the VM.refundledger event (linked to the row) are written in one transaction, and a repeat is refused by the derived row id.subscription_line_item.deactivated_at(migration20261023105258). Deleting a VM deactivates its line item; the subscription ends only when no line item is still active. On a shared subscription only the VM line's share of each payment is refunded, and renewals, payment handling and the lifecycle skip deactivated items. Exposed asdeactivated_aton customer and admin line item responses.Testing
cargo test --lib:lnvps_api(722),lnvps_api_common(637),lnvps_api_admin(254) and the other library crates pass.lnvps_apirun with--test-threads=1(provisioner::migratetests share state and fail in parallel, also onmaster)../scripts/run-e2e.sh --filter creditagainst MariaDB: 10 passed, including a new test for the migration,Hourround-tripping, and the refund transaction (atomic, booked once, ledger event linked).cargo clippy: no new warnings.cargo llvm-cov. TheDELETEhandler shell itself has no test (noNip98Authharness); its guard, the worker job and the refund are tested.Not included