Payment rows have stored invoice numbers. There's just no means of specifying a separate numbering system for payment rows at this time, which is something we're discussing possibly implementing when we implement the frontend access to payment rows. Since there's already stored payment row invoices I suppose you could alter them directly in the database so they'll be stored however you're needing. Beyond that I do not know what more to suggest a this time.
Regarding how to do this you'd need to likely act on either of the below triggers.
onCPayAfterPaymentStatusChange
Code:
$_PLUGINS->trigger( 'onCPayAfterPaymentStatusChange', array( &$user, &$paymentBasket, &$subscriptions, $unifiedStatus, $previousUnifiedStatus, $occurrences, $autorecurring_type, $autorenew_type ) );
onCPayAfterPaymentStatusUpdateEvent
Code:
$_PLUGINS->trigger( 'onCPayAfterPaymentStatusUpdateEvent', array( &$user, &$paymentBasket, &$subscriptions, $unifiedStatus, $previousUnifiedStatus, $eventType, &$notification ) );
Neither directly provide the payment rows for a basket. You'd basically just do an update query against _cbsubs_payments for the most recent payment row for a basket when the payment status changes. This should allow you to enforce whatever ordering system you need for payment rows and you already have the display output via query field. Example query as follows.
Code:
SET @a = 0;
UPDATE `#__cbsubs_payments` SET `invoice` = CONCAT( 'PAYMENT-', ( @a:=@a + 1 ) ) WHERE `payment_basket_id` = 47
This for example would change the invoice columns for a baskets payments to be PAYMENT-# so PAYMENT-1, PAYMENT-2, PAYMENT-3, etc.. This can of course be expanded on to do whatever numbering scheme you want. As I understand you can increment the basket invoice and that'd be sufficient enough so instead of completely overriding the invoice number you'd have the below.
Code:
SET @a = 0;
UPDATE `#__cbsubs_payments` SET `invoice` = CONCAT( `invoice`, '-', ( @a:=@a + 1 ) ) WHERE `payment_basket_id` = 47
Now for example my invoice is P343063397246874. I've 2 payments for the basket. This gives payment invoice values of P343063397246874-1 and P343063397246874-2. Unique and correctly incremented on a per-payment basis.
The next issue is what happens if the invoice as already incremented? You'd end up with P343063397246874-1-1, which of course isn't good, but we can't skip any row as it's necessary for the incrementing variable so we'll just first remove it. This finally gives us the below.
Code:
SET @a = 0;
UPDATE `#__cbsubs_payments` SET `invoice` = CONCAT( SUBSTRING_INDEX( `invoice`, '-', 1 ), '-', ( @a:=@a + 1 ) ) WHERE `payment_basket_id` = 47
Would this fit your needs?