コード例 #1
0
ファイル: Fiscal.cs プロジェクト: Genotroid/Console_cashier
        public void Register(byte paymentType = 0, string comment = "")
        {
            if (cart.GetCount() <= 0)
            {
                driver.OpenDocument(DOC_TYPE_BUY);
            }
            int    i       = 1;
            double cartSum = cart.GetTotal();
            double sum     = 0;

            //if (cart.GetDiscount() >= 1) driver.RegisterDiscount(1, "Sale", cart.GetDiscount());
            foreach (entities.Product element in cart.GetElements())
            {
                driver.setTax_id(element.Tax_id);
                driver.RegisterProduct(element.GetName(), element.GetSku(), element.GetCartCount(), element.GetPrice(), i);
                driver.RegisterDiscount(1, "sale", element.Discount);
                sum += (element.GetCartCount() * element.GetPrice());
                i++;
            }
            double paymentSum;

            if (cartSum < sum)
            {
                int discount = Convert.ToInt32(sum - cartSum);
                if (discount <= 1)
                {
                    discount = 1;
                }

                paymentSum = sum - discount;
            }
            else
            {
                paymentSum = sum;
            }
            //driver.SetTaxNumber(tax_id);
            //driver.SetCashierName(Properties.Settings.Default.cashierName);
            driver.PrintTotal();
            driver.RegisterPayment(cartSum, paymentType);
            if (comment != "")
            {
                driver.PrintString(comment);
            }
            if (Properties.Settings.Default.cashierSign)
            {
                driver.cashierSign();
            }
            if (Properties.Settings.Default.buyerSign)
            {
                driver.buyerSign();
            }
            for (i = 0; i < Properties.Settings.Default.indentSize / 5; i++)
            {
                driver.ScrollPaper();
            }
            driver.CloseDocument();
        }