Module ORDERDTL.DD

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