tbcomputerguy Posted February 22, 2012 Posted February 22, 2012 Hi Guys, wondering if you could check over this script. I have an job order i need to converted to an invoice. I can get most of except, these invoices are created by the user selecting which items from the job order to be invoiced. Again no problem. what I am trying to do is warn the user that if they select an item already invoiced, please try again. But I am stuck. The first check is to see if they want to create a second invoice most time they do. ==Create Invoices==: Create Invoices # Allow User Abort[ Off ] Set Error Capture [ On ] # If [ Invoices_From_Jobs::id_joborder ] Show Custom Dialog[ Title: "Transfer Error"; Message: "An INVOICE has already been made for this Job Order. Would you like another INVOICE made?"; Buttons: “Yes”, “Cancel” ] If [ Get ( LastMessageChoice ) = "2" ] Exit Script [ ] End If End If Set Variable [ $id_jo; Value:JobOrders::ID_JOBORDER ] Set Variable [ $flag_line_items; Value:Job_Order_Line_Items::id_constant ] Set Variable [ $jocalc; Value:JobOrders::JobOrderNoCalc ] Set Variable [ $inclinv; Value:"Y" ] # #1.Cust Info Set Variable [ $c_id; Value:JobOrders::id_contact ] # Go to Layout[ “Invoices_From_Jobs” (Invoices_From_Jobs) ] New Record/Request Set Variable [ $id_inv; Value:Invoices_From_Jobs::ID_Invoice ] # #Cust Info - Jobs Set Field[ Invoices_From_Jobs::id_contact; $c_id ] Set Field[ Invoices_From_Jobs::JobOrderNumberCalc ; $jocalc ] #--------------------------------------Transfer Line Items If [ $flag_line_items = 1 ] // New Window [ Name: "Transferring Line Items...Part 2"; Height: 50; Width: 200; Top: 50; Left: 50 ] // New Window [ Name: "Transferring Line Items"; Height: 50; Width: 200; Top: 50; Left: 50 ] Go to Layout[ “Job Order Line Items - Maintenance” (Job_Order_Line_Items) ] Enter Find Mode [ ] Set Field[ Job_Order_Line_Items::id_joborder ; $id_jo ] Set Field[ Job_Order_Line_Items::incl_invoice ; $inclinv ] Perform Find[ ] If [ Get (FoundCount) = 0 ] Exit Script [ ] End If Go to Record/Request/Page [ First] Loop #--------------------------------------Set variables with line item info Set Variable [ $lineid; Value:Job_Order_Line_Items::ID_LineItem ] Set Variable [ $desc; Value:Job_Order_Line_Items::Description ] Set Variable [ $quantity; Value:Job_Order_Line_Items::Quantity ] Set Variable [ $price; Value:Job_Order_Line_Items::UnitPrice] #--------------------------------------Go to invoice line items window February 21, 2012 22:53:44 -1-Estimates 2012v1.1.fp7 - Create Invoices Copy ==Create Invoices==: Create Invoices Copy // Select Window [ Name: "Transferring Line Items...Part 2"; Current file ] Go to Layout[ “Invoice_LineItems_Maint” (Invoice_LineItems) ] New Record/Request Go to Record/Request/Page [ Last ] Set Field[ Invoice_LineItems::id_invoice ; $ID_INV ] Set Field[ Invoice_LineItems::Description ; $desc ] Set Field[ Invoice_LineItems::Quantity; $quantity ] Set Field[ Invoice_LineItems::UnitPrice ; $price ] Set Field[ Invoice_LineItems::joblineitem; $lineid ] #--------------------------------------If lineitem from Jobs exists, notify user If [ Invoice_LineItems::joblineitem ] Show Custom Dialog[ Title: "Invoicing Error!"; Message: "An Invoice with some of the line items you selected have already bee invoiced for. Please verify you selection and try creating another invoice!"; Buttons: “Yes”, “Cancel” ] If [ Get ( LastMessageChoice ) = "2" ] Revert Record/Request [ No dialog ] Go to Layout[ “Job Orders” (JobOrders) ] Exit Script [ ] End If End If // Select Window [ Name: "Transferring Line Items"; Current file ] Go to Layout[ “Job Order Line Items - Maintenance” (Job_Order_Line_Items) ] Go to Record/Request/Page [ Next; Exit after last ] End Loop // Close Window [ Name: "Transferring Line Items...Part 2"; Current file ] // Close Window [ Name: "Transferring Line Items"; Current file ] End If // Select Window [ Current Window ] Go to Layout[ “Invoices_From_Jobs” (Invoices_From_Jobs) ] Commit Records/Requests Adjust Window [ Maximize ] Set Zoom Level [ 150% ]
Recommended Posts
This topic is 4658 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now