Skip to main content

Version Docs Updated

Purpose

This page describes how the CommissionBridge component manages the data flow between WooCommerce orders and the Rentiva financial core (Ledger).

πŸŒ‰ WooCommerce Commission Bridge

CommissionBridge acts as a translator between the e-commerce layer (WooCommerce) and the financial recording layer (Ledger). It listens to order events and converts them into financial Ledger entries.

πŸš€ Trigger Events (Hooks)​

The bridge operates by monitoring the following critical WooCommerce events:

  • woocommerce_payment_complete: Fired when payment is successfully completed.
  • woocommerce_order_status_completed: Fired when an order is marked complete, manually or automatically.
  • woocommerce_order_refunded: Used to create a Reverse Entry for refund operations.

πŸ”„ Financial Processing Flow​

When an order is paid, the system follows these steps:


πŸ› οΈ Key Features and Logic​

1. Idempotency (Duplicate Entry Prevention)​

A unique UUID in the format pay_cmp_{order_id}_{booking_id} is generated for each entry. Even if WooCommerce fires the same event multiple times, the Ledger class prevents duplicate entries thanks to this UUID.

2. Refund and Reverse Entry Handling​

When an order is refunded (on_order_refunded), instead of deleting the existing entry, the system creates a new Refund Entry with opposite values (- balance). This is required for financial audit trail integrity.

3. Metric Synchronization​

As soon as a financial entry is written to the Ledger, MetricCacheManager is triggered so that Vendor- and Vehicle-based performance charts are updated immediately.


πŸ“‹ Data Mapping​

WooCommerce FieldLedger FieldDescription
order_idparent_id / source_idIndicates the source is a WC order.
order_totalgross_amountTotal amount including tax.
currencycurrencyCurrency of the order.
_mhm_booking_idreference_idRentiva booking reference.

Section Summary​

  • CommissionBridge converts WooCommerce events into financial Transaction structures.
  • Reverse entry logic prevents data deletion.
  • UUID usage ensures data consistency (idempotency).

Changelog​

DateVersionNote
23.04.20264.27.2English translation added.
19.03.20264.21.2Page updated with Refund logic and Idempotency details.