Ejemplo n.º 1
0
def create_wire_credits_invoice(domain_name, account_created_by,
                                account_entry_point, amount, invoice_items,
                                contact_emails):
    account = BillingAccount.get_or_create_account_by_domain(
        domain_name,
        created_by=account_created_by,
        entry_point=account_entry_point)[0]
    wire_invoice = WirePrepaymentInvoice.objects.create(
        domain=domain_name,
        date_start=datetime.datetime.utcnow(),
        date_end=datetime.datetime.utcnow(),
        date_due=None,
        balance=amount,
        account=account,
    )
    wire_invoice.items = invoice_items

    record = WirePrepaymentBillingRecord.generate_record(wire_invoice)
    if record.should_send_email:
        try:
            record.send_email(contact_emails=contact_emails)
        except Exception as e:
            log_accounting_error(
                "Error sending email for WirePrepaymentBillingRecord %d: %s" %
                (record.id, e.message),
                show_stack_trace=True,
            )
    else:
        record.skipped_email = True
        record.save()
Ejemplo n.º 2
0
def create_wire_credits_invoice(domain_name,
                                account_created_by,
                                account_entry_point,
                                amount,
                                invoice_items,
                                contact_emails):
    account = BillingAccount.get_or_create_account_by_domain(
        domain_name,
        created_by=account_created_by,
        created_by_invoicing=True,
        entry_point=account_entry_point
    )[0]
    wire_invoice = WirePrepaymentInvoice.objects.create(
        domain=domain_name,
        date_start=datetime.datetime.utcnow(),
        date_end=datetime.datetime.utcnow(),
        date_due=None,
        balance=amount,
        account=account,
    )
    wire_invoice.items = invoice_items

    record = WirePrepaymentBillingRecord.generate_record(wire_invoice)
    try:
        record.send_email(contact_emails=contact_emails)
    except Exception as e:
        logger.error("[BILLING] %s" % e)
Ejemplo n.º 3
0
def create_wire_credits_invoice(domain_name,
                                account_created_by,
                                account_entry_point,
                                amount,
                                invoice_items,
                                contact_emails):
    account = BillingAccount.get_or_create_account_by_domain(
        domain_name,
        created_by=account_created_by,
        entry_point=account_entry_point
    )[0]
    wire_invoice = WirePrepaymentInvoice.objects.create(
        domain=domain_name,
        date_start=datetime.datetime.utcnow(),
        date_end=datetime.datetime.utcnow(),
        date_due=None,
        balance=amount,
        account=account,
    )
    wire_invoice.items = invoice_items

    record = WirePrepaymentBillingRecord.generate_record(wire_invoice)
    if record.should_send_email:
        try:
            record.send_email(contact_emails=contact_emails)
        except Exception as e:
            log_accounting_error(
                "Error sending email for WirePrepaymentBillingRecord %d: %s" % (record.id, e.message),
                show_stack_trace=True,
            )
    else:
        record.skipped_email = True
        record.save()
Ejemplo n.º 4
0
def create_wire_credits_invoice(domain_name, amount, invoice_items,
                                contact_emails):
    wire_invoice = WirePrepaymentInvoice.objects.create(
        domain=domain_name,
        date_start=datetime.datetime.utcnow(),
        date_end=datetime.datetime.utcnow(),
        date_due=None,
        balance=amount,
    )
    wire_invoice.items = invoice_items

    record = WirePrepaymentBillingRecord.generate_record(wire_invoice)
    if record.should_send_email:
        try:
            for email in contact_emails:
                record.send_email(contact_email=email)
        except Exception as e:
            log_accounting_error(
                "Error sending email for WirePrepaymentBillingRecord %d: %s" %
                (record.id, six.text_type(e)),
                show_stack_trace=True,
            )
    else:
        record.skipped_email = True
        record.save()
Ejemplo n.º 5
0
def create_wire_credits_invoice(domain_name,
                                amount,
                                invoice_items,
                                contact_emails):
    wire_invoice = WirePrepaymentInvoice.objects.create(
        domain=domain_name,
        date_start=datetime.datetime.utcnow(),
        date_end=datetime.datetime.utcnow(),
        date_due=None,
        balance=amount,
    )
    wire_invoice.items = invoice_items

    record = WirePrepaymentBillingRecord.generate_record(wire_invoice)
    if record.should_send_email:
        try:
            for email in contact_emails:
                record.send_email(contact_email=email)
        except Exception as e:
            log_accounting_error(
                "Error sending email for WirePrepaymentBillingRecord %d: %s" % (record.id, six.text_type(e)),
                show_stack_trace=True,
            )
    else:
        record.skipped_email = True
        record.save()
Ejemplo n.º 6
0
def create_wire_credits_invoice(domain_name, amount, invoice_items,
                                contact_emails):
    deserialized_amount = deserialize_decimal(amount)
    wire_invoice = WirePrepaymentInvoice.objects.create(
        domain=domain_name,
        date_start=datetime.datetime.utcnow(),
        date_end=datetime.datetime.utcnow(),
        date_due=None,
        balance=deserialized_amount,
    )

    deserialized_items = []
    for item in invoice_items:
        general_credit_amount = item['amount']
        deserialized_general_credit = deserialize_decimal(
            general_credit_amount)
        deserialized_items.append({
            'type': item['type'],
            'amount': deserialized_general_credit
        })

    wire_invoice.items = deserialized_items

    record = WirePrepaymentBillingRecord.generate_record(wire_invoice)
    if record.should_send_email:
        try:
            for email in contact_emails:
                record.send_email(contact_email=email)
        except Exception as e:
            log_accounting_error(
                "Error sending email for WirePrepaymentBillingRecord %d: %s" %
                (record.id, str(e)),
                show_stack_trace=True,
            )
    else:
        record.skipped_email = True
        record.save()