Skip to content

Commit

Permalink
LITE-28847: Support 'late' field in product capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
r-s11v committed Oct 24, 2023
1 parent e8aa3e5 commit 7556557
Show file tree
Hide file tree
Showing 9 changed files with 1,040 additions and 779 deletions.
2 changes: 1 addition & 1 deletion connect/cli/plugins/product/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def create_product(self, name=None):

def clean_wb(self):
ws = self.wb['Capabilities']
for row in range(2, 11):
for row in range(2, 12):
ws[f'B{row}'].value = 'update'

ws = self.wb['Embedding Static Resources']
Expand Down
1 change: 1 addition & 0 deletions connect/cli/plugins/product/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
'Pay-as-you-go support and schema',
'Pay-as-you-go dynamic items support',
'Pay-as-you-go future charges support',
'Pay-as-you-go late charges support',
'Consumption reporting for Reservation Items',
'Dynamic Validation of the Draft Requests',
'Dynamic Validation of the Inquiring Form',
Expand Down
97 changes: 57 additions & 40 deletions connect/cli/plugins/product/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,95 +681,112 @@ def _dump_capabilities(ws, product, progress): # noqa: CCR001
ws['B2'].value = '-'
ws['C2'].value = ppu['schema'] if ppu else 'Disabled'
ppu_validation.add(ws['C2'])

ws['A3'].value = 'Pay-as-you-go dynamic items support'
ws['B3'].value = '-'
ws['C3'].value = 'Enabled' if ppu and 'dynamic' in ppu and ppu['dynamic'] else 'Disabled'
disabled_enabled.add(ws['C3'])

ws['A4'].value = 'Pay-as-you-go future charges support'
ws['B4'].value = '-'
ws['C4'].value = 'Enabled' if ppu and 'future' in ppu and ppu['future'] else 'Disabled'
disabled_enabled.add(ws['C4'])
ws['A5'].value = 'Consumption reporting for Reservation Items'

ws['A5'].value = 'Pay-as-you-go late charges support'
ws['B5'].value = '-'
ws['C5'].value = 'Enabled' if capabilities['reservation']['consumption'] else 'Disabled'
ws['C5'].value = 'Enabled' if ppu and 'late' in ppu and ppu['late'] else 'Disabled'
disabled_enabled.add(ws['C5'])

ws['A6'].value = 'Consumption reporting for Reservation Items'
ws['B6'].value = '-'
ws['C6'].value = 'Enabled' if capabilities['reservation']['consumption'] else 'Disabled'
disabled_enabled.add(ws['C6'])

def _get_reporting_consumption(reservation_cap):
if 'consumption' in reservation_cap and reservation_cap['consumption']:
return 'Enabled'
return 'Disabled'

ws['C5'].value = _get_reporting_consumption(capabilities['reservation'])
disabled_enabled.add(ws['C5'])
ws['A6'].value = 'Dynamic Validation of the Draft Requests'
ws['B6'].value = '-'
ws['C6'].value = _get_reporting_consumption(capabilities['reservation'])
disabled_enabled.add(ws['C6'])

ws['A7'].value = 'Dynamic Validation of the Draft Requests'
ws['B7'].value = '-'

def _get_dynamic_validation_draft(capabilities_cart):
if 'validation' in capabilities_cart and capabilities['cart']['validation']:
return 'Enabled'
return 'Disabled'

ws['C6'].value = _get_dynamic_validation_draft(capabilities['cart'])
disabled_enabled.add(ws['C6'])
ws['A7'].value = 'Dynamic Validation of the Inquiring Form'
ws['B7'].value = '-'
ws['C7'].value = _get_dynamic_validation_draft(capabilities['cart'])
disabled_enabled.add(ws['C7'])

ws['A8'].value = 'Dynamic Validation of the Inquiring Form'
ws['B8'].value = '-'

def _get_validation_inquiring(capabilities_inquiring):
if 'validation' in capabilities_inquiring and capabilities_inquiring['validation']:
return 'Enabled'
return 'Disabled'

ws['C7'].value = _get_validation_inquiring(capabilities['inquiring'])
disabled_enabled.add(ws['C7'])
ws['A8'].value = 'Reseller Authorization Level'
ws['B8'].value = '-'
ws['C8'].value = _get_validation_inquiring(capabilities['inquiring'])
disabled_enabled.add(ws['C8'])

ws['A9'].value = 'Reseller Authorization Level'
ws['B9'].value = '-'

def _get_reseller_authorization_level(tiers):
if tiers and 'configs' in tiers and tiers['configs']:
return tiers['configs']['level']
return 'Disabled'

ws['C8'].value = _get_reseller_authorization_level(tiers)
tier_validation.add(ws['C8'])
ws['A9'].value = 'Tier Accounts Sync'
ws['B9'].value = '-'
ws['C9'].value = 'Enabled' if tiers and 'updates' in tiers and tiers['updates'] else 'Disabled'
disabled_enabled.add(ws['C9'])
ws['A10'].value = 'Administrative Hold'
ws['C9'].value = _get_reseller_authorization_level(tiers)
tier_validation.add(ws['C9'])

ws['A10'].value = 'Tier Accounts Sync'
ws['B10'].value = '-'
ws['C10'].value = 'Enabled' if tiers and 'updates' in tiers and tiers['updates'] else 'Disabled'
disabled_enabled.add(ws['C10'])

