Skip to content

Commit 0c8efe5

Browse files
authored
Merge pull request #225 from cloudblue/feature/LITE-28847-add-payg-late
LITE-28847: Support 'late' field in product capabilities
2 parents e8aa3e5 + 7556557 commit 0c8efe5

File tree

9 files changed

+1040
-779
lines changed

9 files changed

+1040
-779
lines changed

connect/cli/plugins/product/clone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def create_product(self, name=None):
176176

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

182182
ws = self.wb['Embedding Static Resources']

connect/cli/plugins/product/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
'Pay-as-you-go support and schema',
5050
'Pay-as-you-go dynamic items support',
5151
'Pay-as-you-go future charges support',
52+
'Pay-as-you-go late charges support',
5253
'Consumption reporting for Reservation Items',
5354
'Dynamic Validation of the Draft Requests',
5455
'Dynamic Validation of the Inquiring Form',

connect/cli/plugins/product/export.py

Lines changed: 57 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -681,95 +681,112 @@ def _dump_capabilities(ws, product, progress): # noqa: CCR001
681681
ws['B2'].value = '-'
682682
ws['C2'].value = ppu['schema'] if ppu else 'Disabled'
683683
ppu_validation.add(ws['C2'])
684+
684685
ws['A3'].value = 'Pay-as-you-go dynamic items support'
685686
ws['B3'].value = '-'
686687
ws['C3'].value = 'Enabled' if ppu and 'dynamic' in ppu and ppu['dynamic'] else 'Disabled'
687688
disabled_enabled.add(ws['C3'])
689+
688690
ws['A4'].value = 'Pay-as-you-go future charges support'
689691
ws['B4'].value = '-'
690692
ws['C4'].value = 'Enabled' if ppu and 'future' in ppu and ppu['future'] else 'Disabled'
691693
disabled_enabled.add(ws['C4'])
692-
ws['A5'].value = 'Consumption reporting for Reservation Items'
694+
695+
ws['A5'].value = 'Pay-as-you-go late charges support'
693696
ws['B5'].value = '-'
694-
ws['C5'].value = 'Enabled' if capabilities['reservation']['consumption'] else 'Disabled'
697+
ws['C5'].value = 'Enabled' if ppu and 'late' in ppu and ppu['late'] else 'Disabled'
695698
disabled_enabled.add(ws['C5'])
696699

700+
ws['A6'].value = 'Consumption reporting for Reservation Items'
701+
ws['B6'].value = '-'
702+
ws['C6'].value = 'Enabled' if capabilities['reservation']['consumption'] else 'Disabled'
703+
disabled_enabled.add(ws['C6'])
704+
697705
def _get_reporting_consumption(reservation_cap):
698706
if 'consumption' in reservation_cap and reservation_cap['consumption']:
699707
return 'Enabled'
700708
return 'Disabled'
701709

702-
ws['C5'].value = _get_reporting_consumption(capabilities['reservation'])
703-
disabled_enabled.add(ws['C5'])
704-
ws['A6'].value = 'Dynamic Validation of the Draft Requests'
705-
ws['B6'].value = '-'
710+
ws['C6'].value = _get_reporting_consumption(capabilities['reservation'])
711+
disabled_enabled.add(ws['C6'])
712+
713+
ws['A7'].value = 'Dynamic Validation of the Draft Requests'
714+
ws['B7'].value = '-'
706715

707716
def _get_dynamic_validation_draft(capabilities_cart):
708717
if 'validation' in capabilities_cart and capabilities['cart']['validation']:
709718
return 'Enabled'
710719
return 'Disabled'
711720

712-
ws['C6'].value = _get_dynamic_validation_draft(capabilities['cart'])
713-
disabled_enabled.add(ws['C6'])
714-
ws['A7'].value = 'Dynamic Validation of the Inquiring Form'
715-
ws['B7'].value = '-'
721+
ws['C7'].value = _get_dynamic_validation_draft(capabilities['cart'])
722+
disabled_enabled.add(ws['C7'])
723+
724+
ws['A8'].value = 'Dynamic Validation of the Inquiring Form'
725+
ws['B8'].value = '-'
716726

