Beispiel #1
0
def map_rs_response(rs_response):
    return {
        'company_id': get_company_id(),
        'revenue_schedule_id': rs_response.get('id'),
        'customer_id': rs_response.get('customer_id'),
        'source_transaction': rs_response.get('source_transaction'),
        'product_id': rs_response.get('product_id'),
        'product_name': rs_response.get('product_name'),
        'plan_id': rs_response.get('plan_id'),
        'plan_name': rs_response.get('plan_name'),
        'charge_id': rs_response.get('charge_id'),
        'charge_name': rs_response.get('charge_name'),
        'charge_type': rs_response.get('charge_type'),
        'charge_timing': rs_response.get('charge_timing'),
        'total_revenue': convert_to_decimal(rs_response.get('total_revenue')),
        'recognized_revenue': convert_to_decimal(rs_response.get('recognized_revenue')),
        'unrecognized_revenue': convert_to_decimal(rs_response.get('unrecognized_revenue')),
        'start_date': rs_response.get('start_date'),
        'end_date': rs_response.get('end_date'),
        'schedule_lines': rs_response.get('schedule_lines'),
        'created_by': rs_response.get('created_by'),
        'updated_by': rs_response.get('updated_by'),
        'created_date': rs_response.get('created_date'),
        'updated_date': rs_response.get('updated_date')
    }
Beispiel #2
0
def map_customer_response(customer_response):
    return {
        'company_id': get_company_id(),
        'customer_id': customer_response['id'],
        'name': customer_response['name'],
        'customer_type': customer_response['customer_type'],
        'description': customer_response['description'],
        'parent_customer': customer_response['parent_customer'],
        'website': customer_response['website'],
        'payment_terms': customer_response['payment_terms'],
        'billing_cycle_day': customer_response['billing_cycle_day'],
        'billing_contact_id': customer_response.get('billing_contact_id', ''),
        'shipping_contact_id': customer_response.get('shipping_contact_id',
                                                     ''),
        'status': customer_response['status'],
        'billing_batch': customer_response['customer_type'],
        'tax_exempt': customer_response['tax_exempt'],
        'balance': convert_to_decimal(customer_response['balance']),
        'auto_pay': customer_response['auto_pay'],
        'currency': customer_response['currency'],
        'edit_auto_pay': customer_response['edit_auto_pay'],
        'price_book_id': customer_response['price_book_id'],
        'cmrr': convert_to_decimal(customer_response['cmrr']),
        'discounted_cmrr':
        convert_to_decimal(customer_response['discounted_cmrr']),
        'delivery_preferences': customer_response['delivery_preferences'],
        'created_by': customer_response['created_by'],
        'updated_by': customer_response['updated_by'],
        'created_date': customer_response['created_date'],
        'updated_date': customer_response['updated_date'],
        'custom_fields': customer_response['custom_fields']
    }
Beispiel #3
0
def map_product_response(product_response):
    return {
        'company_id':
        get_company_id(),
        'product_id':
        product_response.get('id'),
        'name':
        product_response.get('name'),
        'sku':
        product_response.get('sku'),
        'status':
        product_response.get('status'),
        'taxable':
        product_response.get('taxable'),
        'description':
        product_response.get('description'),
        'price':
        convert_to_decimal(product_response.get('price')),
        'currency':
        product_response.get('currency'),
        'income_account':
        product_response.get('income_account'),
        'deferred_revenue_enabled':
        product_response.get('deferred_revenue_enabled'),
        'revenue_rule_id':
        product_response.get('revenue_rule_id'),
        'recognition_start_date':
        product_response.get('recognition_start_date'),
        'order_journal_entry_enabled':
        product_response.get('order_journal_entry_enabled'),
        'order_debit_account':
        product_response.get('order_debit_account'),
        'order_credit_account':
        product_response.get('order_credit_account'),
        'invoice_journal_entry_enabled':
        product_response.get('invoice_journal_entry_enabled'),
        'invoice_debit_account':
        product_response.get('invoice_debit_account'),
        'invoice_credit_account':
        product_response.get('invoice_credit_account'),
        'revenue_journal_entry_enabled':
        product_response.get('revenue_journal_entry_enabled'),
        'revenue_debit_account':
        product_response.get('revenue_debit_account'),
        'revenue_credit_account':
        product_response.get('revenue_credit_account'),
        'created_by':
        product_response.get('created_by'),
        'updated_by':
        product_response.get('updated_by'),
        'created_date':
        product_response.get('created_date'),
        'updated_date':
        product_response.get('updated_date'),
        'custom_fields':
        product_response.get('custom_fields')
    }
