Example #1
0
        private bool CanPost(IPostable receipt, IShift shift, decimal money, out string message)
        {
            foreach (var item in receipt.Items)
            {
                if (!item.IsEnough(out float diff))
                {
                    message = $"Товара \"{item.ItemName}\" не хватает на складе ({diff} шт.)";
                    return(false);
                }
            }

            if ((money >= receipt.TotalPrice) && (receipt.GetItemsCount() > 0) && ((money - receipt.TotalPrice) <= shift.Balance))
            {
                message = $"Сдача: {money - receipt.TotalPrice} руб.";
                return(true);
            }
            else if (money < receipt.TotalPrice)
            {
                message = $"к оплате предоставлено недостаточно средств ({receipt.TotalPrice - money})";
                return(false);
            }
            else if (receipt.GetItemsCount() < 1)
            {
                message = $"список товаров пуст";
                return(false);
            }
            else
            {
                message = $"недостаточно средств для выдачи сдачи " +
                          $"({(money - receipt.TotalPrice) - shift.Balance}).\n" +
                          $"(В кассе: {shift.Balance} руб)";
                return(false);
            }
        }
Example #2
0
 private bool CanPost(IPostable receipt, IShift shift, out string message)
 {
     if ((receipt.GetItemsCount() > 0) && (receipt.TotalPrice <= shift.Balance))
     {
         message = $"К возврату: {receipt.TotalPrice} руб";
         return(true);
     }
     else if (receipt.GetItemsCount() < 1)
     {
         message = $"список товаров пуст";
         return(false);
     }
     else
     {
         message = $"недостаточно средств в кассе для выдачи сдачи " +
                   $"({receipt.TotalPrice - shift.Balance}).\n " +
                   $"В кассе: {shift.Balance} руб)";
         return(false);
     }
 }