You need to sign in to do that
Don't have an account?
Jasril Dane Caliwag
hi all, Can anyone help me in writting the test class for the below class.
public class AddPriceModalController {
@AuraEnabled
public static List<String> getRegionValues() {
List<String> lstGeography = new List<String>(); //new list for holding all of the picklist options
Schema.DescribeFieldResult fieldResult = PriceDetail__c.Geography__c.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry f : ple)
{
lstGeography.add(f.getValue());
}
return lstGeography;
}
@AuraEnabled
public static List<String> getDeliveryMethodValues() {
List<String> lstSourceOfSupply = new List<String>(); //new list for holding all of the picklist options
Schema.DescribeFieldResult fieldResult = PriceDetail__c.Source_of_Supply__c.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry f : ple)
{
lstSourceOfSupply.add(f.getLabel() + '---' + f.getValue());
}
return lstSourceOfSupply;
}
//Method to Save the Price Detail Change Request
@AuraEnabled
public static String savePriceDetails(Id PDID,PriceDetail__c newPriceDetails) {
system.debug('savePriceDetails');
system.debug('newPriceDetails'+newPriceDetails);
Decimal invoiceCost = 0;
Decimal netCost = 0;
Decimal netProfit = 0;
Decimal retailPrice = 0;
string resultId;
//Webservice Call to SAP to get the InvoiceCost and NetCost
/*invoiceCost = PriceDetailsWebService.getInvoiceCost(PDID);
netCost = PriceDetailsWebService.getNetCost(PDID);*/
String PDSOQL = SObjectUtil.getSOQLStringFullFields(PriceDetail__c.getSObjectType())
+' WHERE ' + ' Id = :PDID LIMIT 1';
//List<PriceDetail__c> listPD = Database.query(PDSOQL);
PriceDetail__c PDRec;
try{
PDRec = Database.query(PDSOQL);
}catch(Exception e){
ApplicationLogUtility.logError('SubmitActionController', 'getParentId', e, e.getMessage(), '', 0);
ApplicationLogUtility.commitLog();
PDRec = null;
}
if(PDRec!=null){
PriceDetail__c clonedPD = PDRec.clone(false, true, false, false);
clonedPD.InvoiceCost__c = invoiceCost;
clonedPD.NetCost__c = netCost;
clonedPD.ClonedFrom__c = PDRec.Id;
clonedPD.Status__c = Label.Draft;
clonedPD.RecordTypeId = Schema.SObjectType.PriceDetail__c.getRecordTypeInfosByName().get(Label.PriceDetail_Submit).getRecordTypeId();
Schema.DescribeSObjectResult objResult = PriceDetail__c.sObjectType.getDescribe();
for(string apiName : objResult.fields.getMap().keySet()){
String feildName = apiName;
if(feildName.endsWith('__c')){
if((clonedPD.get(apiName) != newPriceDetails.get(apiName)) && (feildName!= 'ClonedFrom__c')){
system.debug('feildName***'+feildName);
clonedPD.put(apiName, newPriceDetails.get(apiName));
}
}
}
system.debug('clonedPD**'+clonedPD);
if(clonedPD!=null){
insert clonedPD;
}
resultId = Id.valueOf(clonedPD.Id);
system.debug('resultId'+resultId);
}
return resultId;
}
//Method to get the exsisting data from the record
@AuraEnabled
public static PriceDetail__c getPriceDetails(Id recordId) {
system.debug('recordId**'+recordId);
PriceDetail__c pdRecord = (PriceDetail__c) SObjectUtil.getFullSObject(PriceDetail__c.getSObjectType(), recordId);
return pdRecord;
}
}
@AuraEnabled
public static List<String> getRegionValues() {
List<String> lstGeography = new List<String>(); //new list for holding all of the picklist options
Schema.DescribeFieldResult fieldResult = PriceDetail__c.Geography__c.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry f : ple)
{
lstGeography.add(f.getValue());
}
return lstGeography;
}
@AuraEnabled
public static List<String> getDeliveryMethodValues() {
List<String> lstSourceOfSupply = new List<String>(); //new list for holding all of the picklist options
Schema.DescribeFieldResult fieldResult = PriceDetail__c.Source_of_Supply__c.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry f : ple)
{
lstSourceOfSupply.add(f.getLabel() + '---' + f.getValue());
}
return lstSourceOfSupply;
}
//Method to Save the Price Detail Change Request
@AuraEnabled
public static String savePriceDetails(Id PDID,PriceDetail__c newPriceDetails) {
system.debug('savePriceDetails');
system.debug('newPriceDetails'+newPriceDetails);
Decimal invoiceCost = 0;
Decimal netCost = 0;
Decimal netProfit = 0;
Decimal retailPrice = 0;
string resultId;
//Webservice Call to SAP to get the InvoiceCost and NetCost
/*invoiceCost = PriceDetailsWebService.getInvoiceCost(PDID);
netCost = PriceDetailsWebService.getNetCost(PDID);*/
String PDSOQL = SObjectUtil.getSOQLStringFullFields(PriceDetail__c.getSObjectType())
+' WHERE ' + ' Id = :PDID LIMIT 1';
//List<PriceDetail__c> listPD = Database.query(PDSOQL);
PriceDetail__c PDRec;
try{
PDRec = Database.query(PDSOQL);
}catch(Exception e){
ApplicationLogUtility.logError('SubmitActionController', 'getParentId', e, e.getMessage(), '', 0);
ApplicationLogUtility.commitLog();
PDRec = null;
}
if(PDRec!=null){
PriceDetail__c clonedPD = PDRec.clone(false, true, false, false);
clonedPD.InvoiceCost__c = invoiceCost;
clonedPD.NetCost__c = netCost;
clonedPD.ClonedFrom__c = PDRec.Id;
clonedPD.Status__c = Label.Draft;
clonedPD.RecordTypeId = Schema.SObjectType.PriceDetail__c.getRecordTypeInfosByName().get(Label.PriceDetail_Submit).getRecordTypeId();
Schema.DescribeSObjectResult objResult = PriceDetail__c.sObjectType.getDescribe();
for(string apiName : objResult.fields.getMap().keySet()){
String feildName = apiName;
if(feildName.endsWith('__c')){
if((clonedPD.get(apiName) != newPriceDetails.get(apiName)) && (feildName!= 'ClonedFrom__c')){
system.debug('feildName***'+feildName);
clonedPD.put(apiName, newPriceDetails.get(apiName));
}
}
}
system.debug('clonedPD**'+clonedPD);
if(clonedPD!=null){
insert clonedPD;
}
resultId = Id.valueOf(clonedPD.Id);
system.debug('resultId'+resultId);
}
return resultId;
}
//Method to get the exsisting data from the record
@AuraEnabled
public static PriceDetail__c getPriceDetails(Id recordId) {
system.debug('recordId**'+recordId);
PriceDetail__c pdRecord = (PriceDetail__c) SObjectUtil.getFullSObject(PriceDetail__c.getSObjectType(), recordId);
return pdRecord;
}
}
line 6, (Variable does not exist: PDRec)
line 17, (Comparison arguments must be compatible types: Integer, List<String>)
and line 21, (Comparison arguments must be compatible types: Integer, List<String>)