Created
July 21, 2014 18:58
-
-
Save vanrysss/8aed57085ef996dcd68b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public with sharing class IntegratedOrdersReportController{ | |
| private static List<IntegratedReports_Order__c> intgOrders; | |
| private static List<Order_Summary__c> realOrders; | |
| public static List <MergedOrder> mergedOrders {get; set;} | |
| public date endDate {get; set;} | |
| public date startDate {get; set;} | |
| //consturctor | |
| public IntegratedOrdersReportController(){ | |
| } | |
| public List<IntegratedReports_Order__c> getIntgOrders(){ | |
| return intgOrders; | |
| } | |
| //command button method queries integrated and regular orders based upon date fields then populates a list of merged orders and displays | |
| //that data to the page | |
| public List<MergedOrder> computeOrders(){ | |
| intgOrders = [SELECT Id, Name, CreatedDate, Order_Number__c, Shipped_Date__c, Carrier__c, Shipped_Quantity__c, Tracking_Number__c | |
| FROM IntegratedReports_Order__c WHERE CreatedDate >:startDate AND CreatedDate <: endDate]; | |
| realOrders = [SELECT Id, Name, CreatedDate, Number_of_Line_Items_Associated__c, Navision_Order_ID__c | |
| FROM Order_Summary__c | |
| WHERE CreatedDate >:startDate AND CreatedDate <:endDate]; | |
| // System.assert(intgOrders.size() > 0,'The List of Integrated Orders is not of size ZERO.'); | |
| // System.assert(realOrders.size() > 0, 'The List of Orders is not of size ZERO.' ); | |
| Map<string,IntegratedReports_Order__c> myIntegratedMap = new Map<string,IntegratedReports_Order__c>(); | |
| for(IntegratedReports_Order__c indOrder : intgOrders){ | |
| myIntegratedMap.put(indOrder.Order_Number__c, indOrder); | |
| } | |
| for(Order_Summary__c order : realOrders){ | |
| if( order.Name != null && myIntegratedMap.containsKey(order.Name)){ | |
| mergedOrders.add(new MergedOrder(myIntegratedMap.get(order.Name),order)); | |
| } | |
| } | |
| MergedOrder testOrder = new MergedOrder(); | |
| testOrder.orderNumber = '0001111'; | |
| testOrder.shippedDate = Date.newInstance(2014, 07, 12); | |
| testOrder.quantityInIDS = 1; | |
| testOrder.dateInSFDC = testOrder.shippedDate; | |
| testOrder.quantityinSFDC = 1; | |
| mergedOrders.add(testOrder); | |
| System.assert(mergedOrders.size() > 0, 'There were no integrated orders found that match the system.'); | |
| return mergedOrders; | |
| } | |
| //custom class created for the express purpose of merging the matched IDS and normal orders for purposes of | |
| //displaying to the page. SHOULD NOT BE USED ANYWHERE ELSE IN THIS PROJECT | |
| public class MergedOrder{ | |
| public Id id {get; set;} //Order's id | |
| public string orderNumber {get; set;} // IDS Order_Number__c | |
| public date shippedDate{get; set;} // IDS Shipped_Date__c | |
| public double quantityInIDS {get; set;} // IDS Shipped_Quantity__c | |
| public dateTime dateInSFDC {get; set;} // Order's CreatedDate | |
| public Decimal quantityInSFDC {get; set;} // Order's Number_of_Line_Items_Associated__c | |
| public MergedOrder (){} | |
| public MergedOrder(IntegratedReports_Order__c intOrder, Order_Summary__c realOrder){ | |
| this.Id = realOrder.Id; | |
| this.orderNumber = intOrder.Order_Number__c; | |
| this.shippedDate = intOrder.Shipped_Date__c; | |
| this.quantityInIDS = intOrder.Shipped_Quantity__c; | |
| this.dateInSFDC = realOrder.CreatedDate; | |
| this.quantityINSFDC = realOrder.Number_of_Line_Items_Associated__c; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment