public function getDiscountAmount()
    {
        $total = 0;
        $discount = 0;
        
        foreach ($this->items as $item) {
            if ($item->Price) {
                $total += ($item->Price * $item->Quantity);
            }
            
            if ($item->Discount) {
                $discount += ($item->TotalDiscount);
            }
        }
        
        if ($discount > $total) {
            $discount = $total;
        }

        return $discount;
    }
public function getDiscountAmount()
    {
        $total = 0;
        $discount = 0;
        
        foreach ($this->items as $item) {
            if ($item->Price) {
                $total += ($item->Price * $item->Quantity);
            }
            
            if ($item->Discount) {
                $discount += ($item->TotalDiscount);
            }
        }
        
        if ($discount > $total) {
            $discount = $total;
        }

        return $discount;
    }
public function getDiscountAmount ( ) { $ total = 0 ; $ discount = 0 ; foreach ( $ this -> items as $ item ) { if ( $ item -> Price ) { $ total += ( $ item -> Price * $ item -> Quantity ) ; } if ( $ item -> Discount ) { $ discount += ( $ item -> TotalDiscount ) ; } } if ( $ discount > $ total ) { $ discount = $ total ; } return $ discount ; }
Find the total discount based on discount items added.

@return Currency
Find the total discount based on discount items added .