Beispiel #4
0
def map_invoice_response(invoice_response):
    invoice_lines = invoice_response.get('line_items', [])
    for invoice_line in invoice_lines:
        yield {
            'company_id': get_company_id(),
            'invoice_id': invoice_response.get('id'),
            'invoice_line_no': invoice_line.get('line_no'),
            'customer_id': invoice_response.get('customer_id'),
            'billing_contact': invoice_response.get('billing_contact'),
            'shipping_contact': invoice_response.get('shipping_contact'),
            'customer_name': invoice_response.get('customer_name'),
            'invoice_date': invoice_response.get('invoice_date'),
            'due_date': invoice_response.get('due_date'),
            'billing_run_id': invoice_response.get('billing_run_id'),
            'subtotal': convert_to_decimal(invoice_response.get('subtotal')),
            'invoice_tax': convert_to_decimal(invoice_response.get('invoice_tax')),
            'invoice_amount': convert_to_decimal(invoice_response.get('invoice_amount')),
            'paid_amount': convert_to_decimal(invoice_response.get('paid_amount')),
            'balance': convert_to_decimal(invoice_response.get('balance')),
            'status': invoice_response.get('status'),
            'notes': invoice_response.get('notes'),
            'currency': invoice_response.get('currency'),
            'payment_terms': invoice_response.get('payment_terms'),
            'subscription_id': invoice_line.get('subscription_id'),
            'product_id': invoice_line.get('product_id'),
            'product_name': invoice_line.get('product_name'),
            'plan_id': invoice_line.get('plan_id'),
            'plan_name': invoice_line.get('plan_name'),
            'charge_id': invoice_line.get('charge_id'),
            'subscription_line_id': invoice_line.get('subscription_line_id'),
            'charge_name': invoice_line.get('charge_name'),
            'charge_type': invoice_line.get('charge_type'),
            'description': invoice_line.get('description'),
            'start_date': format_date_string(invoice_line.get('start_date')),
            'end_date': format_date_string(invoice_line.get('end_date')),
            'unit_price': convert_to_decimal(invoice_line.get('unit_price')),
            'list_price': convert_to_decimal(invoice_line.get('list_price')),
            'list_price_base': invoice_line.get('list_price_base'),
            'taxable': invoice_line.get('taxable'),
            'quantity': convert_to_decimal(invoice_line.get('quantity')),
            'discount': convert_to_decimal(invoice_line.get('discount')),
            'effective_price': convert_to_decimal(invoice_line.get('effective_price')),
            'line_tax': convert_to_decimal(invoice_line.get('line_tax')),
            'tax_lines': invoice_line.get('tax_lines'),
            'applied_tiers': format_array(invoice_line.get('applied_tiers')),
            'created_by': invoice_response.get('created_by'),
            'updated_by': invoice_response.get('updated_by'),
            'created_date': invoice_response.get('created_date'),
            'updated_date': invoice_response.get('updated_date'),
            'custom_fields': invoice_response.get('line_no'),
            'line_custom_fields': invoice_line.get('custom_fields')
        }
Beispiel #5
0
def map_payment_response(payment_response):
    return {
        'company_id':
        get_company_id(),
        'payment_id':
        payment_response.get('id'),
        'customer_id':
        payment_response.get('customer_id'),
        'payment_date':
        payment_response.get('payment_date'),
        'notes':
        payment_response.get('notes'),
        'status':
        payment_response.get('status'),
        'payment_amount':
        convert_to_decimal(payment_response.get('payment_amount')),
        'fee_amount':
        convert_to_decimal(payment_response.get('fee_amount')),
        'applied_amount':
        convert_to_decimal(payment_response.get('applied_amount')),
        'unapplied_amount':
        convert_to_decimal(payment_response.get('unapplied_amount')),
        'refunded_amount':
        convert_to_decimal(payment_response.get('refunded_amount')),
        'payment_type':
        payment_response.get('payment_type'),
        'payment_method':
        payment_response.get('payment_method'),
        'reference_number':
        payment_response.get('reference_number'),
        'auto_apply':
        format_boolean(payment_response.get('auto_apply')),
        'retried_attempts':
        payment_response.get('retried_attempts'),
        'invoices':
        payment_response.get('invoices'),
        'refunds':
        payment_response.get('refunds'),
        'gl_account':
        payment_response.get('gl_account'),
        'created_by':
        payment_response.get('created_by'),
        'updated_by':
        payment_response.get('updated_by'),
        'created_date':
        payment_response.get('created_date'),
        'updated_date':
        payment_response.get('updated_date'),
        'custom_fields':
        payment_response.get('custom_fields')
    }