717727
def _get_validation_inquiring(capabilities_inquiring):
718728
if 'validation' in capabilities_inquiring and capabilities_inquiring['validation']:
719729
return 'Enabled'
720730
return 'Disabled'
721731

722-
ws['C7'].value = _get_validation_inquiring(capabilities['inquiring'])
723-
disabled_enabled.add(ws['C7'])
724-
ws['A8'].value = 'Reseller Authorization Level'
725-
ws['B8'].value = '-'
732+
ws['C8'].value = _get_validation_inquiring(capabilities['inquiring'])
733+
disabled_enabled.add(ws['C8'])
734+
735+
ws['A9'].value = 'Reseller Authorization Level'
736+
ws['B9'].value = '-'
726737

727738
def _get_reseller_authorization_level(tiers):
728739
if tiers and 'configs' in tiers and tiers['configs']:
729740
return tiers['configs']['level']
730741
return 'Disabled'
731742

732-
ws['C8'].value = _get_reseller_authorization_level(tiers)
733-
tier_validation.add(ws['C8'])
734-
ws['A9'].value = 'Tier Accounts Sync'
735-
ws['B9'].value = '-'
736-
ws['C9'].value = 'Enabled' if tiers and 'updates' in tiers and tiers['updates'] else 'Disabled'
737-
disabled_enabled.add(ws['C9'])
738-
ws['A10'].value = 'Administrative Hold'
743+
ws['C9'].value = _get_reseller_authorization_level(tiers)
744+
tier_validation.add(ws['C9'])
745+
746+
ws['A10'].value = 'Tier Accounts Sync'
739747
ws['B10'].value = '-'
748+
ws['C10'].value = 'Enabled' if tiers and 'updates' in tiers and tiers['updates'] else 'Disabled'
749+
disabled_enabled.add(ws['C10'])
740750

