Commit 1f9cb06d authored by Birin Sanchez's avatar Birin Sanchez
Browse files

parse_subscription: get account_type and billing_period from bundle


configuration file rather than WC subscription.
Signed-off-by: Birin Sanchez's avatarBirin Sanchez <birin.sanchez@puri.sm>
parent 4506e28a
Pipeline #18966 passed with stage
in 29 seconds
......@@ -73,32 +73,26 @@ def parse_subscription(json_entry):
else:
bundle_key = line_item.get('product_id')
# get account_type and billing_period from subscription
line_item_meta = line_item["meta"]
acct_value = None
billing_value = None
for meta in line_item_meta:
if meta["key"] == "service-bundle":
acct_value = meta["value"]
if meta["key"] == "billing-period":
billing_value = meta["value"]
# get account_type and billing_period from configured bundles
account_type = AccountType.UNDEFINED
if acct_value:
acct_value = acct_value.lower()
if 'family' in acct_value:
billing_period = None
bundles = get_available_bundles()
sub_bundle = bundles.get(str(bundle_key), None)
if sub_bundle:
sub_acc_type = sub_bundle.get('type', None)
if 'GROUP' == sub_acc_type:
account_type = AccountType.GROUP
elif 'complete' in acct_value:
elif 'COMPLETE' == sub_acc_type:
account_type = AccountType.COMPLETE
elif 'basic' in acct_value:
elif 'BASIC' == sub_acc_type:
account_type = AccountType.BASIC
billing_period = None
if billing_value:
if 'monthly' == billing_value.lower():
sub_period = sub_bundle.get('period', None)
if 'monthly' == sub_period:
billing_period = 'monthly'
elif 'yearly' == billing_value.lower():
billing_period = 'yearly'
elif 'annual' == sub_period:
billing_period = 'annual'
# create result
result = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment