1// namespace.className managed package
2
3global inherited sharing class CustomPricingPlanImplementation implements VlocityOpenInterface {
4
5 global boolean invokeMethod(String methodName, Map<String, Object> input, Map<String, Object> output, Map<String, Object> options) {
6
7 if (methodName == 'testV2CustommPricingPlanImpl'){
8 testV2CustomPricingPlan(input, output, options);
9 }
10 if (methodName == 'testV3CustommPricingPlanImpl'){
11 testV3CustomPricingPlan(input, output, options);
12 }
13 return true;
14 }
15
16 private void testV2CustomPricingPlan(Map<String, Object> input, Map<String, Object> output, Map<String, Object> options) {
17 Map<String, Object> args = new Map<String, Object>();
18
19
20 CartWrapper wrapper = (CartWrapper)PricingPlanService.getFromPricingContext('Parent');
21 Map<String, Object> result = wrapper.call('getAllItems', null);
22 if(result.containsKey(CpqConstants.RESULT)){
23
24 Map<Id, CartItemWrapper> allItems = (Map<Id, CartItemWrapper>) result.get(CpqConstants.RESULT);
25 for(Id itemId : allItems.keySet()) {
26 CartItemWrapper itemWrapper = allItems.get(itemId);
27
28 // args.put(CpqConstants.FIELD, 'vlocity_lwc8__ItemName__c');
29 // args.put(CpqConstants.VALUE, 'DummyName');
30
31 args.put(CpqConstants.FIELD, 'vlocity_lwc8__EffectiveRecurringTotal__c'); //
32 args.put(CpqConstants.VALUE, 205);
33
34 itemWrapper.call(CpqConstants.SET_ITEM_FIELD, args);
35
36 }
37
38 }
39
40 }
41
42 private void testV3CustomPricingPlan(Map<String, Object> input, Map<String, Object> output, Map<String, Object> options) {
43 Map<String, Object> args = new Map<String, Object>();
44
45
46 CartWrapper wrapper = (CartWrapper)input.get('cartDocument');
47 Map<String, Object> result = wrapper.call('getAllItems', null);
48 if(result.containsKey(CpqConstants.RESULT)){
49
50 Map<String, CartItemWrapper> allItems = (Map<String, CartItemWrapper>) result.get(CpqConstants.RESULT);
51 for(String itemId : allItems.keySet()) {
52 CartItemWrapper itemWrapper = allItems.get(itemId);
53
54 // args.put(CpqConstants.FIELD, 'vlocity_lwc8__ItemName__c');
55 // args.put(CpqConstants.VALUE, 'DummyName');
56
57 args.put(CpqConstants.FIELD, 'vlocity_lwc8__EffectiveRecurringTotal__c'); //
58 args.put(CpqConstants.VALUE, 205);
59 itemWrapper.call(CpqConstants.SET_ITEM_FIELD, args);
60
61 }
62
63 }
64 Map<String, Object> args1 = new Map<String, Object>();
65 args.put(CpqConstants.FIELD, 'vlocity_lwc8__EffectiveRecurringTotal__c');
66 args.put(CpqConstants.VALUE, 410);
67
68 wrapper.call(CpqConstants.SET_CART_FIELD, args);
69
70 }
71
72}