741-
ws['A11'].value = 'Dynamic Validation of Tier Requests'
751+
ws['A11'].value = 'Administrative Hold'
742752
ws['B11'].value = '-'
743-
ws['C11'].value = 'Enabled' if capabilities['tiers']['validation'] else 'Disabled'
753+
754+
def _get_administrative_hold(capabilities):
755+
if 'hold' in capabilities['subscription'] and capabilities['subscription']['hold']:
756+
return 'Enabled'
757+
return 'Disabled'
758+
759+
ws['C11'].value = _get_administrative_hold(capabilities)
744760
disabled_enabled.add(ws['C11'])
745-
ws['A12'].value = 'Editable Ordering Parameters in Change Request'
761+
762+
ws['A12'].value = 'Dynamic Validation of Tier Requests'
746763
ws['B12'].value = '-'
747-
ws['C12'].value = (
748-
'Enabled' if subscription['change']['editable_ordering_parameters'] else 'Disabled'
749-
)
764+
ws['C12'].value = 'Enabled' if capabilities['tiers']['validation'] else 'Disabled'
750765
disabled_enabled.add(ws['C12'])
751-
ws['A13'].value = 'Validation of Draft Change Request'
766+
767+
ws['A13'].value = 'Editable Ordering Parameters in Change Request'
752768
ws['B13'].value = '-'
753-
ws['C13'].value = 'Enabled' if 'validation' in change and change['validation'] else 'Disabled'
769+
ws['C13'].value = (
770+
'Enabled' if subscription['change']['editable_ordering_parameters'] else 'Disabled'
771+
)
754772
disabled_enabled.add(ws['C13'])
755-
ws['A14'].value = 'Validation of inquiring form for Change Requests'
773+
774+
ws['A14'].value = 'Validation of Draft Change Request'
756775
ws['B14'].value = '-'
757-
ws['C14'].value = (
776+
ws['C14'].value = 'Enabled' if 'validation' in change and change['validation'] else 'Disabled'
777+
disabled_enabled.add(ws['C14'])
778+
779+
ws['A15'].value = 'Validation of inquiring form for Change Requests'
780+
ws['B15'].value = '-'
781+
ws['C15'].value = (
758782
'Enabled'
759783
if 'inquiring_validation' in change and change['inquiring_validation']
760784
else 'Disabled'
761785
)
762-
disabled_enabled.add(ws['C14'])
786+
disabled_enabled.add(ws['C15'])
763787

764-
def _get_administrative_hold(capabilities):
765-
if 'hold' in capabilities['subscription'] and capabilities['subscription']['hold']:
766-
return 'Enabled'
767-
return 'Disabled'
768-
769-
ws['C10'].value = _get_administrative_hold(capabilities)
770-
disabled_enabled.add(ws['C10'])
771788
idx = 2
772-
while idx < 11:
789+
while idx < 12:
773790
action_validation.add(f'B{idx}')
774791
idx = idx + 1
775792

connect/cli/plugins/product/sync/capabilities.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ def sync(self): # noqa: CCR001
4848
'schema': data.value,
4949
'dynamic': False,
5050
'future': False,
51+
'late': False,
5152
}
5253
else:
5354
product['capabilities']['ppu']['schema'] = data.value
5455
else:
5556
product['capabilities']['ppu'] = None
57+
5658
if data.capability == 'Pay-as-you-go dynamic items support':
5759
if not product['capabilities'].get('ppu', False):
5860
if data.value == 'Enabled':
@@ -66,6 +68,7 @@ def sync(self): # noqa: CCR001
6668
product['capabilities']['ppu']['dynamic'] = True
6769
else:
6870
product['capabilities']['ppu']['dynamic'] = False
71+
6972
if data.capability == 'Pay-as-you-go future charges support':
7073
if not product['capabilities'].get('ppu', False):
7174
if data.value == 'Enabled':
@@ -80,6 +83,22 @@ def sync(self): # noqa: CCR001
8083
product['capabilities']['ppu']['future'] = True
8184
else:
8285
product['capabilities']['ppu']['future'] = False
86+
87+
if data.capability == 'Pay-as-you-go late charges support':
88+
if not product['capabilities'].get('ppu', False):
89+
if data.value == 'Enabled':
90+
raise Exception(
91+
"Report of late charges can't be enabled without Pay-as-you-go "
92+
'support',
93+
)
94+
update = False
95+
96+
else:
97+
if data.value == 'Enabled':
98+
product['capabilities']['ppu']['late'] = True
99+
else:
100+
product['capabilities']['ppu']['late'] = False
101+
83102
if data.capability == 'Consumption reporting for Reservation Items':
84103
if data.value == 'Enabled':
85104
product['capabilities']['reservation']['consumption'] = True
@@ -105,21 +124,25 @@ def sync(self): # noqa: CCR001
105124
product['capabilities']['tiers']['configs'] = {
106125
'level': data.value,
107126
}
127+
108128
if data.capability == 'Tier Accounts Sync':
109129
if data.value == 'Enabled':
110130
product['capabilities']['tiers']['updates'] = True
111131
else:
112132
product['capabilities']['tiers']['updates'] = False
133+
113134
if data.capability == 'Administrative Hold':
114135
if data.value == 'Enabled':
115136
product['capabilities']['subscription']['hold'] = True
116137
else:
117138
product['capabilities']['subscription']['hold'] = False
139+
118140
if data.capability == 'Dynamic Validation of Tier Requests':
119141
if data.value == 'Enabled':
120142
product['capabilities']['tiers']['validation'] = True
121143
else:
122144
product['capabilities']['tiers']['validation'] = False
145+
123146
if data.capability == 'Editable Ordering Parameters in Change Request':
124147
if data.value == 'Enabled':
125148
product['capabilities']['subscription']['change'][
@@ -129,11 +152,13 @@ def sync(self): # noqa: CCR001
129152
product['capabilities']['subscription']['change'][
130153
'editable_ordering_parameters'
131154
] = False
155+
132156
if data.capability == 'Validation of Draft Change Request':
133157
if data.value == 'Enabled':
134158
product['capabilities']['subscription']['change']['validation'] = True
135159
else:
136160
product['capabilities']['subscription']['change']['validation'] = False
161+
137162
if data.capability == 'Validation of inquiring form for Change Requests':
138163
if data.value == 'Enabled':
139164
product['capabilities']['subscription']['change'][

0 commit comments

Comments
 (0)