Invoicing for recurring payments

4 years 11 months ago - 4 years 11 months ago #312138 by activha
Replied by activha on topic Invoicing for recurring payments

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.


Yes that could be a workaround to keep the basket invoice which is already incrementing and to add a payment increment. That would fit both annual and monthly invoices.

This should allow you to enforce whatever ordering system you need for payment rows and you already have the display output via query field.

We already use the query field for our administration needs in the front end and this works fine.

Would this fit your needs?

Unfortunately no because the goal is for the customer to get a legal invoice with an incremented number. That's not our need but a legal requirement for all people that would use the recurring system of CBSubs for less than yearly subscription. I think that the french law for invoicing numbering scheme is the same as european requirements regarding unique compulsory sequential number for each invoice

So what we would need is to display the invoice at each new payment with the incremented invoice number so that the customer can print or pdf it. This is the only way to be compliant with the legal rules.

How can we combine your _cbsubs_payments update query with a display of the corresponding invoice ? I think this would be the best path to combine a payment row update and to follow by a display of invoices based on _cbsubs_payments tables instead of _cbsubs_baskets. Is it feasible ?

Maybe that you could alter the present invoices template to add a substitution for _cbsubs_payments invoice field ?

Please Log in to join the conversation.

4 years 11 months ago #312144 by krileon
Replied by krileon on topic Invoicing for recurring payments
We don't have any invoices for payment rows. We only have invoices for baskets as they're one in the same. Best I can suggest is put together an endpoint to output whatever information you need using CB Auto Actions and a Code action with Method set to PHP then code the entire output. You'd then need to link to that auto action in your query field usage per payment row so you can pass the payment id. The below for example might accomplish this.

Global
Triggers: None
Type: Code
User: Self
Access: All Registered Users
Conditions
1: [get_payment] Not Empty
Action
Method: PHP
Code:
// First lets try to find and load the payment:
$payment		=	new cbpaidPayment();

$payment->load( (int) '[get_payment]' );

if ( (int) $payment->get( 'by_user_id' ) != (int) '[user_id]' ) {
	return null;
}

// Now we need the original basket for the payment:
$paymentBasket	=	new cbpaidPaymentBasket();

$paymentBasket->load( (int) $payment->get( 'payment_basket_id' ) );

// Finally we'll override some of the values of the basket so the basket invoice reflects the most recent payment:
$paymentBasket->set( 'time_initiated', $payment->get( 'time_created' ) );
$paymentBasket->set( 'time_updated', $payment->get( 'time_modified' ) );
$paymentBasket->set( 'time_completed', $payment->get( 'time_paid' ) );
$paymentBasket->set( 'time_completed_date', $payment->get( 'time_paid_date' ) );
$paymentBasket->set( 'time_completed_day_of_week', $payment->get( 'time_paid_day_of_week' ) );
$paymentBasket->set( 'time_completed_yearweek', $payment->get( 'time_paid_yearweek' ) );
$paymentBasket->set( 'time_completed_yearmonth', $payment->get( 'time_paid_yearmonth' ) );
$paymentBasket->set( 'time_completed_hour', $payment->get( 'time_paid_hour' ) );
$paymentBasket->set( 'proformainvoice', $payment->get( 'invoice' ) );

return $paymentBasket->displayInvoice( $user, true, false );
Output
Display: return

Next be sure you modify the query field as given in a previous reply to the following.

Row:
		<tr>
			<td><a href="index.php?option=com_comprofiler&view=pluginclass&plugin=cbautoactions&action=action&actions=AUTOACTION_ID_HERE&payment=[column_id]" target="_blank">[column_invoice]</a></td>
			<td>[column_item_name]</td>
			<td>[column_mc_gross]</td>
			<td>[column_time_paid]</td>
		</tr>

Be sure to replace AUTOACTION_ID_HERE with the ID of your new auto action created above. This should cause the invoice numbers for the payment rows to link to that auto action. That auto action then loads the payment, loads it baskets, overrides the basket values, then outputs the basket invoice with the payment details overriding it. This doesn't store anything so the original baskets are still safe. Combine this with my earlier proposal of an auto action to update the payment row invoices to be incremented and this entire package should provide exactly what you need.

The link you provided states you can outsource invoicing. Have you considered just using the email receipts that Stripe can send? PayPal with account-only purchasing also provides a full invoice record for them. To enable this for Stripe login to your dashboard and navigate to Settings > Email Receipts.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

4 years 11 months ago #312145 by activha
Replied by activha on topic Invoicing for recurring payments
That is a nice suggestion that we will try right now on the dev server and let you know.
BTW is there any possibility with CB to output directly the result to PDF ?

Regarding Stripe, I thought about it but the problem is that we have also a manual gateway for some offline payments, and Stripe does not support yet full edition of the invoice to show our company details.

Please Log in to join the conversation.

4 years 11 months ago #312148 by krileon
Replied by krileon on topic Invoicing for recurring payments

BTW is there any possibility with CB to output directly the result to PDF ?

No, but I guess you could add &tmpl=component&print=1 to the URL to make it a Joomla print view.

and Stripe does not support yet full edition of the invoice to show our company details.

You could add your necessary details to an image then set that as the logo within Settings > Branding. Beyond that it already outputs business name and business contact information so I'm not sure what more you'd need to add to it.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

4 years 11 months ago #312150 by activha
Replied by activha on topic Invoicing for recurring payments
This should do the job :-)

Last question :
How can we change this code to make also viewable by mods ? and not only by user ?
if ( (int) $payment->get( 'by_user_id' ) != (int) '[user_id]' ) {
	return null;
}

Please Log in to join the conversation.

4 years 11 months ago #312152 by krileon
Replied by krileon on topic Invoicing for recurring payments
You'll need to add a moderator check. Below should work.

// First lets try to find and load the payment:
$payment		=	new cbpaidPayment();

$payment->load( (int) '[get_payment]' );

$isOwner		=	( (int) $payment->get( 'by_user_id' ) == (int) '[user_id]' );

if ( ( ! $isOwner ) && ( ! \CBLib\Application\Application::User( (int) '[user_id]' )->isGlobalModerator() ) ) {
	return null;
}

// Now we need the original basket for the payment:
$paymentBasket	=	new cbpaidPaymentBasket();

$paymentBasket->load( (int) $payment->get( 'payment_basket_id' ) );

// Finally we'll override some of the values of the basket so the basket invoice reflects the most recent payment:
$paymentBasket->set( 'time_initiated', $payment->get( 'time_created' ) );
$paymentBasket->set( 'time_updated', $payment->get( 'time_modified' ) );
$paymentBasket->set( 'time_completed', $payment->get( 'time_paid' ) );
$paymentBasket->set( 'time_completed_date', $payment->get( 'time_paid_date' ) );
$paymentBasket->set( 'time_completed_day_of_week', $payment->get( 'time_paid_day_of_week' ) );
$paymentBasket->set( 'time_completed_yearweek', $payment->get( 'time_paid_yearweek' ) );
$paymentBasket->set( 'time_completed_yearmonth', $payment->get( 'time_paid_yearmonth' ) );
$paymentBasket->set( 'time_completed_hour', $payment->get( 'time_paid_hour' ) );
$paymentBasket->set( 'proformainvoice', $payment->get( 'invoice' ) );

return $paymentBasket->displayInvoice( $user, $isOwner, false );


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.231 seconds

Facebook Twitter LinkedIn