/*

Copyright (C) 1998, 2000 by the Object Management Group, Inc.  All  
rights reserved.  

Permission to use, copy, modify, and distribute this software for
any teaching or instructional purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that copyright notice and this permission
notice appear in supporting documentation, and that the names of
Object Management Group, Inc. (OMG) and John Wiley and Sons, Inc.
(Wiley) not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.

THIS SOFTWARE IS SOLD AS IS WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  Neither OMG, Wiley, nor their dealers or distributors
assume any liability of any alleged or actual damages arising
from the use of or the inability to use this software.  (Some
states do not allow the exclusion of implied warranties, so the
exclusion may not apply to you).

*/
#ifndef _STORE_IDL_
#define _STORE_IDL_

// include interface definition for Point Of Sale objects
#include "POS.idl"

#pragma prefix "omg.org"

module AStore
{
    enum ItemTypes {FOOD, CLOTHES, OTHER};
    typedef long AStoreId;

    struct ItemInfo
    {
        POS::Barcode      item;
        ItemTypes         item_type;
        float             item_cost;
        string            name;
        long              quantity;
    };

    // The barcodeNotFound exception indicates that the
    // input barcode does not match to any known item.
    exception BarcodeNotFound { POS::Barcode item; };

    interface StoreAccess; // /forward reference

    struct POSInfo
    {
        POS::POSId   id;
        StoreAccess  store_access_reference;
        float        total_sales;
        float        total_taxes;
    };

    typedef sequence <POSInfo> POSList;

    interface Tax
    {
        float calculate_tax(     in float     taxable_amount);
        float find_taxable_price(in float     item_price,
                                 in ItemTypes item_type);
    };

    interface Store
    {
        struct StoreTotals
        {
            float     store_total;
            float     store_tax_total;
        };

        readonly attribute AStoreId store_id;

        // The struct StoreTotals and this readonly attribute are used
        // in place of a pair of float attributes to avoid data inconsistencies
        // that would result from the following sequence of operations:
        //
        //    POS 1 invokes a method to read store_total
        //    POS 2 invokes the method update_store_totals
        //    POS 1 invokes a method to read the store_tax_total
        readonly attribute StoreTotals totals;

        StoreAccess login(               in  POS::POSId id);
        void        get_POS_totals(      out POSList    POS_data);
        void        update_store_totals( in  POS::POSId id,
                                         in  float      price,
                                         in  float      taxes);
    };

    interface StoreAccess
    {
        // ItemTaxPrice is 0 or return value of FindTaxablePrice()
        void        find_price(          in  POS::Barcode item,
                                         in  long         quantity,
                                         out float        item_price,
                                         out float        item_tax_price,
                                         out ItemInfo     item_info)
            raises (BarcodeNotFound);
    };

};
#endif /* _STORE_IDL_ */
