contract SalesContract is AllowanceCrowdsale, TimedCrowdsale {

    uint256 private _sold;

    constructor(
        uint256 rate,
        address payable wallet,
        ERC20 token,
        address payable tokenWallet,
        uint256 openingTime,
        uint256 closingTime
    )
        Crowdsale(rate, wallet, token)
        AllowanceCrowdsale(tokenWallet)
        TimedCrowdsale(openingTime, closingTime)
        public
    {
        _sold = 0;
    }

    /**
     * @return the token being sold.
     */
    function sold() public view returns (uint256) {
        return _sold;
    }

    /**
    * @dev Override to track number of sold tokens
    * @param _beneficiary Address receiving the tokens
    * @param _weiAmount Value in wei involved in the purchase
    */
    function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal
    {
        _sold = _sold.add(_getTokenAmount(_weiAmount));
    }
}
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal
{
    _sold = _sold.add(_getTokenAmount(_weiAmount));
}

/**
 * @dev Override to track number of sold tokens
 * @param _beneficiary Address receiving the tokens
 * @param _weiAmount Value in wei involved in the purchase
 */