Example #1
0
        private ShiftEntity GetShiftFormReceipts(ShiftEntity shiftEntity)
        {
            List <ReceiptEntity> receiptEntity = _receiptRepository.GetReceiptByShiftId(shiftEntity.Id, shiftEntity.StoreEmail);


            decimal cashPayment = 0m;
            decimal discount    = 0m;
            decimal debitCard   = 0m;
            decimal creditCard  = 0m;
            decimal qrCode      = 0m;



            foreach (ReceiptEntity receipt in receiptEntity)
            {
                if (receipt.PaymentType == EP_PaymentTypeEnum.Cash)
                {
                    cashPayment += receipt.Total;
                }
                else if (receipt.PaymentType == EP_PaymentTypeEnum.Credit)
                {
                    creditCard += receipt.Total;
                }
                else if (receipt.PaymentType == EP_PaymentTypeEnum.Debit)
                {
                    debitCard += receipt.Total;
                }
                else if (receipt.PaymentType == EP_PaymentTypeEnum.Qr)
                {
                    qrCode += receipt.Total;
                }

                discount += receipt.TotalDiscount;
            }



            shiftEntity.CashPayment = cashPayment;
            shiftEntity.CreditCard  = creditCard;
            shiftEntity.DebitCard   = debitCard;
            shiftEntity.QRCode      = qrCode;
            shiftEntity.Discount    = discount;

            decimal payIn  = 0;
            decimal payOut = 0;
            List <ManageCashEntity> manageCash = _manageCashRepository.GetManageCashByShiftId(shiftEntity.Id, shiftEntity.StoreEmail);

            foreach (ManageCashEntity manage in manageCash)
            {
                if (manage.ManageCashStatus == ManageCashStatus.PayIn)
                {
                    payIn += manage.Amount;
                }
                else if (manage.ManageCashStatus == ManageCashStatus.PayOut)
                {
                    payOut += manage.Amount;
                }
            }

            shiftEntity.Paidin  = payIn;
            shiftEntity.Paidout = payOut;


            return(shiftEntity);
        }