Module OrderDtl.dd
1Use Windows.pkg // Basic Definitions
2Use DataDict.pkg // DataDictionary Class Definition
3Use DDvalTbl.pkg // Validation Table Class Definitions
4
5Open OrderDtl
6Open OrderHea
7Open Invt
8
9
10Class OrderDtl_DataDictionary Is A DataDictionary
11
12 Procedure Construct_Object
13 Forward Send Construct_Object
14
15 Set Main_File To OrderDtl.File_Number
16 Set Cascade_Delete_State To False
17
18 Set Foreign_Field_Option DD_KEYFIELD DD_FINDREQ to True
19 Set Foreign_Field_Option DD_INDEXFIELD DD_NOPUT to True
20 Set Foreign_Field_Option DD_DEFAULT DD_DISPLAYONLY to True
21
22 Set Add_Server_File to OrderHea.File_Number
23 Set Add_Server_File to Invt.File_Number
24
25 Set Field_Auto_Increment Field OrderDtl.Detail_Number to File_Field OrderHea.Last_Detail_Num
26
27
28 Set Field_Option Field OrderDtl.Order_Number DD_NOPUT to True
29
30 Set Field_Option Field OrderDtl.Detail_Number DD_NOPUT to True
31
32
33 Set Field_Exit_msg Field OrderDtl.Qty_Ordered To Adjust_Display_Total
34 Set Field_Label_Long Field OrderDtl.Qty_Ordered To "Quantity Ordered"
35 Set Field_Label_Short Field OrderDtl.Qty_Ordered To "Quantity"
36 Set Field_Mask_Type Field OrderDtl.Qty_Ordered To MASK_NUMERIC_WINDOW
37 Set Status_Help Field OrderDtl.Qty_Ordered To "Number of items ordered"
38
39 Set Field_Entry_msg Field OrderDtl.Price To Entering_Price
40 Set Field_Exit_msg Field OrderDtl.Price To Adjust_Display_Total
41 Set Field_Label_Long Field OrderDtl.Price To "Price per Unit"
42 Set Field_Label_Short Field OrderDtl.Price To "Price"
43 Set Field_Mask_Type Field OrderDtl.Price To MASK_CURRENCY_WINDOW
44 Set Status_Help Field OrderDtl.Price To "Price per Unit"
45
46 Set Field_Label_Long Field OrderDtl.Extended_Price To "Extended Price"
47 Set Field_Label_Short Field OrderDtl.Extended_Price To "Total"
48 Set Field_Mask_Type Field OrderDtl.Extended_Price To MASK_CURRENCY_WINDOW
49 Set Field_Option Field OrderDtl.Extended_Price DD_DISPLAYONLY to True
50 Set Status_Help Field OrderDtl.Extended_Price To "Total extended price"
51
52 End_Procedure // Construct_Object
53
54 // Update and Backout need to adjust the Invt.On_Hand quantity,
55 // the dtl line's extended price and the OrderHea total. We will call
56 // the same procedure (Adjust_Balances) to insure that backout and
57 // update are inverses of each other.
58 // Note that Backout does not need to change the extended_price. This
59 // only gets changed as part of update.
60 Procedure Update
61 Forward Send Update
62 Move (OrderDtl.Price * OrderDtl.Qty_Ordered) To OrderDtl.Extended_Price
63 Send Adjust_Balances OrderDtl.Qty_Ordered OrderDtl.Extended_Price
64 End_Procedure
65
66 Procedure Backout
67 Forward Send Backout
68 Send Adjust_Balances (-OrderDtl.Qty_Ordered) (-OrderDtl.Extended_Price)
69 End_Procedure
70
71 // Called by Backout and Update passing the quantity
72 // and the extended price.
73 // Subtract quantity from Invt on-hand and
74 // add extended amnt to order total.
75 Procedure Adjust_Balances Number Qty Number Amt
76 Subtract Qty From Invt.On_Hand
77 Add Amt To OrderHea.Order_Total
78 End_Procedure
79
80 // when entering the price field we may wish to update the
81 // current field value with the standard unit price from the
82 // Invt file. Only do this if the current amount is zero and an item was actually picked. If non-
83 // zero or no item picked, we assume the field is being edited (and we make no assumptions).
84 Procedure Entering_Price Integer Field# Number nAmnt
85 Handle hoInvtDD
86 Boolean bHasRecord
87
88 Get Data_Set Invt.File_Number to hoInvtDD
89
90 If (hoInvtDD) Begin
91 Get HasRecord of hoInvtDD to bHasRecord
92
93 If (nAmnt=0 and bHasRecord) Begin
94 Get File_Field_Current_Value File_Field Invt.Unit_Price to nAmnt
95 Set Field_Changed_Value Field# to nAmnt
96 Send Adjust_Display_Total
97 End
98 End
99
100 End_Procedure
101
102 // This updates the extended price field, which will update any
103 // display balances. This is only done for display purposes. The actual
104 // amount is updated to the field during the save.
105 Procedure Adjust_Display_total Integer iField String sValue
106 Integer iQty
107 Number nAmnt
108
109 Get Field_Current_Value Field OrderDtl.Qty_Ordered To iQty
110 Get Field_Current_Value Field OrderDtl.Price To nAmnt
111 Set Field_Current_Value Field OrderDtl.Extended_Price To (nAmnt * iQty)
112 // note we set value, but not changed state!
113 End_Procedure
114
115
116 Procedure Field_Defaults
117 Forward Send Field_Defaults
118 End_Procedure // Field_Defaults
119
120End_Class // OrderDtl_DataDictionary
121
122