Currently commerce_purchase_order table makes it difficult to build new features on top of the module, because there is not a clear relationship between transaction objects and PO record.

For example, View displaying list of transactions cannot display PO numbers, which especially impacts VBO.
Another example: Deleting a transaction, when there are more than one PO transaction per order, makes it pretty complicated to delete the right record in `commerce_purchase_order` table.

Proposed solution: Introduce transaction_id field into commerce_purchase_order database and make it a primary key.

CommentFileSizeAuthor
#2 2878812-2.patch3.93 KBbbujisic

Comments

bbujisic created an issue. See original summary.

bbujisic’s picture

Status: Active » Needs review
StatusFileSize
new3.93 KB

Attached patch adds the extra transaction_id field to the schema and makes it a primary key, while keeping the order_id-po_number pair unique.

hook_update_n() populates transaction_id's whenever PO number could be determined from existing "commerce_purchase_order" transactions. Other (orphaned?) purchase order records are being deleted in order to make sure no transaction_id == NULL nonsense breaks db_add_primary_key() function.

It is a relatively large change. A review would be appreciated.

bbujisic’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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