﻿var NetSuiteItemPrice = (function() {
    function fnNetSuiteItemPriceConstructor(iNewCurrency, fNewAmount) {
        /****************************************************/
        /*                                                  */
        /*                                                  */
        /*           Class Level Private Variables          */
        /*                                                  */
        /*                                                  */
        /****************************************************/
        
        var oInstance;

        var iCurrency;
        var fAmount;
        var aPromotions

        /****************************************************/
        /*                                                  */
        /*                                                  */
        /*                Accessors/Mutators                */
        /*                                                  */
        /*                                                  */
        /****************************************************/
        
        this.getCurrency = function() {
            return iCurrency;
        }
        
        this.setCurrency = function(iNewCurrency) {
            iCurrency = iNewCurrency;
        }
        
        this.getAmount = function() {
            return fAmount;
        }
        
        this.setAmount = function(fNewAmount) {
            fAmount = fNewAmount;
        }
        
        this.getPromotions = function() {
            var aNewPromotions = new Array();
            
            for (var iPromotion = 0; iPromotion < aPromotions.length; iPromotion++)
                aNewPromotions.push(new NetSuiteItemPricePromotion(aPromotions[iPromotion].getId()));
            
            return aNewPromotions;
        }
        
        /****************************************************/
        /*                                                  */
        /*                                                  */
        /*                Cloneable Interface               */
        /*                                                  */
        /*                                                  */
        /****************************************************/
        
        this.clone = function() {
            var oNewNetSuiteItemPrice = new NetSuiteItemPrice(this.getCurrency(), this.getAmount());
            
            for (var iPromotion = 0; iPromotion < aPromotions.length; iPromotion++)
                oNewNetSuiteItemPrice.addPromotion(aPromotions[iPromotion].clone());
                
            return oNewNetSuiteItemPrice;
        }
        
        /****************************************************/
        /*                                                  */
        /*                                                  */
        /*          Class Level Priveleged Methods          */
        /*                                                  */
        /*                                                  */
        /****************************************************/
        
        this.addPromotion = function(oPromotion) {
            aPromotions.push(oPromotion);
        }
        
        this.removePromotion = function() {
            
        }
        
        /****************************************************/
        /*                                                  */
        /*                                                  */
        /*                 Initialize Class                 */
        /*                                                  */
        /*                                                  */
        /****************************************************/
        
        oInstance = this;

        this.setCurrency(iNewCurrency);
        this.setAmount(fNewAmount);
        aPromotions = new Array();
    }
    
    return fnNetSuiteItemPriceConstructor;
})();