manage.py vm delete must remove payment as well #38
- manage.py vm create thevm --owner=adminuser --flavor=small
- manage.py generate_invoice
- check mail is sent
- manage.py vm delete thevm
It will fail when run twice because there are leftover from the previous vm and generate_invoice won't send the invoice
This is tricky, I imagine Hostea operators would want to retain payments information for accounting purposes but the current invoice generation implementation is very dependent on the name of the VM.
I'm adding a
vm_deleted field to the Payments record. When a VM is deleted, all payments made against it will have its
vm_deleted set to True. And when generating invoices, we'll check for only payments of non-deleted VMs
checking if payment is already fulfilled
Invoice generation is dependent on instance_name. Deleting a VM doesn't delete the corresponding payments record since payment receipts should be preserved for accounting purposes.
But being heavily dependent on instance_name, without taking deleted VMs into account produces incorrect behavior under certain circumstances: if a VM named 'foo' is paid for and is deleted before its billing cycle is competed and a new VM is created with the same name, either by the same user or a different user, invoice won't be generated for the new VM since a payment record already exists for that billing cycle for the VM named 'foo'.
Marking deleted VMs' payment records unsuitable for checking if a VM is already paid for will result in correct behavior.
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?