// Class Name: Orderdtl_DataDictionary // Revision : 7 // Version : 2 Use Windows // Basic Definitions Use DataDict.pkg // DataDictionary Class Definition Use DDvalTbl // Validation Table Class Definitions Open Orderdtl Open Orderhea Open Invt Class Orderdtl_DataDictionary is a DataDictionary Procedure Construct_Object Forward Send Construct_Object Set Main_File To Orderdtl.File_Number Set Cascade_Delete_State To FALSE Set Foreign_Field_Option DD_KEYFIELD DD_FINDREQ to True Set Foreign_Field_Option DD_INDEXFIELD DD_NOPUT to True Set Foreign_Field_Option DD_DEFAULT DD_DISPLAYONLY to True // Parent (Server) file structure............... Set Add_Server_File to Orderhea.File_Number Set Add_Server_File to Invt.File_Number Set Field_Auto_Increment Field Orderdtl.Detail_Number to File_Field Orderhea.Last_Detail_Num // Field-based properties....................... // Field Orderdtl.Order_Number To "Relates to OrderHea DD" Set Field_Option Field Orderdtl.Order_Number DD_NOPUT to True // Field Orderdtl.Detail_Number To "This is maintained internally and is normally not displayed" Set Field_Option Field Orderdtl.Detail_Number DD_NOPUT to True // Field Orderdtl.Item_Id To "relates to Invt DD" Set Field_Exit_msg Field Orderdtl.Qty_Ordered To Adjust_Display_Total Set Field_Label_Long Field Orderdtl.Qty_Ordered To "Quantity Ordered" Set Field_Label_Short Field Orderdtl.Qty_Ordered To "Quantity" Set Field_Mask_Type Field Orderdtl.Qty_Ordered To MASK_NUMERIC_WINDOW Set Status_Help Field Orderdtl.Qty_Ordered To "Number of items ordered" // Field Orderdtl.Price To "Default is set from Invt. Can be adjusted for each order." Set Field_Entry_msg Field Orderdtl.Price To Entering_Price Set Field_Exit_msg Field Orderdtl.Price To Adjust_Display_Total Set Field_Label_Long Field Orderdtl.Price To "Price per Unit" Set Field_Label_Short Field Orderdtl.Price To "Price" Set Field_Mask_Type Field Orderdtl.Price To MASK_CURRENCY_WINDOW Set Status_Help Field Orderdtl.Price To "Price per Unit" // Field Orderdtl.Extended_Price To "system maintained: Ext Price = Qty * Price" Set Field_Label_Long Field Orderdtl.Extended_Price To "Extended Price" Set Field_Label_Short Field Orderdtl.Extended_Price To "Total" Set Field_Mask_Type Field Orderdtl.Extended_Price To MASK_CURRENCY_WINDOW Set Field_Option Field Orderdtl.Extended_Price DD_DISPLAYONLY to True Set Status_Help Field Orderdtl.Extended_Price To "Total extended price" End_Procedure // Construct_Object // Update and Backout need to adjust the Invt.On_Hand quantity, // the dtl line's extended price and the OrderHea total. We will call // the same procedure (Adjust_Balances) to insure that backout and // update are inverses of each other. // Note that Backout does not need to change the extended_price. This // only gets changed as part of update. Procedure Update Forward Send Update Move (OrderDtl.Price * OrderDtl.Qty_Ordered) to OrderDtl.Extended_Price Send Adjust_Balances OrderDtl.Qty_Ordered OrderDtl.Extended_Price End_Procedure Procedure Backout Forward Send Backout Send Adjust_Balances (-OrderDtl.Qty_Ordered) (-OrderDtl.Extended_Price) End_Procedure // Called by Backout and Update passing the quantity // and the extended price. // Subtract quantity from Invt on-hand and // add extended amnt to order total. Procedure Adjust_Balances Number nQty Number nAmt Subtract nQty from Invt.On_Hand Add nAmt to Orderhea.Order_Total End_Procedure // when entering the price field we may wish to update the // current field value with the standard unit price from the // Invt file. Only do this if the current amount is zero. If non // zero we assume the field is being edited (and we make no assumptions). Procedure Entering_Price integer iField# Number nAmnt If (nAmnt=0) Begin Get File_Field_Current_Value File_Field Invt.Unit_Price to nAmnt Set Field_Changed_Value iField# to nAmnt Send Adjust_Display_Total End End_procedure // This updates the extended price field, which will update any // display balances. This is only done for display purposes. The actual // amount is updated to the field during the save. Procedure Adjust_Display_Total Integer iQty Number nAmnt Get Field_Current_Value Field Orderdtl.Qty_Ordered to iQty Get Field_Current_Value Field Orderdtl.Price to nAmnt Set Field_Current_Value Field Orderdtl.Extended_Price to (nAmnt * iQty) // note we set value, but not changed state! End_Procedure // Field_Defaults: // This procedure is used to establish default field values. Procedure Field_Defaults Forward Send Field_Defaults End_Procedure // Field_Defaults End_Class // Orderdtl_DataDictionary