I'm currently working on a patch to allow entry of the final payment date due by number of days from purchase.
I discovered while clearing out test orders that the downpayments module does not remove the associated records in uc_downpayment_payments.
This is very easy to fix, just requires an added case for operation (delete) and a few lines of code added to do the work at the end of the hook_order routine (uc_downpayment_order).

Existing code at line 272 reads...

    case 'update':
      break;
    case 'load':
      break;
  }

Change to the following...

    case 'update':
      break;
    case 'load':
      break;

// handle removal of downpayment payments on order deletion
    case 'delete':
      foreach ($arg1->products as $key => $product) {
        if ($product->data['downpayment']) {
          db_query("DELETE FROM {uc_downpayment_payments} WHERE order_id = %d",
                   $product->data['downpayment']->order_id);
        }
      }
      break;

  } /* end of switch ($op) */

I will post the patch for final payment date entry by days from purchase when I have done some more testing and bug stomping.

Comments

sokrplare’s picture

Nice catch, silverwing - will get this added in to the live project soon (http://drupal.org/project/uc_downpayment). Unfortunately, this sandbox project couldn't be properly promoted due to http://drupal.org/node/1104470#comment-4901344 so will fix this and then resolve the ticket out and handle future issues (like your awesome sounding final payment date entry by dates from purchase patch) in the live issue queue.

sokrplare’s picture

Assigned: Unassigned » sokrplare
sokrplare’s picture

Status: Active » Needs work
sokrplare’s picture

Project: » UC Down Payment
Version: » 6.x-1.x-dev

Moving to live project queue.

sokrplare’s picture

When an order is deleted, we can delete all down payment records related to that order, so I believe it is sufficient to add the following code:

case 'delete':
  db_query("DELETE FROM {uc_downpayment_payments} WHERE order_id = %d", $arg1->order_id);
  break;
sokrplare’s picture

Status: Needs work » Closed (fixed)

This code has been added to the most recent version. Many thanks for helping with this bug.

sokrplare’s picture

Status: Closed (fixed) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.