def change_billing_cycle(request, *args, **kwargs): subscription_id = request.GET['subscription_id'] new_cycle = request.GET['new_cycle'] subscription_model = get_subscription_model() if getattr(settings, 'IS_IKWEN', False): service = subscription_model.objects.using(UMBRELLA).get( pk=subscription_id) service.billing_cycle = new_cycle service.save(using=service.database) else: service = subscription_model.objects.get(pk=subscription_id) service.billing_cycle = new_cycle service.save() callback = request.GET['callback'] response = callback + '(' + json.dumps({'success': True}) + ')' return HttpResponse(response, content_type='application/json')
from ikwen.accesscontrol.models import Member, SUDO from ikwen.billing.models import Payment, AbstractInvoice, InvoicingConfig, Invoice, NEW_INVOICE_EVENT, \ SUBSCRIPTION_EVENT, PaymentMean, MoMoTransaction, CloudBillingPlan, PAYMENT_CONFIRMATION, SupportBundle from ikwen.billing.utils import get_payment_confirmation_message, get_invoice_generated_message, \ get_next_invoice_number, get_subscription_registered_message, get_subscription_model, get_product_model, \ get_invoicing_config_instance, get_days_count, share_payment_and_set_stats from ikwen.core.admin import CustomBaseAdmin from ikwen.core.models import QueuedSMS, Config, Application, Service, RETAIL_APP_SLUG from ikwen.core.utils import get_service_instance, get_mail_content, send_sms, add_event, add_database from ikwen.partnership.models import ApplicationRetailConfig from import_export import resources, fields Product = get_product_model() subscription_model_name = getattr(settings, 'BILLING_SUBSCRIPTION_MODEL', 'billing.Subscription') Subscription = get_subscription_model() class InvoicingConfigAdmin(CustomBaseAdmin): list_display = ( 'gap', 'reminder_delay', 'overdue_delay', 'tolerance', ) fieldsets = ( (_('General'), { 'fields': ( 'gap', 'separate_billing_cycle', 'processing_fees_on_customer',
def render_billing_event(event, request): service = event.service database = service.database add_database_to_settings(database) currency_symbol = service.config.currency_symbol try: invoice = Invoice.objects.using(database).get(pk=event.object_id) member = invoice.member try: details = invoice.subscription.product.get_details() except: try: subscription = get_subscription_model().objects.get( pk=invoice.subscription.id) details = subscription.details except: details = ', '.join( [entry.item.label for entry in invoice.entries]) from ikwen.conf import settings as ikwen_settings data = { 'title': _(event.event_type.title), 'details': details, 'danger': event.event_type.codename == SERVICE_SUSPENDED_EVENT, 'currency_symbol': currency_symbol, 'amount': invoice.amount, 'obj': invoice, 'details_url': service.url + reverse('billing:invoice_detail', args=(invoice.id, )), 'show_pay_now': invoice.status != Invoice.PAID, 'MEMBER_AVATAR': ikwen_settings.MEMBER_AVATAR, 'IKWEN_MEDIA_URL': ikwen_settings.MEDIA_URL } if member and member.id != request.GET['member_id']: data['member'] = member c = Context(data) except Invoice.DoesNotExist: try: report = SendingReport.objects.using(database).get( pk=event.object_id) c = Context({ 'title': '<strong>%d</strong> %s' % (report.count, _(event.event_type.title)), 'currency_symbol': currency_symbol, 'amount': report.total_amount, 'details_url': service.url + reverse('billing:admin_invoice_list'), 'obj': report }) except SendingReport.DoesNotExist: return None html_template = get_template('billing/events/notice.html') return html_template.render(c)