Below is a set of commands for self-hosted users, mostly for managing invoicing tasks, whether for immediate processing or scheduling.These commands run in a Rails console (rails c) inside a Docker container named api, managed by Docker Compose.
docker compose exec api rails c
Bill a subscription for a future date
Use this to queue the billing of a subscription for a later issuance date. The job
generates a real invoice, it is not a preview. Specify the correct subscription
external_id, the targeted invoice issuance date, and an invoicing_reason.
# In the Rails consolesubscription = Subscription.find_by(external_id: 'YOUR_SUB_EXTERNAL_ID')timestamp = DateTime.parse('2024-10-01').to_iBillSubscriptionJob.perform_later([subscription], timestamp, invoicing_reason: :subscription_periodic)
invoicing_reason is required. It accepts subscription_starting,
subscription_periodic, subscription_terminating, in_advance_charge,
in_advance_charge_periodic and progressive_billing.
Issue an invoice immediately
Use this to issue an invoice right away. Specify the correct subscription external_id.
# In the Rails consolesubscription = Subscription.find_by(external_id: 'YOUR_SUB_EXTERNAL_ID')timestamp = Time.current.to_iBillSubscriptionJob.perform_now([subscription], timestamp, invoicing_reason: :subscription_periodic)
Remove cache for a subscription
Use this to remove the cache on a specific subscription.
# In the Rails consoleSubscriptions::ChargeCacheService.expire_for_subscription(Subscription.find_by(external_id: 'YOUR_SUB_EXTERNAL_ID'))
To remove the cache for all subscriptions, you can alternatively use this command:
# In the Rails consoleSubscription.find_each {|s| Subscriptions::ChargeCacheService.expire_for_subscription(s) }
Audit logs of a subscription
Use this to view all changes applied to a subscription and identify which membership made those changes.
# In the Rails consolesubscription = Subscription.find_by(external_id: 'YOUR_SUB_EXTERNAL_ID')subscription.versions