You need to sign in to do that
Don't have an account?
Test Case Help reqd pls
Can anyone write me a test case for the follwing prog!!!
Help needed very urgently.
public class opportunityController {
Quotes__c quote;
Opportunity opportunity;
Account account;
Order__c order;
Invoice__c invoice;
public opportunityController(ApexPages.StandardController controller) {
}
public Quotes__c getQuote() {
if(quote == null) quote = new Quotes__c();
return quote;
}
public PageReference saveQuote() {
getQuote();
opportunity = [select id,AccountId from Opportunity where id = :ApexPages.currentPage().getParameters().get('id')];
account = [select Id,Name,BillingStreet,BillingCity,BillingState,BillingPostalCode,BillingCountry,Phone,ShippingStreet,ShippingCity,ShippingState,
ShippingPostalCode,ShippingCountry from Account where id = :Opportunity.AccountId ];
quote.opportunity__c = opportunity.id;
quote.quoteDate__c = date.today();
quote.validUntil__c = date.Today() + 15;
quote.billingCustomer__c = account.Name;
quote.shipTo__c = account.Name;
quote.billingStreet__c = account.BillingStreet;
quote.billingCity__c = account.BillingCity;
quote.billingState__c = account.BillingState;
quote.billingCountry__c = account.BillingCountry;
quote.billingPostalCode__c = account.BillingPostalcode;
quote.billingPhone__c = account.Phone;
quote.shippingStreet__c = account.ShippingStreet;
quote.shippingCity__c = account.ShippingCity;
quote.shippingState__c = account.ShippingState;
quote.shippingCountry__c = account.ShippingCountry;
quote.shippingPostalCode__c = account.ShippingPostalcode;
quote.shippingPhone__c = account.Phone;
insert quote;
OpportunityLineItem[] OLI = [SELECT Quantity, ListPrice,PricebookEntry.UnitPrice, PricebookEntry.Name,PricebookEntry.Product2.Name
From OpportunityLineItem where OpportunityId = :ApexPages.currentPage().getParameters().get('id') ];
Quote_line_Items__c[] QLT = new Quote_line_Items__c[]{};
Quote_line_Items__c items = new Quote_line_Items__c();
for(OpportunityLineItem ol: OLI){
items = new Quote_line_Items__c();
items.Quote__c = quote.id;
items.Quantity__c = ol.Quantity;
items.Product__c = ol.PricebookEntry.Product2.Id;
items.Unit_Price__c = ol.PricebookEntry.UnitPrice;
items.Total_Price__c = items.Unit_Price__c * items.Quantity__c;
QLT.add(items);
}
insert QLT;
PageReference quotePage = new ApexPages.StandardController(quote).view();
quotePage.setRedirect(true);
return quotePage;
}
}
Man i got it..
I have written the exact test case. Tutorials really help you.
Thanks god... finally...
Ah and yeah... anyone wants to learn, follow the link
http://wiki.developerforce.com/page/Visualforce_Quote2PDF