manage.py vm delete must remove payment as well #38

Closed
opened 2022-07-07 21:54:57 +00:00 by dachary · 3 comments
  • 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

* 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.

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.
realaravinth started working 2022-07-08 13:54:56 +00:00

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

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
realaravinth stopped working 2022-07-08 16:15:38 +00:00
2h 20min 42s
checking if payment is already fulfilled

DESCRIPTION
    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.
``` checking if payment is already fulfilled DESCRIPTION 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. ```
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Total Time Spent: 2 hours 20 minutes
realaravinth
2 hours 20 minutes
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Hostea/dashboard#38
There is no content yet.