Beispiel #6
0
def map_order_response(order_response):
    order_lines = order_response.get('line_items', [])
    for order_line in order_lines:
        yield {
            'company_id':
            get_company_id(),
            'order_id':
            order_response.get('id'),
            'order_line_no':
            order_line.get('line_no'),
            'customer_id':
            order_response.get('customer_id'),
            'invoice_id':
            order_response.get('invoice_id'),
            'order_date':
            order_response.get('order_date'),
            'status':
            order_response.get('status'),
            'order_amount':
            convert_to_decimal(order_response.get('order_amount')),
            'separate_invoice':
            order_response.get('separate_invoice'),
            'currency':
            order_response.get('currency'),
            'notes':
            order_response.get('notes'),
            'product_id':
            order_line.get('product_id'),
            'product_name':
            order_line.get('product_name'),
            'description':
            order_line.get('description'),
            'unit_price':
            convert_to_decimal(order_line.get('unit_price')),
            'quantity':
            convert_to_decimal(order_line.get('quantity')),
            'discount':
            convert_to_decimal(order_line.get('discount')),
            'effective_price':
            convert_to_decimal(order_line.get('effective_price')),
            'created_by':
            order_response.get('created_by'),
            'updated_by':
            order_response.get('updated_by'),
            'created_date':
            order_response.get('created_date'),
            'updated_date':
            order_response.get('updated_date'),
            'custom_fields':
            order_response.get('custom_fields')
        }
Beispiel #7
0
def map_bs_response(bs_response):
    key_metrics = bs_response.get('key_metrics', {})
    return {
        'company_id':
        get_company_id(),
        'billing_schedule_id':
        bs_response.get('id'),
        'customer_id':
        bs_response.get('customer_id'),
        'customer_name':
        bs_response.get('customer_name'),
        'subscription_id':
        bs_response.get('subscription_id'),
        'product_id':
        bs_response.get('product_id'),
        'product_name':
        bs_response.get('product_name'),
        'charge_id':
        bs_response.get('charge_id'),
        'charge_name':
        bs_response.get('charge_name'),
        'charge_type':
        bs_response.get('charge_type'),
        'charge_timing':
        bs_response.get('charge_timing'),
        'start_date':
        bs_response.get('start_date'),
        'end_date':
        bs_response.get('end_date'),
        'monthly_recurring_revenue':
        convert_to_decimal(key_metrics.get('monthly_recurring_revenue')),
        'annual_contract_revenue':
        convert_to_decimal(key_metrics.get('annual_contract_revenue')),
        'total_contract_revenue':
        convert_to_decimal(key_metrics.get('total_contract_revenue')),
        'amount_invoiced':
        convert_to_decimal(key_metrics.get('amount_invoiced')),
        'currency':
        bs_response.get('currency'),
        'schedule_lines':
        bs_response.get('schedule_lines'),
        'created_by':
        bs_response.get('created_by'),
        'updated_by':
        bs_response.get('updated_by'),
        'created_date':
        bs_response.get('created_date'),
        'updated_date':
        bs_response.get('updated_date')
    }
Beispiel #8
0
def map_credit_response(credit_response):
    return {
        'company_id':
        get_company_id(),
        'credit_id':
        credit_response.get('id'),
        'customer_id':
        credit_response.get('customer_id'),
        'credit_date':
        credit_response.get('credit_date'),
        'notes':
        credit_response.get('notes'),
        'status':
        credit_response.get('status'),
        'credit_amount':
        convert_to_decimal(credit_response.get('credit_amount')),
        'applied_amount':
        convert_to_decimal(credit_response.get('applied_amount')),
        'unapplied_amount':
        convert_to_decimal(credit_response.get('unapplied_amount')),
        'currency':
        credit_response.get('currency'),
        'reference_number':
        credit_response.get('reference_number'),
        'auto_apply':
        format_boolean(credit_response.get('auto_apply')),
        'gl_account':
        credit_response.get('gl_account'),
        'invoices':
        credit_response.get('invoices'),
        'refunds':
        credit_response.get('refunds'),
        'created_by':
        credit_response.get('created_by'),
        'updated_by':
        credit_response.get('updated_by'),
        'created_date':
        credit_response.get('created_date'),
        'updated_date':
        credit_response.get('updated_date'),
        'custom_fields':
        credit_response.get('custom_fields')
    }
Beispiel #9
0
def map_refund_response(refund_response):
    return {
        'company_id': get_company_id(),
        'refund_id': refund_response.get('id'),
        'customer_id': refund_response.get('customer_id'),
        'refund_date': refund_response.get('refund_date'),
        'refund_amount':
        convert_to_decimal(refund_response.get('refund_amount')),
        'refund_type': refund_response.get('refund_type'),
        'notes': refund_response.get('notes'),
        'status': refund_response.get('refund_status'),
        'payment_id': refund_response.get('payment_id'),
        'currency': refund_response.get('currency'),
        'reference_number': refund_response.get('reference_number'),
        'created_by': refund_response.get('created_by'),
        'updated_by': refund_response.get('updated_by'),
        'created_date': refund_response.get('created_date'),
        'updated_date': refund_response.get('updated_date'),
        'custom_fields': refund_response.get('custom_fields')
    }
