We use check payments and track them in Ubercart, but would like a report or view that shows orders that have outstanding balances.

I'd like to create a view that includes the amount paid and/or the final balance on an order. This is tracked in the database, but is not available in the views interface. I'm thinking the solution is to add some code to hook_views_data to make that field (uc_payment_receipts.amount) visible to Views and joined to the main orders bundle.

Is there a better solution that I'm missing?

Thanks.

CommentFileSizeAuthor
#6 1490632-uc_payment-views.patch3.23 KBlongwave
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TR’s picture

Title: Tracking payments » Expose payment receipts and payment balance to Views
Version: 7.x-3.0-rc1 » 7.x-3.x-dev
Component: Reports » Payment
longwave’s picture

DanZ’s picture

See also #1876496: Calculate additional Ordered Product fields for Views.

Should payment records be entities?

DanZ’s picture

Yes, payment receipts should be entities. They should be fieldable to allow attachment of extra information by other modules, especially payment modules, instead of using the serialized "data" field. That would make those extra fields available in Views, once modules started using them.

The tricky part is converting the assorted code that interacts with payment receipts to use the entity interface without breaking anything.

The question is whether it's a good idea to expose the table to Views before converting it to an entity.

longwave’s picture

I don't think it's worth changing payment receipts to be entities now in 7.x - I don't see what benefit this gains us, and we cannot change the underlying data structure now without affecting existing contrib modules. In this issue I think we should just describe {uc_payment_receipts} to Views via a relationship to {uc_orders}, and make a note in the Drupal 8 issue that payment receipts should become entities in the future.

longwave’s picture

Status: Active » Needs review
FileSize
3.23 KB

This patch describes most of the payment receipt data to Views. Add a relationship to Order: Payments to see the fields.

longwave’s picture

Status: Needs review » Fixed

Committed #6.

Status: Fixed » Closed (fixed)

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