Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class QuoteSyncUtil {
- public static boolean isRunningTest = false;
- private static Map<String, String> quoteFieldMap = new Map<String, String>();
- private static Map<String, String> quoteLineFieldMap = new Map<String, String>();
- static {
- public static String getQuoteFieldsString() {
- String fields = '';
- for (String field : getQuoteFields()) {
- fields += ', ' + field;
- }
- return fields;
- }
- Map<String, QuoteLineSyncField__c> quoteLineFields = QuoteLineSyncField__c.getAll();
- system.debug('KENNY '+quoteLineFields);
- for (String quoteLineField : quoteLineFields.keySet()) {
- QuoteLineSyncField__c quoteLineSyncField = QuoteLineSyncField__c.getInstance(quoteLineField);
- //FIXME - uppercase value cause NPE
- quoteLineFieldMap.put(quoteLineSyncField.Name, quoteLineSyncField.OppLineSyncField__c);
- system.debug('KENNY '+QuoteLineSyncField__c.getInstance(quoteLineField));
- //quoteLineFieldMap.put(quoteLineField, quoteLineSyncField.OppLineSyncField__c);
- if(quotelinefield == 'Product_Type__c'){
- System.debug('********* ' + quoteLineField);
- System.debug('^^^^^^^^^ ' + quotelineSyncField.OppLineSyncField__c);
- }
- }
- }
- public static Set<String> getQuoteLineFields() {
- system.debug('KENNY '+quoteLineFieldMap.keyset());
- return quoteLineFieldMap.keySet();
- }
- List<String> oppLineFields = QuoteSyncUtil.getOppLineFields();
- // pricebook entry ids in trigger
- Set<Id> pbEntryIds = new Set<Id>();
- // a Set of Pricebook2 Ids represented in Trigger.new
- Set<Id> setPricebookId = new Set<Id>();
- String oliFields = QuoteSyncUtil.getOppLineFieldsString();
- String qliFields = QuoteSyncUtil.getQuoteLineFieldsString();
- String qliIds = '';
- String quoteIdString = '';
- for (QuoteLineItem qli : qlisInTrigger) {
- if (qliIds != '') qliIds += ', ';
- qliIds += ''' + qli.Id + ''';
- if (quoteIdString != '') quoteIdString += ', ';
- quoteIdString += ''' + qli.QuoteId + ''';
- pbEntryIds.add(qli.PricebookEntryId);
- }
- String qliQuery = 'SELECT Id, ' +
- 'QuoteId, ' +
- 'PricebookEntryId, ' +
- 'UnitPrice, ' +
- 'Quantity, ' +
- 'Discount, ' +
- 'ServiceDate, ' +
- 'SortOrder, ' +
- 'PricebookEntry.Product2.Name, ' +
- 'PricebookEntry.Product2.Product_Type__c, ' +
- 'PricebookEntry.Product2.Approval_Required__c, ' +
- 'PricebookEntry.Pricebook2Id, ' +
- 'ListPrice, ' +
- 'Discount_off_List__c ' +
- qliFields +
- ' FROM QuoteLineItem where QuoteId in (' + quoteIdString + ')';
- System.debug(qliQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement