def handle(self, *args, **options): from tendenci.apps.recurring_payments.models import RecurringPayment from tendenci.apps.recurring_payments.utils import run_a_recurring_payment verbosity = int(options['verbosity']) recurring_payments = RecurringPayment.objects.filter(status_detail='active', status=True) for rp in recurring_payments: run_a_recurring_payment(rp, verbosity)
def handle(self, *args, **options): from tendenci.apps.recurring_payments.models import RecurringPayment from tendenci.apps.recurring_payments.utils import run_a_recurring_payment verbosity = int(options['verbosity']) recurring_payments = RecurringPayment.objects.filter( status_detail='active', status=True) for rp in recurring_payments: run_a_recurring_payment(rp, verbosity)
def handle(self, *args, **options): from tendenci.apps.recurring_payments.models import RecurringPayment from tendenci.apps.recurring_payments.utils import run_a_recurring_payment from tendenci.apps.site_settings.utils import get_setting if get_setting('module', 'recurring_payments', 'enabled'): verbosity = int(options['verbosity']) recurring_payments = RecurringPayment.objects.filter(status_detail='active', status=True) for rp in recurring_payments: run_a_recurring_payment(rp, verbosity) else: print('Recurring payments not enabled')
def handle(self, *args, **options): from tendenci.apps.recurring_payments.models import RecurringPayment from tendenci.apps.recurring_payments.utils import run_a_recurring_payment if get_setting('module', 'recurring_payments', 'enabled'): verbosity = int(options['verbosity']) recurring_payments = RecurringPayment.objects.filter( status_detail='active', status=True) for rp in recurring_payments: if has_supported_merchant_account(rp.platform): run_a_recurring_payment(rp, verbosity) else: print('Recurring payments not enabled')
def handle(self, *args, **options): from tendenci.apps.recurring_payments.models import RecurringPayment from tendenci.apps.recurring_payments.utils import run_a_recurring_payment logger = getLogger('run_recurring_payment') if get_setting('module', 'recurring_payments', 'enabled'): verbosity = int(options['verbosity']) recurring_payments = RecurringPayment.objects.filter(status_detail='active', status=True) for rp in recurring_payments: if has_supported_merchant_account(rp.platform): try: run_a_recurring_payment(rp, verbosity) except: print(traceback.format_exc()) rp_url = '%s%s' % (get_setting('site', 'global', 'siteurl'), reverse('recurring_payment.view_account', args=[rp.id])) logger.error(f'Error processing recurring payment {rp_url}...\n\n{traceback.format_exc()}') else: print('Recurring payments not enabled')
def run_now(request): """Run a recurring payment. """ rp_id = request.POST.get('rp_id') rp = get_object_or_404(RecurringPayment, pk=rp_id) result_data = {} result_data['processed'] = 'false' result_data['reason'] = 'done' payment_profiles = PaymentProfile.objects.filter( customer_profile_id=rp.customer_profile_id, status=True, status_detail='active' ).order_by('-update_dt') if not payment_profiles: valid_cpp_ids, invalid_cpp_ids = rp.populate_payment_profile() #print valid_cpp_ids, invalid_cpp_ids if valid_cpp_ids: payment_profiles = PaymentProfile.objects.filter( customer_profile_id=valid_cpp_ids[0]) if not payment_profiles: result_data['reason'] = 'not setup' else: if rp.status_detail == 'active': num_processed = run_a_recurring_payment(rp) if num_processed: result_data['processed'] = 'true' result_data['reason'] = 'processed' # get total_paid and balance for this rp result_data['total_paid'] = str(rp.total_paid) result_data['balance'] = str(rp.get_outstanding_balance()) # get total amount received for all rps d = RecurringPaymentInvoice.objects.filter( invoice__balance=0, ).aggregate(total_amount_received=Sum('invoice__total')) result_data['total_amount_received'] = d['total_amount_received'] if not result_data['total_amount_received']: result_data['total_amount_received'] = 0 result_data['total_amount_received'] = tcurrency(result_data['total_amount_received']) return HttpResponse(simplejson.dumps(result_data))