You need to sign in to do that
Don't have an account?
Amit Jadhav 13
SObject row was retrieved via SOQL without querying the requested field: Order.Supplier_Order__c
Controller:
public with sharing class costsheet {
public String OrderId;
public Order ord;
public costsheet(ApexPages.StandardController controller) {
listIex =0.0;
CFSList =0.0;
CHAList =0.0;
CHAListS =0.0;
ord= (Order)Controller.getRecord();
OrderId=Apexpages.currentpage().getParameters().get('id');
system.debug('listStemer>>'+OrderId);
listStemer=[Select Id,subtotal__c,Supplier_Order__c from Shipper_Info_India__c where Supplier_Order__c =:ord.id AND RecordType.Name='Steamer Charges' limit 1] ;
system.debug('listStemer>>'+listStemer);
if(listStemer.size()>0)
{
listIex =listStemer[0].subtotal__c;
system.debug('listStemer>>'+listIex );
}
listCHAChargesR=[Select Id,subtotal__c,Supplier_Order__c from Shipper_Info_India__c where Supplier_Order__r.id =:ord.id AND RecordType.Name='CHA Charges' AND Bill_Type__c = 'Reimbursement Type'] ;
if(listCHAChargesR.size()>0)
{
CHAList =listCHAChargesR[0].subtotal__c;
}
listCHAChargesS=[Select Id,subtotal__c,Supplier_Order__c from Shipper_Info_India__c where Supplier_Order__r.id =:ord.id AND RecordType.Name='CHA Charges' AND Bill_Type__c = 'Service Type'] ;
if(listCHAChargesS.size()>0)
{
CHAListS =listCHAChargesS[0].subtotal__c;
}
listCFSCharges=[Select Id,subtotal__c,Supplier_Order__c from Shipper_Info_India__c where Supplier_Order__r.id =:ord.id AND RecordType.Name='CFS Charges' limit 1] ;
if(listCFSCharges.size()>0)
{
CFSList =(listCFSCharges[0].subtotal__c).setScale(2);
}
Calculation();
}
public List<Shipper_Info_India__c > listStemer;
public List<Shipper_Info_India__c > listCFSCharges;
public List<Shipper_Info_India__c > listCHAChargesR;
public List<Shipper_Info_India__c > listCHAChargesS;
public Decimal CFSList {get;set;}
public Decimal CHAList {get;set;}
Public Decimal listIex {get;set;}
public Decimal CHAListS {get;set;}
public List<Order> ordList = new List<Order>();
public Decimal TotalAmount_3{get;set;}
public Decimal TotalFreightAmount_19{get;set;}
public Decimal TotalFreightAmount_21{get;set;}
public Decimal TotalFreightAmount_c21{get;set;}
public Decimal TotalFreightAmount_d21{get;set;}
public Decimal BasicDuty_c23{get;set;}
public Decimal BasicDuty_d23{get;set;}
public Decimal Cess_c24{get;set;}
public Decimal Cess_d24{get;set;}
public Decimal TotalCustomDuty_g25{get;set;}
public Decimal TotalCustomDuty_c25{get;set;}
public Decimal TotalCustomDuty_d25{get;set;}
public Decimal ShippingLine_c27 {get;set;}
public Decimal ShippingLine_d27 {get;set;}
public Decimal StorageCFS_c32 {get;set;}
public Decimal StorageCFS_d32 {get;set;}
public Decimal Others_c30 {get;set;}
public Decimal Others_d30 {get;set;}
public Decimal Clearing_c31 {get;set;}
public Decimal Clearing_d31 {get;set;}
public Decimal TotalC {get;set;}
public Decimal TotalCost{get;set;}
public decimal TotalC_c37 {get;set;}
public decimal TotalC_d37 {get;set;}
public decimal TotalCost_c38 {get;set;}
public decimal TotalCost_d38 {get;set;}
public void Calculation(){
TotalAmount_3 = 0;
TotalFreightAmount_19= 0;
if(ord.Quantity__c != NULL && ord.Unit_Price__c != null){
TotalAmount_3 = (ord.Unit_Price__c *ord.Quantity__c).setScale(2);
}else{
TotalAmount_3=0;
}
if(ord.Total_Insurance__c != null){
// Need to update this with adding Freight charges
TotalFreightAmount_19= (ord.Total_Insurance__c+ord.Total_Sea_Freight_Charges__c+TotalAmount_3).setscale(2) ;
}else{
TotalFreightAmount_19=0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
TotalFreightAmount_21 = (TotalFreightAmount_19*ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
}else{
TotalFreightAmount_21=(0+TotalFreightAmount_19).setscale(2);
}
if(TotalFreightAmount_19 != 0)
{
TotalFreightAmount_c21 = (TotalFreightAmount_21/ord.Quantity__c/1000).setscale(2);
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
TotalFreightAmount_d21 = (TotalFreightAmount_c21*1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
}else{
TotalFreightAmount_d21=0;
}
if(ord.Basic_Customs_Duty_value__c != null)
{
BasicDuty_c23 = (ord.Basic_Customs_Duty_value__c/ord.Quantity__c/1000).setscale(2);
}else{
BasicDuty_c23=0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
BasicDuty_d23 = (BasicDuty_c23*1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
}else{
BasicDuty_d23=0;
}
if(ord.Social_Welfare_Surcharge__c != null)
{
Cess_c24 = (ord.Social_Welfare_Surcharge__c/ord.Quantity__c/1000).setscale(2);
}else{
Cess_c24=0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
Cess_d24 = (Cess_c24*1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
}else{
Cess_d24=0;
}
if(ord.Basic_Customs_Duty_value__c != null && ord.Social_Welfare_Surcharge__c != null)
{
TotalCustomDuty_g25=(ord.Basic_Customs_Duty_value__c+ord.Social_Welfare_Surcharge__c).setscale(2);
}else{
TotalCustomDuty_g25=0;
}
if(TotalCustomDuty_g25 != 0)
{
TotalCustomDuty_c25 = (TotalCustomDuty_g25/ord.Quantity__c/1000).setscale(2);
}else{
TotalCustomDuty_c25 =0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
TotalCustomDuty_d25 = (TotalCustomDuty_c25*1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
} else{
TotalCustomDuty_d25 =0;
}
if(listIex != null)
{
ShippingLine_c27 = (listIex/ord.Quantity__c/1000).setscale(2);
}else{
ShippingLine_c27 =0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
ShippingLine_d27 = (ShippingLine_c27*1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
} else{
ShippingLine_d27 =0;
}
if(CFSList != null)
{
StorageCFS_c32 = (CFSList/ord.Quantity__c/1000).setscale(2);
}else{
StorageCFS_c32 =0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
StorageCFS_d32 = (StorageCFS_c32*1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
} else{
StorageCFS_d32 =0;
}
if(CHAList != null)
{
Others_c30 = (CHAList/ord.Quantity__c/1000).setscale(2);
}else{
Others_c30 =0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
Others_d30 = (Others_c30 *1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
} else{
Others_d30 =0;
}
if(CHALists != null)
{
Clearing_c31 = (CHALists/ord.Quantity__c/1000).setscale(2);
}else{
Clearing_c31 =0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
Clearing_d31 = (Clearing_c31 *1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
} else{
Clearing_c31 =0;
}
TotalC = (listIex+CHAList+CHAListS+CFSList).setscale(2);
TotalCost = (TotalC+TotalFreightAmount_21+TotalCustomDuty_g25).setscale(2);
if(TotalC != null)
{
TotalC_c37= (TotalC/ord.Quantity__c/1000).setscale(2);
}else{
TotalC_c37=0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
TotalC_d37= (TotalC_c37*1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
} else{
TotalC_d37=0;
}
if(TotalCost != null)
{
TotalCost_c38= (TotalCost/ord.Quantity__c/1000).setscale(2);
}else{
TotalCost_c38=0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
TotalCost_d38= (TotalCost_c38*1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
} else{
TotalCost_d38=0;
}
}
//Method to Save Attachments
public PageReference SaveAttachmentpdf() {
system.debug('In save');
blob pdfBody;
PageReference thePDF = new PageReference('/apex/costsheetpdf?id='+OrderId);
system.debug('ORD--'+OrderId);
thePDF.setRedirect(true);
if(Test.isRunningTest()) {
pdfBody = blob.valueOf('Unit.Test');
} else {
pdfBody = thePDF.getContentAsPDF();
}
Attachment attach = new Attachment();
attach.body = pdfBody;
attach.Name='CostSheetPdf '+System.Now();
system.debug('OrderId'+OrderId);
attach.ParentId=OrderId;
attach.ContentType = 'application/pdf';
Insert attach;
if (attach == null){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Error will Saving a file .Please check the content of the file'));
}
if (attach != null){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Quote Pdf generated successfully'));
}
PageReference qtpage = new PageReference('/'+OrderId);
qtpage.setRedirect(true);
return thePDF;
}
public with sharing class costsheet {
public String OrderId;
public Order ord;
public costsheet(ApexPages.StandardController controller) {
listIex =0.0;
CFSList =0.0;
CHAList =0.0;
CHAListS =0.0;
ord= (Order)Controller.getRecord();
OrderId=Apexpages.currentpage().getParameters().get('id');
system.debug('listStemer>>'+OrderId);
listStemer=[Select Id,subtotal__c,Supplier_Order__c from Shipper_Info_India__c where Supplier_Order__c =:ord.id AND RecordType.Name='Steamer Charges' limit 1] ;
system.debug('listStemer>>'+listStemer);
if(listStemer.size()>0)
{
listIex =listStemer[0].subtotal__c;
system.debug('listStemer>>'+listIex );
}
listCHAChargesR=[Select Id,subtotal__c,Supplier_Order__c from Shipper_Info_India__c where Supplier_Order__r.id =:ord.id AND RecordType.Name='CHA Charges' AND Bill_Type__c = 'Reimbursement Type'] ;
if(listCHAChargesR.size()>0)
{
CHAList =listCHAChargesR[0].subtotal__c;
}
listCHAChargesS=[Select Id,subtotal__c,Supplier_Order__c from Shipper_Info_India__c where Supplier_Order__r.id =:ord.id AND RecordType.Name='CHA Charges' AND Bill_Type__c = 'Service Type'] ;
if(listCHAChargesS.size()>0)
{
CHAListS =listCHAChargesS[0].subtotal__c;
}
listCFSCharges=[Select Id,subtotal__c,Supplier_Order__c from Shipper_Info_India__c where Supplier_Order__r.id =:ord.id AND RecordType.Name='CFS Charges' limit 1] ;
if(listCFSCharges.size()>0)
{
CFSList =(listCFSCharges[0].subtotal__c).setScale(2);
}
Calculation();
}
public List<Shipper_Info_India__c > listStemer;
public List<Shipper_Info_India__c > listCFSCharges;
public List<Shipper_Info_India__c > listCHAChargesR;
public List<Shipper_Info_India__c > listCHAChargesS;
public Decimal CFSList {get;set;}
public Decimal CHAList {get;set;}
Public Decimal listIex {get;set;}
public Decimal CHAListS {get;set;}
public List<Order> ordList = new List<Order>();
public Decimal TotalAmount_3{get;set;}
public Decimal TotalFreightAmount_19{get;set;}
public Decimal TotalFreightAmount_21{get;set;}
public Decimal TotalFreightAmount_c21{get;set;}
public Decimal TotalFreightAmount_d21{get;set;}
public Decimal BasicDuty_c23{get;set;}
public Decimal BasicDuty_d23{get;set;}
public Decimal Cess_c24{get;set;}
public Decimal Cess_d24{get;set;}
public Decimal TotalCustomDuty_g25{get;set;}
public Decimal TotalCustomDuty_c25{get;set;}
public Decimal TotalCustomDuty_d25{get;set;}
public Decimal ShippingLine_c27 {get;set;}
public Decimal ShippingLine_d27 {get;set;}
public Decimal StorageCFS_c32 {get;set;}
public Decimal StorageCFS_d32 {get;set;}
public Decimal Others_c30 {get;set;}
public Decimal Others_d30 {get;set;}
public Decimal Clearing_c31 {get;set;}
public Decimal Clearing_d31 {get;set;}
public Decimal TotalC {get;set;}
public Decimal TotalCost{get;set;}
public decimal TotalC_c37 {get;set;}
public decimal TotalC_d37 {get;set;}
public decimal TotalCost_c38 {get;set;}
public decimal TotalCost_d38 {get;set;}
public void Calculation(){
TotalAmount_3 = 0;
TotalFreightAmount_19= 0;
if(ord.Quantity__c != NULL && ord.Unit_Price__c != null){
TotalAmount_3 = (ord.Unit_Price__c *ord.Quantity__c).setScale(2);
}else{
TotalAmount_3=0;
}
if(ord.Total_Insurance__c != null){
// Need to update this with adding Freight charges
TotalFreightAmount_19= (ord.Total_Insurance__c+ord.Total_Sea_Freight_Charges__c+TotalAmount_3).setscale(2) ;
}else{
TotalFreightAmount_19=0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
TotalFreightAmount_21 = (TotalFreightAmount_19*ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
}else{
TotalFreightAmount_21=(0+TotalFreightAmount_19).setscale(2);
}
if(TotalFreightAmount_19 != 0)
{
TotalFreightAmount_c21 = (TotalFreightAmount_21/ord.Quantity__c/1000).setscale(2);
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
TotalFreightAmount_d21 = (TotalFreightAmount_c21*1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
}else{
TotalFreightAmount_d21=0;
}
if(ord.Basic_Customs_Duty_value__c != null)
{
BasicDuty_c23 = (ord.Basic_Customs_Duty_value__c/ord.Quantity__c/1000).setscale(2);
}else{
BasicDuty_c23=0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
BasicDuty_d23 = (BasicDuty_c23*1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
}else{
BasicDuty_d23=0;
}
if(ord.Social_Welfare_Surcharge__c != null)
{
Cess_c24 = (ord.Social_Welfare_Surcharge__c/ord.Quantity__c/1000).setscale(2);
}else{
Cess_c24=0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
Cess_d24 = (Cess_c24*1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
}else{
Cess_d24=0;
}
if(ord.Basic_Customs_Duty_value__c != null && ord.Social_Welfare_Surcharge__c != null)
{
TotalCustomDuty_g25=(ord.Basic_Customs_Duty_value__c+ord.Social_Welfare_Surcharge__c).setscale(2);
}else{
TotalCustomDuty_g25=0;
}
if(TotalCustomDuty_g25 != 0)
{
TotalCustomDuty_c25 = (TotalCustomDuty_g25/ord.Quantity__c/1000).setscale(2);
}else{
TotalCustomDuty_c25 =0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
TotalCustomDuty_d25 = (TotalCustomDuty_c25*1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
} else{
TotalCustomDuty_d25 =0;
}
if(listIex != null)
{
ShippingLine_c27 = (listIex/ord.Quantity__c/1000).setscale(2);
}else{
ShippingLine_c27 =0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
ShippingLine_d27 = (ShippingLine_c27*1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
} else{
ShippingLine_d27 =0;
}
if(CFSList != null)
{
StorageCFS_c32 = (CFSList/ord.Quantity__c/1000).setscale(2);
}else{
StorageCFS_c32 =0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
StorageCFS_d32 = (StorageCFS_c32*1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
} else{
StorageCFS_d32 =0;
}
if(CHAList != null)
{
Others_c30 = (CHAList/ord.Quantity__c/1000).setscale(2);
}else{
Others_c30 =0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
Others_d30 = (Others_c30 *1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
} else{
Others_d30 =0;
}
if(CHALists != null)
{
Clearing_c31 = (CHALists/ord.Quantity__c/1000).setscale(2);
}else{
Clearing_c31 =0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
Clearing_d31 = (Clearing_c31 *1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
} else{
Clearing_c31 =0;
}
TotalC = (listIex+CHAList+CHAListS+CFSList).setscale(2);
TotalCost = (TotalC+TotalFreightAmount_21+TotalCustomDuty_g25).setscale(2);
if(TotalC != null)
{
TotalC_c37= (TotalC/ord.Quantity__c/1000).setscale(2);
}else{
TotalC_c37=0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
TotalC_d37= (TotalC_c37*1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
} else{
TotalC_d37=0;
}
if(TotalCost != null)
{
TotalCost_c38= (TotalCost/ord.Quantity__c/1000).setscale(2);
}else{
TotalCost_c38=0;
}
if(ord.Exchange_Rate_PO_Currency_to_INR__c != null)
{
TotalCost_d38= (TotalCost_c38*1000/ord.Exchange_Rate_PO_Currency_to_INR__c).setscale(2);
} else{
TotalCost_d38=0;
}
}
//Method to Save Attachments
public PageReference SaveAttachmentpdf() {
system.debug('In save');
blob pdfBody;
PageReference thePDF = new PageReference('/apex/costsheetpdf?id='+OrderId);
system.debug('ORD--'+OrderId);
thePDF.setRedirect(true);
if(Test.isRunningTest()) {
pdfBody = blob.valueOf('Unit.Test');
} else {
pdfBody = thePDF.getContentAsPDF();
}
Attachment attach = new Attachment();
attach.body = pdfBody;
attach.Name='CostSheetPdf '+System.Now();
system.debug('OrderId'+OrderId);
attach.ParentId=OrderId;
attach.ContentType = 'application/pdf';
Insert attach;
if (attach == null){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Error will Saving a file .Please check the content of the file'));
}
if (attach != null){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Quote Pdf generated successfully'));
}
PageReference qtpage = new PageReference('/'+OrderId);
qtpage.setRedirect(true);
return thePDF;
}
thanks in advance
Amit Jadhav
Can you be more explicit regarding which one do you want me to explain so that I can do that with an example.
Thanks,
Anant