Module OrderDtl.DD
1//DDB-FileStart
2//DDB-HeaderStart
3
4// File Name : OrderDtl.DD
5// Class Name: OrderDtl_DataDictionary
6// Revision : 5
7// Version : 2
8
9Use Windows // Basic Definitions
10Use DataDict.pkg // DataDictionary Class Definition
11Use DDvalTbl // Validation Table Class Definitions
12
13Open OrderDtl
14Open OrderHea
15Open Invt
16
17//DDB-HeaderEnd
18
19Class OrderDtl_DataDictionary Is A DataDictionary
20
21 Procedure Define_Fields
22 Forward Send Define_Fields
23 //DDB-Generated-Code-Location
24 //DDB-DefineFieldStart
25
26 Set Main_File To OrderDtl.File_Number
27 Set Cascade_Delete_State To False
28
29 Set Foreign_Field_Options DD_KEYFIELD To DD_FINDREQ
30 Set Foreign_Field_Options DD_INDEXFIELD To DD_NOPUT
31 Set Foreign_Field_Options DD_DEFAULT To DD_DISPLAYONLY
32
33 // Parent (Server) file structure...............
34 Send Add_Server_File OrderHea.File_Number
35 Send Add_Server_File Invt.File_Number
36
37 Define_Auto_Increment OrderHea.Last_Detail_Num To OrderDtl.Detail_Number
38
39 // Field-based properties.......................
40
41 // OrderDtl.Order_Number
42 //DDB/ Comment_Short Field OrderDtl.Order_Number To "Relates to OrderHea DD"
43 Set Field_Options Field OrderDtl.Order_Number To DD_NOPUT
44
45 // OrderDtl.Detail_Number
46 //DDB/ Comment_Short Field OrderDtl.Detail_Number To "This is maintained internally and is normally not displayed"
47 Set Field_Options Field OrderDtl.Detail_Number To DD_NOPUT
48
49 // OrderDtl.Item_Id
50 //DDB/ Comment_Short Field OrderDtl.Item_ID To "relates to Invt DD"
51
52 // OrderDtl.Qty_Ordered
53 Set Field_Exit_msg Field OrderDtl.Qty_Ordered To Adjust_Display_Total
54 Set Field_Label_Long Field OrderDtl.Qty_Ordered To "Quantity Ordered"
55 Set Field_Label_Short Field OrderDtl.Qty_Ordered To "Quantity"
56 Set Field_Mask_Type Field OrderDtl.Qty_Ordered To MASK_NUMERIC_WINDOW
57 Set Status_Help Field OrderDtl.Qty_Ordered To "Number of items ordered"
58
59 // OrderDtl.Price
60 //DDB/ Comment_Short Field OrderDtl.Price To "Default is set from Invt. Can be adjusted for each order."
61 Set Field_Entry_msg Field OrderDtl.Price To Entering_Price
62 Set Field_Exit_msg Field OrderDtl.Price To Adjust_Display_Total
63 Set Field_Label_Long Field OrderDtl.Price To "Price per Unit"
64 Set Field_Label_Short Field OrderDtl.Price To "Price"
65 Set Field_Mask_Type Field OrderDtl.Price To MASK_CURRENCY_WINDOW
66 Set Status_Help Field OrderDtl.Price To "Price per Unit"
67
68 // OrderDtl.Extended_Price
69 //DDB/ Comment_Short Field OrderDtl.Extended_Price To "System Maintained: Ext Price = Qty * Price"
70 Set Field_Label_Long Field OrderDtl.Extended_Price To "Extended Price"
71 Set Field_Label_Short Field OrderDtl.Extended_Price To "Total"
72 Set Field_Mask_Type Field OrderDtl.Extended_Price To MASK_CURRENCY_WINDOW
73 Set Field_Options Field OrderDtl.Extended_Price To DD_DISPLAYONLY
74 Set Status_Help Field OrderDtl.Extended_Price To "Total extended price"
75
76 //DDB-DefineFieldEnd
77 End_Procedure // Define_Fields
78
79 // Update and Backout need to adjust the Invt.On_Hand quantity,
80 // the dtl line's extended price and the OrderHea total. We will call
81 // the same procedure (Adjust_Balances) to insure that backout and
82 // update are inverses of each other.
83 // Note that Backout does not need to change the extended_price. This
84 // only gets changed as part of update.
85 Procedure Update
86 Forward Send Update
87 Move (OrderDtl.Price * OrderDtl.Qty_Ordered) To OrderDtl.Extended_Price
88 Send Adjust_Balances OrderDtl.Qty_Ordered OrderDtl.Extended_Price
89 End_Procedure
90
91 Procedure Backout
92 Forward Send Backout
93 Send Adjust_Balances (-OrderDtl.Qty_Ordered) (-OrderDtl.Extended_Price)
94 End_Procedure
95
96 // Called by Backout and Update passing the quantity
97 // and the extended price.
98 // Subtract quantity from Invt on-hand and
99 // add extended amnt to order total.
100 Procedure Adjust_Balances Number Qty Number Amt
101 Subtract Qty From Invt.On_Hand
102 Add Amt To OrderHea.Order_Total
103 End_Procedure
104
105 // when entering the price field we may wish to update the
106 // current field value with the standard unit price from the
107 // Invt file. Only do this if the current amount is zero. If non
108 // zero we assume the field is being edited (and we make no assumptions).
109 Procedure Entering_Price Integer Field# Number nAmnt
110 If (nAmnt=0) Begin
111 Get File_Field_Current_Value File_Field Invt.Unit_Price To nAmnt
112 Set Field_Changed_Value Field# To nAmnt
113 Send Adjust_Display_Total
114 End
115 End_Procedure
116
117 // This updates the extended price field, which will update any
118 // display balances. This is only done for display purposes. The actual
119 // amount is updated to the field during the save.
120 Procedure Adjust_Display_total
121 Integer iQty
122 Number nAmnt
123
124 Get Field_Current_Value Field OrderDtl.Qty_Ordered To iQty
125 Get Field_Current_Value Field OrderDtl.Price To nAmnt
126 Set Field_Current_Value Field OrderDtl.Extended_Price To (nAmnt * iQty)
127 // note we set value, but not changed state!
128 End_Procedure
129
130 // Field_Defaults:
131 // This procedure is used to establish default field values.
132
133 Procedure Field_Defaults
134 Forward Send Field_Defaults
135 //DDB-Generated-Code-Location
136 //DDB-FieldDefaultStart
137 //DDB-FieldDefaultEnd
138 End_Procedure // Field_Defaults
139
140End_Class // OrderDtl_DataDictionary
141//DDB-FileEnd
142