View Javadoc
1   package org.kuali.ole.batch.rule;
2   
3   import org.kuali.ole.OLEConstants;
4   import org.kuali.ole.batch.bo.OLEBatchProcessProfileBo;
5   import org.kuali.ole.batch.bo.OLEBatchProcessProfileConstantsBo;
6   import org.kuali.ole.batch.bo.OLEBatchProcessProfileDataMappingOptionsBo;
7   import org.kuali.ole.batch.bo.OLEBatchProcessProfileMappingOptionsBo;
8   import org.kuali.ole.select.OleSelectConstant;
9   import org.kuali.ole.sys.OLEKeyConstants;
10  import org.kuali.rice.krad.maintenance.MaintenanceDocument;
11  import org.kuali.rice.krad.rules.MaintenanceDocumentRuleBase;
12  import org.kuali.rice.krad.util.GlobalVariables;
13  import org.kuali.rice.krad.util.KRADConstants;
14  
15  import java.util.*;
16  
17  /**
18   * Created with IntelliJ IDEA.
19   * User: ?
20   * Date: 3/21/13
21   * Time: 1:16 PM
22   * To change this template use File | Settings | File Templates.
23   */
24  public class OleBatchProcessProfileRule extends MaintenanceDocumentRuleBase {
25  
26      private boolean isCurrencyTypeAvailable = false;
27  
28      protected boolean processCustomSaveDocumentBusinessRules(MaintenanceDocument document) {
29          boolean isValid = true;
30          OLEBatchProcessProfileBo oleBatchProcessProfileBo = (OLEBatchProcessProfileBo) document.getNewMaintainableObject().getDataObject();
31          if(oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.ORDER_RECORD_IMPORT) || oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.INVOICE_RECORD_IMPORT)){
32              if(oleBatchProcessProfileBo.getBibImportProfileForOrderRecord() == null){
33                  GlobalVariables.getMessageMap().putError(OLEConstants.OLEBatchProcess.BIB_IMPORT_PROFILE, OLEKeyConstants.ERROR_REQUIRED, "Bib Import Profile");
34              }
35          }
36          if(oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.ORDER_RECORD_IMPORT)) {
37              isValid &= validateRequiredFieldsForOrderRecordImport(oleBatchProcessProfileBo);
38          }
39          if(oleBatchProcessProfileBo.getBatchProcessProfileType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.INVOICE_RECORD_IMPORT)) {
40              isValid &= validateRequiredFieldsForInvoiceImport(oleBatchProcessProfileBo);
41          }
42          return isValid;
43      }
44  
45      /**
46       * This method  validates duplicate Agreement Method Id and return boolean value.
47       *
48       * @param
49       * @return boolean
50       */
51      private boolean validateRequiredFieldsForOrderRecordImport(OLEBatchProcessProfileBo oleBatchProcessProfileBo) {
52          Set<String> availableFields = new HashSet<>();
53          List<OLEBatchProcessProfileMappingOptionsBo> oleBatchProcessProfileMappingOptionsBoList = oleBatchProcessProfileBo.getOleBatchProcessProfileMappingOptionsList();
54          for (OLEBatchProcessProfileMappingOptionsBo oleBatchProcessProfileMappingOptionsBo : oleBatchProcessProfileMappingOptionsBoList) {
55              List<OLEBatchProcessProfileDataMappingOptionsBo> oleBatchProcessProfileDataMappingOptionsBoList = oleBatchProcessProfileMappingOptionsBo.getOleBatchProcessProfileDataMappingOptionsBoList();
56              for (int dataMapCount = 0;dataMapCount<oleBatchProcessProfileDataMappingOptionsBoList.size();dataMapCount++) {
57                  if(OLEConstants.OLEBatchProcess.LIST_PRICE.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
58                      availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
59                  }
60                  else if(OLEConstants.OLEBatchProcess.VENDOR_NUMBER.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())){
61                      availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
62                  }
63                  else if(OLEConstants.OLEBatchProcess.QUANTITY.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())){
64                      availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
65                  }
66                  else if(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())){
67                      availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
68                  }
69                  else if(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())){
70                      availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
71                  }
72                  else if(OLEConstants.OLEBatchProcess.OBJECT_CODE.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())){
73                      availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
74                  }
75                  else if(OLEConstants.OLEBatchProcess.ITEM_CHART_CODE.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())){
76                      availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
77                  }
78                  else if(OLEConstants.OLEBatchProcess.COST_SOURCE.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
79                      availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
80                  }
81                  else if(OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
82                      availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
83                  }
84                  else if(OLEConstants.OLEBatchProcess.BUILDING_CODE.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
85                      availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
86                  }
87                  else if(OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
88                      availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
89                  }
90                  else if(OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
91                      availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
92                  }
93                  else if(OLEConstants.OLEBatchProcess.ORG_CODE.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
94                      availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
95                  }
96                  else if(OLEConstants.OLEBatchProcess.CHART_CODE.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
97                      availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
98                  }
99                  else if(OLEConstants.OLEBatchProcess.FUNDING_SOURCE.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
100                     availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
101                 }
102                 else if(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
103                     availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
104                 }
105             }
106         }
107         List<OLEBatchProcessProfileConstantsBo> oleBatchProcessProfileConstantsBoList = oleBatchProcessProfileBo.getOleBatchProcessProfileConstantsList();
108             for(int constantCount = 0;constantCount < oleBatchProcessProfileConstantsBoList.size();constantCount++ )  {
109                 if(OLEConstants.OLEBatchProcess.LIST_PRICE.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())) {
110                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
111                 }
112                 else if(OLEConstants.OLEBatchProcess.VENDOR_NUMBER.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())){
113                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
114                 }
115                 else if(OLEConstants.OLEBatchProcess.QUANTITY.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())){
116                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
117                 }
118                 else if(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())){
119                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
120                 }
121                 else if(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())){
122                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
123                 }
124                 else if(OLEConstants.OLEBatchProcess.OBJECT_CODE.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())){
125                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
126                 }
127                 else if(OLEConstants.OLEBatchProcess.ITEM_CHART_CODE.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())){
128                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
129                 }
130                 else if(OLEConstants.OLEBatchProcess.COST_SOURCE.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())) {
131                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
132                 }
133                 else if(OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())) {
134                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
135                 }
136                 else if(OLEConstants.OLEBatchProcess.BUILDING_CODE.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())) {
137                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
138                 }
139                 else if(OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())) {
140                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
141                 }
142                 else if(OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())) {
143                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
144                 }
145                 else if(OLEConstants.OLEBatchProcess.ORG_CODE.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())) {
146                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
147                 }
148                 else if(OLEConstants.OLEBatchProcess.CHART_CODE.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())) {
149                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
150                 }
151                 else if(OLEConstants.OLEBatchProcess.FUNDING_SOURCE.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())) {
152                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
153                 }
154                 else if(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())) {
155                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
156                 }
157             }
158         String requiredFields = null;
159         requiredFields = checkForAllMandatoryFieldsForOrderImport(oleBatchProcessProfileBo,availableFields,requiredFields);
160         if(requiredFields == null){
161             return true;
162         }
163         else {
164             GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS,OLEConstants.OLEBatchProcess.REQUIRED_VALUES_FOR_ORDER_RECORD_IMPORT,requiredFields);
165         }
166         return false;
167     }
168 
169     private String checkForAllMandatoryFieldsForOrderImport(OLEBatchProcessProfileBo oleBatchProcessProfileBo,Set<String> availableFields,String requiredFields){
170         List<String> mandatoryFields = new ArrayList<>();
171         if(oleBatchProcessProfileBo.getMarcOnly()){
172             mandatoryFields.add(OLEConstants.OLEBatchProcess.LIST_PRICE);
173             mandatoryFields.add(OLEConstants.OLEBatchProcess.VENDOR_NUMBER);
174             mandatoryFields.add(OLEConstants.OLEBatchProcess.QUANTITY);
175             mandatoryFields.add(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS);
176             mandatoryFields.add(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER);
177             mandatoryFields.add(OLEConstants.OLEBatchProcess.OBJECT_CODE);
178             mandatoryFields.add(OLEConstants.OLEBatchProcess.ITEM_CHART_CODE);
179         }
180         mandatoryFields.add(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION);
181         mandatoryFields.add(OLEConstants.OLEBatchProcess.COST_SOURCE);
182         mandatoryFields.add(OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION);
183         mandatoryFields.add(OLEConstants.OLEBatchProcess.BUILDING_CODE);
184         mandatoryFields.add(OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE);
185         mandatoryFields.add(OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER);
186         mandatoryFields.add(OLEConstants.OLEBatchProcess.ORG_CODE);
187         mandatoryFields.add(OLEConstants.OLEBatchProcess.CHART_CODE);
188         mandatoryFields.add(OLEConstants.OLEBatchProcess.FUNDING_SOURCE);
189         mandatoryFields.removeAll(availableFields);
190         if(mandatoryFields == null || mandatoryFields.size() == 0){
191             return requiredFields;
192         }
193         else {
194             requiredFields = addRequiredFieldsMessageForOrderImport(mandatoryFields);
195             return requiredFields;
196         }
197     }
198 
199     private String addRequiredFieldsMessageForOrderImport(List<String> mandatoryFields){
200         StringBuffer fieldsRequired = new StringBuffer();
201         for(int fieldCount = 0; fieldCount < mandatoryFields.size();fieldCount++){
202             if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.LIST_PRICE)){
203                 fieldsRequired.append(OLEConstants.REQUIRED_LIST_PRICE);
204             }
205             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.VENDOR_NUMBER)){
206                 fieldsRequired.append(OLEConstants.REQUIRED_VENDOR_NUMBER);
207             }
208             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.QUANTITY)){
209                 fieldsRequired.append(OLEConstants.REQUIRED_QTY);
210             }
211             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.ITEM_NO_OF_PARTS)){
212                 fieldsRequired.append(OLEConstants.REQUIRED_NO_OF_PARTS);
213             }
214             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER)){
215                 fieldsRequired.append(OLEConstants.REQUIRED_ACCOUNT_NUMBER);
216             }
217             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.OBJECT_CODE)){
218                 fieldsRequired.append(OLEConstants.REQUIRED_OBJECT_CODE);
219             }
220             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.ITEM_CHART_CODE)){
221                 fieldsRequired.append(OLEConstants.REQUIRED_ITEM_CHART_CD);
222             }
223             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.COST_SOURCE)){
224                 fieldsRequired.append(OLEConstants.REQUIRED_COST_SOURCE);
225             }
226             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION)){
227                 fieldsRequired.append(OLEConstants.REQUIRED_METHOD_OF_PO_TRANSMISSION);
228             }
229             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.BUILDING_CODE)){
230                 fieldsRequired.append(OLEConstants.REQUIRED_BUILDING_CODE);
231             }
232             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER)){
233                 fieldsRequired.append(OLEConstants.REQUIRED_DELIVERY_BUILDING_ROOM_NUMBER);
234             }
235             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE)){
236                 fieldsRequired.append(OLEConstants.REQUIRED_DELIVERY_CAMPUS_CODE);
237             }
238             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.ORG_CODE)){
239                 fieldsRequired.append(OLEConstants.REQUIRED_ORG_CODE);
240             }
241             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.CHART_CODE)){
242                 fieldsRequired.append(OLEConstants.REQUIRED_CHART_CODE);
243             }
244             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.FUNDING_SOURCE)){
245                 fieldsRequired.append(OLEConstants.REQUIRED_FUNDING_SOURCE);
246             }
247             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION)){
248                 fieldsRequired.append(OLEConstants.REQUIRED_DEFAULT_LOCATION);
249             }
250             if(!(fieldCount  == mandatoryFields.size()-1)){
251                 fieldsRequired.append(", ");
252             }
253         }
254         fieldsRequired.append(mandatoryFields.size() == 1?" is":" are");
255         return fieldsRequired.toString();
256     }
257 
258 
259     private boolean validateRequiredFieldsForInvoiceImport(OLEBatchProcessProfileBo oleBatchProcessProfileBo){
260         Set<String> availableFields = new HashSet<>();
261         List<OLEBatchProcessProfileMappingOptionsBo> oleBatchProcessProfileMappingOptionsBoList = oleBatchProcessProfileBo.getOleBatchProcessProfileMappingOptionsList();
262         for (OLEBatchProcessProfileMappingOptionsBo oleBatchProcessProfileMappingOptionsBo : oleBatchProcessProfileMappingOptionsBoList) {
263             List<OLEBatchProcessProfileDataMappingOptionsBo> oleBatchProcessProfileDataMappingOptionsBoList = oleBatchProcessProfileMappingOptionsBo.getOleBatchProcessProfileDataMappingOptionsBoList();
264             for (int dataMapCount = 0;dataMapCount<oleBatchProcessProfileDataMappingOptionsBoList.size();dataMapCount++) {
265                 if(OLEConstants.OLEBatchProcess.LIST_PRICE.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
266                     availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
267                 }
268                 else if(OLEConstants.OLEBatchProcess.FOREIGN_LIST_PRICE.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())) {
269                     availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
270                 }
271                 else if(OLEConstants.OLEBatchProcess.QUANTITY.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())){
272                     availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
273                 }
274                 else if(OLEConstants.OLEBatchProcess.INVOICE_DATE.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())){
275                     availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
276                 }
277                 else if(OLEConstants.OLEBatchProcess.VENDOR_NUMBER.equals(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField())){
278                     availableFields.add(oleBatchProcessProfileDataMappingOptionsBoList.get(dataMapCount).getDestinationField());
279                 }
280             }
281         }
282         List<OLEBatchProcessProfileConstantsBo> oleBatchProcessProfileConstantsBoList = oleBatchProcessProfileBo.getOleBatchProcessProfileConstantsList();
283             for(int constantCount = 0;constantCount < oleBatchProcessProfileConstantsBoList.size();constantCount++ )  {
284                 if(OLEConstants.OLEBatchProcess.LIST_PRICE.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())) {
285                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
286                 }
287                 else if(OLEConstants.OLEBatchProcess.FOREIGN_LIST_PRICE.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())) {
288                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
289                 }
290                 else if(OLEConstants.OLEBatchProcess.QUANTITY.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())){
291                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
292                 }
293                 else if(OLEConstants.OLEBatchProcess.INVOICE_DATE.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())){
294                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
295                 }
296                 else if(OLEConstants.OLEBatchProcess.VENDOR_NUMBER.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())){
297                     availableFields.add(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName());
298                 }
299                 else if(OLEConstants.OLEBatchProcess.CURRENCY_TYPE.equals(oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeName())){
300                     if(!oleBatchProcessProfileConstantsBoList.get(constantCount).getAttributeValue().equalsIgnoreCase(OleSelectConstant.CURRENCY_TYPE_NAME)){
301                         isCurrencyTypeAvailable = true;
302                     }
303                 }
304             }
305         String requiredFields = null;
306         requiredFields = checkForAllMandatoryFieldsForInvoiceImport(availableFields,requiredFields);
307         if(requiredFields == null){
308             return true;
309         }
310         else {
311             GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS,OLEConstants.OLEBatchProcess.REQUIRED_VALUES_FOR_ORDER_RECORD_IMPORT,requiredFields);
312         }
313         return false;
314     }
315 
316 
317 
318     private String checkForAllMandatoryFieldsForInvoiceImport(Set<String> availableFields,String requiredFields){
319         List<String> mandatoryFields = new ArrayList<>();
320         mandatoryFields.add(OLEConstants.OLEBatchProcess.LIST_PRICE);
321         mandatoryFields.add(OLEConstants.OLEBatchProcess.QUANTITY);
322         mandatoryFields.add(OLEConstants.OLEBatchProcess.INVOICE_DATE);
323         mandatoryFields.add(OLEConstants.OLEBatchProcess.VENDOR_NUMBER);
324         if(isCurrencyTypeAvailable){
325             mandatoryFields.add(OLEConstants.OLEBatchProcess.FOREIGN_LIST_PRICE);
326             mandatoryFields.remove(OLEConstants.OLEBatchProcess.LIST_PRICE);
327         }
328         mandatoryFields.removeAll(availableFields);
329         if(mandatoryFields == null || mandatoryFields.size() == 0){
330             return requiredFields;
331         }
332         else {
333             requiredFields = addRequiredFieldsMessageForInvoiceImport(mandatoryFields);
334             return requiredFields;
335         }
336     }
337 
338     private String addRequiredFieldsMessageForInvoiceImport(List<String> mandatoryFields){
339         StringBuffer fieldsRequired = new StringBuffer();
340         for(int fieldCount = 0; fieldCount < mandatoryFields.size();fieldCount++){
341             if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.LIST_PRICE)){
342                 fieldsRequired.append(OLEConstants.REQUIRED_INVOICED_PRICE);
343             }
344             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.FOREIGN_LIST_PRICE)){
345                 fieldsRequired.append(OLEConstants.REQUIRED_INVOICED_FOREIGN_PRICE);
346             }
347             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.VENDOR_NUMBER)){
348                 fieldsRequired.append(OLEConstants.REQUIRED_VENDOR_NUMBER);
349             }
350             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.QUANTITY)){
351                 fieldsRequired.append(OLEConstants.REQUIRED_QTY);
352             }
353             else if(mandatoryFields.get(fieldCount).equalsIgnoreCase(OLEConstants.OLEBatchProcess.INVOICE_DATE)){
354                 fieldsRequired.append(OLEConstants.REQUIRED_INVOICE_DATE);
355             }
356             if(!(fieldCount  == mandatoryFields.size()-1)){
357                 fieldsRequired.append(", ");
358             }
359         }
360         fieldsRequired.append(mandatoryFields.size() == 1?" is":" are");
361         return fieldsRequired.toString();
362     }
363 
364 }