Beispiel #10
0
def map_subscription_response(subscription_response):
    subscription_plans = subscription_response.get('plans')
    for subscription_plan in subscription_plans:
        yield {
            "company_id":
            get_company_id(),
            "subscription_id":
            subscription_response.get('id'),
            "subscription_line_id":
            subscription_plan.get('subscription_line_id'),
            "customer_id":
            subscription_response.get('customer_id'),
            "bill_contact_id":
            subscription_response.get('bill_contact_id'),
            "shipping_contact_id":
            subscription_response.get('shipping_contact_id'),
            "status":
            subscription_response.get('status'),
            "billing_start_date":
            format_date_string(
                subscription_response.get('billing_start_date')),
            "service_start_date":
            format_date_string(
                subscription_response.get('service_start_date')),
            "order_placed_at":
            format_date_string(subscription_response.get('order_placed_at')),
            "contract_effective_date":
            format_date_string(
                subscription_response.get('contract_effective_date')),
            "cancellation_date":
            format_date_string(subscription_response.get('cancellation_date')),
            "auto_renew":
            subscription_response.get('auto_renew'),
            "currency":
            subscription_response.get('currency'),
            "payment_terms":
            subscription_response.get('payment_terms'),
            "cmrr":
            convert_to_decimal(subscription_response.get('cmrr')),
            "discounted_cmrr":
            convert_to_decimal(subscription_response.get('discounted_cmrr')),
            "separate_invoice":
            subscription_response.get('separate_invoice'),
            "notes":
            subscription_response.get('notes'),
            "version":
            subscription_response.get('version'),
            "version_type":
            subscription_response.get('version_type'),
            "contract_term":
            subscription_response.get('contract_term'),
            "renewal_term":
            subscription_response.get('renewal_term'),
            "tcv":
            convert_to_decimal(subscription_response.get('tcv')),
            "product_id":
            subscription_plan.get('product_id'),
            "product_name":
            subscription_plan.get('product_name'),
            "plan_name":
            subscription_plan.get('plan_name'),
            "charge_id":
            subscription_plan.get('charge_id'),
            "charge_name":
            subscription_plan.get('charge_name'),
            "pricing_model":
            subscription_plan.get('pricing_model'),
            "list_price":
            convert_to_decimal(subscription_plan.get('list_price')),
            "price_base":
            subscription_plan.get('price_base'),
            "quantity":
            convert_to_decimal(subscription_plan.get('quantity')),
            "included_units":
            convert_to_decimal(subscription_plan.get('included_units')),
            "discount":
            convert_to_decimal(subscription_plan.get('discount')),
            "effective_price":
            convert_to_decimal(subscription_plan.get('effective_price')),
            "charge_type":
            subscription_plan.get('charge_type'),
            "billing_period":
            subscription_plan.get('billing_period'),
            "unit_of_measure":
            subscription_plan.get('unit_of_measure'),
            "current_period_start_date":
            subscription_plan.get('current_period_start_date'),
            "current_period_end_date":
            subscription_plan.get('current_period_end_date'),
            "billing_schedule_id":
            subscription_plan.get('billing_schedule_id'),
            "revenue_schedule_id":
            subscription_plan.get('revenue_schedule_id'),
            "charge_timing":
            subscription_plan.get('charge_timing'),
            "billing_period_start_alignment":
            subscription_plan.get('billing_period_start_alignment'),
            "billing_day":
            subscription_plan.get('billing_day'),
            "prorate_partial_periods":
            subscription_plan.get('prorate_partial_periods'),
            "backcharge_current_period":
            subscription_plan.get('backcharge_current_period'),
            "prepayment_periods":
            convert_to_decimal(subscription_plan.get('prepayment_periods')),
            "renewal_increment_percent":
            convert_to_decimal(
                subscription_plan.get('renewal_increment_percent')),
            "override_renewal_increment_percent":
            subscription_plan.get('override_renewal_increment_percent'),
            "charge_end_date":
            format_date_string(subscription_plan.get('charge_end_date')),
            "created_by":
            subscription_response.get('created_by'),
            "updated_by":
            subscription_response.get('updated_by'),
            "created_date":
            subscription_response.get('created_date'),
            "updated_date":
            subscription_response.get('updated_date'),
            "custom_fields":
            subscription_response.get('custom_fields'),
            "charge_custom_fields":
            subscription_plan.get('custom_fields')
        }