ws['A11'].value = 'Dynamic Validation of Tier Requests'
ws['A11'].value = 'Administrative Hold'
ws['B11'].value = '-'
ws['C11'].value = 'Enabled' if capabilities['tiers']['validation'] else 'Disabled'

def _get_administrative_hold(capabilities):
if 'hold' in capabilities['subscription'] and capabilities['subscription']['hold']:
return 'Enabled'
return 'Disabled'

ws['C11'].value = _get_administrative_hold(capabilities)
disabled_enabled.add(ws['C11'])
ws['A12'].value = 'Editable Ordering Parameters in Change Request'

ws['A12'].value = 'Dynamic Validation of Tier Requests'
ws['B12'].value = '-'
ws['C12'].value = (
'Enabled' if subscription['change']['editable_ordering_parameters'] else 'Disabled'
)
ws['C12'].value = 'Enabled' if capabilities['tiers']['validation'] else 'Disabled'
disabled_enabled.add(ws['C12'])
ws['A13'].value = 'Validation of Draft Change Request'

ws['A13'].value = 'Editable Ordering Parameters in Change Request'
ws['B13'].value = '-'
ws['C13'].value = 'Enabled' if 'validation' in change and change['validation'] else 'Disabled'
ws['C13'].value = (
'Enabled' if subscription['change']['editable_ordering_parameters'] else 'Disabled'
)
disabled_enabled.add(ws['C13'])
ws['A14'].value = 'Validation of inquiring form for Change Requests'

ws['A14'].value = 'Validation of Draft Change Request'
ws['B14'].value = '-'
ws['C14'].value = (
ws['C14'].value = 'Enabled' if 'validation' in change and change['validation'] else 'Disabled'
disabled_enabled.add(ws['C14'])

ws['A15'].value = 'Validation of inquiring form for Change Requests'
ws['B15'].value = '-'
ws['C15'].value = (
'Enabled'
if 'inquiring_validation' in change and change['inquiring_validation']
else 'Disabled'
)
disabled_enabled.add(ws['C14'])
disabled_enabled.add(ws['C15'])

def _get_administrative_hold(capabilities):
if 'hold' in capabilities['subscription'] and capabilities['subscription']['hold']:
return 'Enabled'
return 'Disabled'

ws['C10'].value = _get_administrative_hold(capabilities)
disabled_enabled.add(ws['C10'])
idx = 2
while idx < 11:
while idx < 12:
action_validation.add(f'B{idx}')
idx = idx + 1

Expand Down
25 changes: 25 additions & 0 deletions connect/cli/plugins/product/sync/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ def sync(self): # noqa: CCR001
'schema': data.value,
'dynamic': False,
'future': False,
'late': False,
}
else:
product['capabilities']['ppu']['schema'] = data.value
else:
product['capabilities']['ppu'] = None

if data.capability == 'Pay-as-you-go dynamic items support':
if not product['capabilities'].get('ppu', False):
if data.value == 'Enabled':
Expand All @@ -66,6 +68,7 @@ def sync(self): # noqa: CCR001
product['capabilities']['ppu']['dynamic'] = True
else:
product['capabilities']['ppu']['dynamic'] = False

if data.capability == 'Pay-as-you-go future charges support':
if not product['capabilities'].get('ppu', False):
if data.value == 'Enabled':
Expand All @@ -80,6 +83,22 @@ def sync(self): # noqa: CCR001
product['capabilities']['ppu']['future'] = True
else:
product['capabilities']['ppu']['future'] = False

if data.capability == 'Pay-as-you-go late charges support':
if not product['capabilities'].get('ppu', False):
if data.value == 'Enabled':
raise Exception(
"Report of late charges can't be enabled without Pay-as-you-go "
'support',
)
update = False

else:
if data.value == 'Enabled':
product['capabilities']['ppu']['late'] = True
else:
product['capabilities']['ppu']['late'] = False

if data.capability == 'Consumption reporting for Reservation Items':
if data.value == 'Enabled':
product['capabilities']['reservation']['consumption'] = True
Expand All @@ -105,21 +124,25 @@ def sync(self): # noqa: CCR001
product['capabilities']['tiers']['configs'] = {
'level': data.value,
}

if data.capability == 'Tier Accounts Sync':
if data.value == 'Enabled':
product['capabilities']['tiers']['updates'] = True
else:
product['capabilities']['tiers']['updates'] = False

if data.capability == 'Administrative Hold':
if data.value == 'Enabled':
product['capabilities']['subscription']['hold'] = True
else:
product['capabilities']['subscription']['hold'] = False

if data.capability == 'Dynamic Validation of Tier Requests':
if data.value == 'Enabled':
product['capabilities']['tiers']['validation'] = True
else:
product['capabilities']['tiers']['validation'] = False

if data.capability == 'Editable Ordering Parameters in Change Request':
if data.value == 'Enabled':
product['capabilities']['subscription']['change'][
Expand All @@ -129,11 +152,13 @@ def sync(self): # noqa: CCR001
product['capabilities']['subscription']['change'][
'editable_ordering_parameters'
] = False

if data.capability == 'Validation of Draft Change Request':
if data.value == 'Enabled':
product['capabilities']['subscription']['change']['validation'] = True
else:
product['capabilities']['subscription']['change']['validation'] = False

if data.capability == 'Validation of inquiring form for Change Requests':
if data.value == 'Enabled':
product['capabilities']['subscription']['change'][
Expand Down
Loading

0 comments on commit 7556557

Please sign in to comment.