0% found this document useful (0 votes)
2 views3 pages

LIT2021

The provided code defines a method to update orders that are lost in transit by comparing new and old order maps. It identifies master orders based on delivery status and updates relevant order items and orchestration items accordingly. The method ensures that specific fields are cleared or updated based on the conditions set for different order types and statuses.

Uploaded by

roshnns
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

LIT2021

The provided code defines a method to update orders that are lost in transit by comparing new and old order maps. It identifies master orders based on delivery status and updates relevant order items and orchestration items accordingly. The method ensures that specific fields are cleared or updated based on the conditions set for different order types and statuses.

Uploaded by

roshnns
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

public static void updateForLostInTransit(Map<ID, Order> newOrderMap , Map<ID,

Order> oldOrderMap) {
if(!checkRecursive.isFutureUpdate)
{
List<OrderItem> updateOrderItemList = new List<OrderItem>();
List<vlocity_cmt__OrchestrationItem__c> updateOrchItemList = new
List<vlocity_cmt__OrchestrationItem__c>();
List<Order> orderList = new List<Order>();
Set<Id> masterOrderIdSet = new Set<Id>();
for(Order newOrder : newOrderMap.values()) {
Order oldOrder = oldOrderMap.get(newOrder.Id);
if(newOrder.isMasterOrder__c == true &&
(newOrder.Delivery_Status__c != oldOrder.Delivery_Status__c) &&
newOrder.Delivery_Status__c =='1'){
masterOrderIdSet.add(newOrder.Id);
}
else if(newOrder.isMasterOrder__c == true &&
newOrder.Delivery_Status__c =='6' && newOrder.Unpaired__c == true &&
newOrder.Pairing_Status__c == 'Completed')
{
masterOrderIdSet.add(newOrder.Id);
}
}
system.debug('MOISET1---> ' + masterOrderIdSet );
if(!masterOrderIdSet.isEmpty()) {
//added on 16-june-2021 for removing the value of air way billing
id if exist
for(Order ord : [SELECT Id, Delivery_Status__c,airWayBillId__c,
Pairing_Status__c, Unpaired__c FROM Order WHERE Id IN : masterOrderIdSet]){
Order orderUpdate = new Order();
if(ord.airWayBillId__c != null &&
String.Isnotblank(ord.airWayBillId__c)){
orderUpdate.id = ord.Id;
orderUpdate.airWayBillId__c = '';
//orderUpdate.Pairing_Status__c = 'Unpaired Completed';
//orderList.add(orderUpdate);
}
}
system.debug('MOISET2---> ' + masterOrderIdSet );
Map<String, String> numberMap = new Map<String, String>();
for(OrderItem oi : [SELECT Id, ICCID__c, Old_ICCID__c, IMEI__c,
IMSI__c, Old_IMSI__c,
OrderId,Pairing_Status__c,
Order.MasterOrder__c, Order.MasterOrder__r.Delivery_Status__c,
Order.MasterOrder__r.airWayBillId__c,
Order.MasterOrder__r.Pairing_Status__c,
Order.MasterOrder__r.Unpaired__c,
vlocity_cmt__Action__c,

vlocity_cmt__ParentItemId__c,Order.Order_Type__c
FROM OrderItem
WHERE Order.MasterOrder__c != null AND
Order.MasterOrder__c IN: masterOrderIdSet
ORDER BY vlocity_cmt__Action__c DESC]) {
if(oi.Order.MasterOrder__r.Delivery_Status__c == '6' &&
(oi.ICCID__c != '' || oi.IMEI__c != '' || oi.IMSI__c != '')
&& oi.Order.MasterOrder__r.Pairing_Status__c == 'Completed'
&& oi.Order.MasterOrder__r.Unpaired__c == true){
if(oi.Order.Order_Type__c =='New Connect' ||
oi.Order.Order_Type__c =='Infinity to Gold with Retention' ||
oi.Order.Order_Type__c =='Gold to Infinity with Retention')
{
oi.ICCID__c = '';
oi.IMEI__c = '';
oi.IMSI__c = '';
//oi.Pairing_Status__c = 'Unpaired Completed';
updateOrderItemList.add(oi);
}
else if(oi.Order.Order_Type__c =='Retention Existing
Service New Device' || oi.Order.Order_Type__c =='Change CPE/Handset/Device
Replacement' || oi.Order.Order_Type__c =='Retention with Upgrade' ||
oi.Order.Order_Type__c =='Retention with Downgrade')
{
oi.IMEI__c = '';
//oi.Pairing_Status__c = 'Unpaired Completed';
updateOrderItemList.add(oi);
}
else if(oi.Order.Order_Type__c =='Gold to Infinity' ||
oi.Order.Order_Type__c =='Infinity to Gold' || oi.Order.Order_Type__c =='SIM
Replacement')
{
oi.ICCID__c = '';
oi.IMSI__c = '';
//oi.Pairing_Status__c = 'Unpaired Completed';
updateOrderItemList.add(oi);
}
}else if(oi.Order.MasterOrder__r.Delivery_Status__c == '1' &&
oi.vlocity_cmt__ParentItemId__c == null){ //Logic to update old ICCID and old IMSI
if(oi.vlocity_cmt__Action__c == 'Disconnect'){
if(oi.IMSI__c != null && oi.IMSI__c != '')
numberMap.put(oi.OrderId+'_oldIMSI', oi.IMSI__c);
if(oi.ICCID__c != null && oi.ICCID__c != '')
numberMap.put(oi.OrderId+'_oldICCID', oi.ICCID__c);
}else if(oi.vlocity_cmt__Action__c == 'Add'){
if(numberMap.containsKey(oi.OrderId+'_oldIMSI'))
oi.Old_IMSI__c =
numberMap.get(oi.OrderId+'_oldIMSI');
if(numberMap.containsKey(oi.OrderId+'_oldICCID'))
oi.Old_ICCID__c =
numberMap.get(oi.OrderId+'_oldICCID');
}
system.debug('numberMap-'+numberMap);
updateOrderItemList.add(oi);
}

}
system.debug('numberMap-'+numberMap);
system.debug('updateOrderItemList-'+updateOrderItemList);
List<String> applicableOrchItemList = new List<String>{'Update
ICCID,IMEI and Courier Details',
'SIM Pairing','Pairing Status','Update SO','Delivered',
'Delivery SMS Notification','CSP Update Status',
'Auto Task Break','A2P Pairing Complete','SIM ICCID & MIN
unPairingLIT'
};
for(vlocity_cmt__OrchestrationItem__c orchItem : [SELECT
Id, Name, vlocity_cmt__State__c FROM vlocity_cmt__OrchestrationItem__c
WHERE
vlocity_cmt__OrchestrationPlanId__r.vlocity_cmt__OrderId__c IN :masterOrderIdSet
AND Name IN :applicableOrchItemList
AND
vlocity_cmt__OrchestrationPlanId__r.vlocity_cmt__OrderId__r.Delivery_Status__c =
'6'
AND
vlocity_cmt__OrchestrationPlanId__r.vlocity_cmt__OrderId__r.Pairing_Status__c =
'Completed'
AND
vlocity_cmt__OrchestrationPlanId__r.vlocity_cmt__OrderId__r.Unpaired__c = true
]) {

if(orchItem.Name == 'SIM Pairing' || orchItem.Name == 'Pairing Status' ||


orchItem.Name == 'Update SO'
||
orchItem.Name == 'Delivered' || orchItem.Name == 'Delivery SMS Notification' ||

orchItem.Name == 'CSP Update Status' || orchItem.Name == 'Auto Task Break' ||

orchItem.Name == 'A2P Pairing Complete' || orchItem.Name == 'SIM ICCID & MIN


unPairingLIT') {

orchItem.vlocity_cmt__State__c = 'Pending';

}
else
if(orchItem.Name == 'Update ICCID,IMEI and Courier Details' ){

orchItem.vlocity_cmt__State__c = 'Running';
}

updateOrchItemList.add(orchItem);
}
}

if(updateOrderItemList != null ) {
Database.update(updateOrderItemList, false);
}
if(orderList.size() > 0){
system.debug('orderList-> ' + orderList);
Database.update(orderList, false);
}
if(updateOrchItemList != null) {
Database.update(updateOrchItemList, false);
}
}
}

Attr - pick - x,y,z,t products Data

You might also like