if(input.Dispatch_Type == "Plan")
{
input.Plan_Date_Time = zoho.currenttime;
fetso = Sales_Order[ID == input.Sales_Order_ID];
invmain = Invoice[ID == input.Invoice_ID];
invsub = Invoice_Subform[Invoice_Exist_ID == invmain.ID];
if(input.Sales_Type == "Direct Order" || input.Sales_Type == "Tooling")
{
if(fetso.CWPL_SO_Status == "Active")
{
fetso.CWPL_SO_Status="Dispatch Note Partial";
}
}
var = True;
polist = List();
for each rec in input.Product_Details
{
invsub.Dispatch_Plan_Date_time=rec.Disp_Plan_Date_Time;
fetsosub = Sale_Order_Subform[Sales_Order_Exis_ID == fetso.ID && Part_No == rec.Product_Code];
polist.add(rec.Product_Code);
fetsosub.Planned_Qty_So_far=ifNull(rec.Plan_Qty_so_far,0) + ifNull(rec.Planned_Qty,0);
rec.Balance_Qty=ifNull(rec.Planned_Qty,0);
bal = ifnull(fetsosub.Balance_Qty,0.0) - ifnull(rec.Planned_Qty,0.0);
if(bal > 0)
{
var = False;
}
if(bal < 0)
{
fetsosub.Balance_Qty=0;
}
}
for each sorec in Sale_Order_Subform[Sales_Order_Exis_ID == fetso.ID && Part_No not in polist]
{
sobal = ifnull(sorec.Balance_Qty,0.0) - ifnull(sorec.Planned_Qty_So_far,0.0);
if(sobal > 0)
{
var = false;
}
if(sobal < 0)
{
sorec.Balance_Qty=0;
}
}
fetso.DP_Status=var;
if(fetso.DP_Status == True && fetso.CWPL_SO_Status == "Active" || fetso.CWPL_SO_Status == "Dispatch Note Partial")
{
fetso.CWPL_SO_Status="Dispatch Note Plan Completed";
}
input.Disptach_Status = "Plan Closed";
fetci = Check_Inventory[ID == input.Check_Inventory_ID];
if(fetci.count() > 0)
{
fetci.Create_Dispatch_Note_RECID=input.ID;
fetci.Status="Closed";
}
so = Sales_Order[ID == input.Sales_Order_ID];
if(so.count() > 0)
{
getsosub = Sale_Order_Subform[Sales_Order_Exis_ID == so.ID];
if(getsosub.count() > 0)
{
getsosub.Create_Dispatch_Note_Plan_ID=input.ID;
so.Create_Dispatch_Note_REC_ID=input.ID;
}
}
}
getmodule = Module_Master[Module_Name == "Dispatch Note"];
getauto = Auto_Generate_Numbers[Module_Name == getmodule.ID];
input.CDNF_ID = getauto.Module_Short_Name + "-" + getauto.Prefix + "-" + input.Auto_Number;
openUrl("#Form:Alert_Messages?Status=" + "DN1" + "&Value=" + input.CDNF_ID + "&zc_LoadIn=dialog","same window");
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter