コード例 #1
0
        private Dictionary <string, List <MyPairValue> > CalculateReceipt()
        {
            var result = new Dictionary <string, List <MyPairValue> >();

            var receiptQuery =
                _cloudPosUnitofwork.ReceiptNoteRepository.Get(x => x.Inday.CompareTo(From) >= 0 &&
                                                              x.Inday.CompareTo(To) <= 0);

            //Total Receipt
            decimal totalAmount = 0;

            foreach (var order in receiptQuery)
            {
                totalAmount += order.TotalAmount;
            }
            MyPairValue receiptCal = new MyPairValue()
            {
                Title  = "Bills",
                Count  = receiptQuery.Count(),
                Amount = totalAmount
            };

            result.Add("Total", new List <MyPairValue>()
            {
                receiptCal
            });

            return(result);
        }
コード例 #2
0
        private Dictionary <string, List <MyPairValue> > CalculatePayAndRefund()
        {
            var result     = new Dictionary <string, List <MyPairValue> >();
            var orderQuery =
                _cloudPosUnitofwork.OrderRepository.Get(x => x.Ordertime.CompareTo(From) >= 0 &&
                                                        x.Ordertime.CompareTo(To) <= 0);

            //Total Cash
            var     orderCashQuery  = orderQuery.Where(x => x.paymentMethod == (int)PaymentMethod.Cash);
            decimal cashTotalAmount = 0;

            foreach (var order in orderCashQuery)
            {
                cashTotalAmount += order.TotalPrice;
            }
            MyPairValue cashCal = new MyPairValue()
            {
                Title  = "Orders",
                Count  = orderCashQuery.Count(),
                Amount = cashTotalAmount
            };

            result.Add("Cash", new List <MyPairValue>()
            {
                cashCal
            });


            //Total Cheque
            var     orderChequeQuery  = orderQuery.Where(x => x.paymentMethod == (int)PaymentMethod.Cheque);
            decimal chequeTotalAmount = 0;

            foreach (var order in orderChequeQuery)
            {
                chequeTotalAmount += order.TotalPrice;
            }
            MyPairValue chequeCal = new MyPairValue()
            {
                Title  = "Orders",
                Count  = orderChequeQuery.Count(),
                Amount = chequeTotalAmount
            };

            result.Add("Cheque", new List <MyPairValue>()
            {
                chequeCal
            });


            //Total Deferred
            var     orderDeferredQuery  = orderQuery.Where(x => x.paymentMethod == (int)PaymentMethod.Deferred);
            decimal deferredTotalAmount = 0;

            foreach (var order in orderDeferredQuery)
            {
                deferredTotalAmount += order.TotalPrice;
            }
            MyPairValue defferedCal = new MyPairValue()
            {
                Title  = "Orders",
                Count  = orderDeferredQuery.Count(),
                Amount = deferredTotalAmount
            };

            result.Add("Deferred", new List <MyPairValue>()
            {
                defferedCal
            });


            //Total International(Visa)
            var     orderInterQuery  = orderQuery.Where(x => x.paymentMethod == (int)PaymentMethod.International);
            decimal interTotalAmount = 0;

            foreach (var order in orderInterQuery)
            {
                interTotalAmount += order.TotalPrice;
            }
            MyPairValue interCal = new MyPairValue()
            {
                Title  = "Orders",
                Count  = orderInterQuery.Count(),
                Amount = interTotalAmount
            };

            result.Add("International(Visa)", new List <MyPairValue>()
            {
                interCal
            });


            //Total Credit
            var     orderCreditQuery  = orderQuery.Where(x => x.paymentMethod == (int)PaymentMethod.Credit);
            decimal creditTotalAmount = 0;

            foreach (var order in orderCreditQuery)
            {
                creditTotalAmount += order.TotalPrice;
            }
            MyPairValue creditCal = new MyPairValue()
            {
                Title  = "Orders",
                Count  = orderCreditQuery.Count(),
                Amount = creditTotalAmount
            };

            result.Add("Credit", new List <MyPairValue>()
            {
                creditCal
            });


            //Total OnAcount
            var     orderOnAcountQuery  = orderQuery.Where(x => x.paymentMethod == (int)PaymentMethod.OnAcount);
            decimal onAcountTotalAmount = 0;

            foreach (var order in orderOnAcountQuery)
            {
                onAcountTotalAmount += order.TotalPrice;
            }
            MyPairValue onAcountCal = new MyPairValue()
            {
                Title  = "Orders",
                Count  = orderOnAcountQuery.Count(),
                Amount = onAcountTotalAmount
            };

            result.Add("On Account", new List <MyPairValue>()
            {
                onAcountCal
            });


            return(result);
        }
コード例 #3
0
        private Dictionary <string, List <MyPairValue> > CalculateTotalSales()
        {
            var result            = new Dictionary <string, List <MyPairValue> >();
            var orderDetailsQuery =
                _cloudPosUnitofwork.OrderDetailsRepository.Get(x => x.OrderNote.Ordertime.CompareTo(From) >= 0 &&
                                                               x.OrderNote.Ordertime.CompareTo(To) <= 0);
            var orderQuery =
                _cloudPosUnitofwork.OrderRepository.Get(x => x.Ordertime.CompareTo(From) >= 0 &&
                                                        x.Ordertime.CompareTo(To) <= 0);


            // Total Alcohol
            var orderDetailsAlcoholQuery = orderDetailsQuery.Where(x => x.Product.Type == (int)ProductType.Cocktail ||
                                                                   x.Product.Type == (int)ProductType.Beer ||
                                                                   x.Product.Type == (int)ProductType.Wine);
            decimal alcoholTotalAmount = 0;

            foreach (var orderDetails in orderDetailsAlcoholQuery)
            {
                alcoholTotalAmount += orderDetails.Quan * (orderDetails.Product.Price * (100 - orderDetails.Discount)) / 100;
            }
            MyPairValue alcoholCal = new MyPairValue()
            {
                Title  = "Count",
                Count  = orderDetailsAlcoholQuery.Count(),
                Amount = alcoholTotalAmount
            };

            result.Add("Total Alcohol", new List <MyPairValue>()
            {
                alcoholCal
            });


            // Total Beverage
            var orderDetailsBeverageQuery = orderDetailsQuery.Where(x => x.Product.Type == (int)ProductType.Beverage ||
                                                                    x.Product.Type == (int)ProductType.Coffee);
            decimal beverageTotalAmount = 0;

            foreach (var orderDetails in orderDetailsBeverageQuery)
            {
                beverageTotalAmount += orderDetails.Quan * (orderDetails.Product.Price * (100 - orderDetails.Discount)) / 100;
            }
            MyPairValue beverageCal = new MyPairValue()
            {
                Title  = "Count",
                Count  = orderDetailsBeverageQuery.Count(),
                Amount = beverageTotalAmount
            };

            result.Add("Total Beverage", new List <MyPairValue>()
            {
                beverageCal
            });


            // Total Food
            var     orderDetailsFoodQuery = orderDetailsQuery.Where(x => x.Product.Type == (int)ProductType.Food);
            decimal foodTotalAmount       = 0;

            foreach (var orderDetails in orderDetailsFoodQuery)
            {
                foodTotalAmount += orderDetails.Quan * (orderDetails.Product.Price * (100 - orderDetails.Discount)) / 100;
            }
            MyPairValue foodCal = new MyPairValue()
            {
                Title  = "Count",
                Count  = orderDetailsFoodQuery.Count(),
                Amount = foodTotalAmount
            };

            result.Add("Total Food", new List <MyPairValue>()
            {
                foodCal
            });


            // Total Other
            var     orderDetailsOtherQuery = orderDetailsQuery.Where(x => x.Product.Type == (int)ProductType.Other);
            decimal otherTotalAmount       = 0;

            foreach (var orderDetails in orderDetailsOtherQuery)
            {
                otherTotalAmount += orderDetails.Quan * (orderDetails.Product.Price * (100 - orderDetails.Discount)) / 100;
            }
            MyPairValue otherCal = new MyPairValue()
            {
                Title  = "Count",
                Count  = orderDetailsOtherQuery.Count(),
                Amount = otherTotalAmount
            };

            result.Add("Total Other", new List <MyPairValue>()
            {
                otherCal
            });


            // SubTotal
            // real TotalAmount
            decimal totalAmount = 0;

            foreach (var orderDetails in orderDetailsQuery)
            {
                totalAmount += orderDetails.Quan * (orderDetails.Product.Price * (100 - orderDetails.Discount)) / 100;
            }
            MyPairValue orderTotalCal = new MyPairValue()
            {
                Title  = "Orders",
                Amount = totalAmount,
                Count  = orderQuery.Count()
            };

            // SVC
            decimal totalSVC = 0;

            foreach (var order in orderQuery)
            {
                decimal curTotalAmount = 0;
                foreach (var orderDetails in order.OrderNoteDetails)
                {
                    curTotalAmount += orderDetails.Quan * (orderDetails.Product.Price * (100 - orderDetails.Discount)) / 100;
                }

                totalSVC += (curTotalAmount * 5) / 100;
            }
            MyPairValue SVCTotalCal = new MyPairValue()
            {
                Title  = "Service Charge",
                Amount = totalSVC,
                Count  = orderQuery.Count()
            };

            // VAT
            decimal totalVAT = 0;

            foreach (var order in orderQuery)
            {
                decimal curTotalAmount = 0;
                foreach (var orderDetails in order.OrderNoteDetails)
                {
                    curTotalAmount += orderDetails.Quan * (orderDetails.Product.Price * (100 - orderDetails.Discount)) / 100;
                }

                totalVAT += ((((curTotalAmount * 5) / 100) + curTotalAmount) * 10) / 100;
            }
            MyPairValue VATTotalCal = new MyPairValue()
            {
                Title  = "VAT",
                Amount = totalVAT,
                Count  = orderQuery.Count()
            };

            // DIscount
            decimal totalDisc = 0;
            int     countDisc = 0;

            foreach (var order in orderQuery)
            {
                if (order.Discount != 0)
                {
                    totalDisc += order.TotalPriceNonDisc - order.TotalPrice;
                    countDisc++;
                }
            }
            MyPairValue DiscTotalCal = new MyPairValue()
            {
                Title  = "Discount",
                Amount = totalDisc,
                Count  = countDisc
            };

            result.Add("SubTotal", new List <MyPairValue>()
            {
                orderTotalCal,
                SVCTotalCal,
                VATTotalCal,
                DiscTotalCal
            });


            // Total
            decimal total = 0;

            foreach (var order in orderQuery)
            {
                total += order.TotalPrice;
            }
            MyPairValue totalCal = new MyPairValue()
            {
                Title  = "Orders",
                Amount = total,
                Count  = orderQuery.Count()
            };

            result.Add("Total", new List <MyPairValue>()
            {
                totalCal
            });

            return(result);
        }