Beispiel #1
0
        public EditNewPayment(Operation operation, BasePaymentType?paymentType = null, bool printFiscal = false)
        {
            this.operation = operation;
            if (this.operation.Id <= 0)
            {
                this.operation.Payments.Clear();
            }

            total            = Currency.Round(operation.TotalPlusVAT, operation.TotalsPriceType);
            this.paymentType = paymentType ?? BusinessDomain.AppConfiguration.LastPaymentMethod;

            paymentWidget = new PaymentWidget(payments, operation.TotalsPriceType);
            paymentWidget.PaymentDeleted += (sender, e) => RecalculateChange(paymentWidget.Received);
            paymentWidget.ValueChanged   += (sender, e) => RecalculateChange(e.Value);

            Initialize();

            ArrangePaymentWidget();

            chkChangeIsReturned.Visible = operation.UseChange;

            ICashReceiptPrinterController cashReceiptPrinter = BusinessDomain.DeviceManager.CashReceiptPrinterDriver;
            object hasFiscalMemory;

            chkPrintCashReceipt.Sensitive = cashReceiptPrinter != null &&
                                            operation.AllowFiscal &&
                                            (operation.Id < 0 || (cashReceiptPrinter.GetAttributes().TryGetValue(DriverBase.HAS_FISCAL_MEMORY, out hasFiscalMemory) && (bool)hasFiscalMemory == false));

            chkPrintCashReceipt.Visible = BusinessDomain.WorkflowManager.AllowSaleWithoutReceipt;
            chkPrintCashReceipt.Active  = !BusinessDomain.WorkflowManager.AllowSaleWithoutReceipt || (chkPrintCashReceipt.Sensitive && printFiscal);
            chkPrintDocument.Sensitive  = BusinessDomain.AppConfiguration.IsPrintingAvailable();
        }
Beispiel #2
0
        private void PrintNonFiscal(DeviceManagerBase devMan, ICashReceiptPrinterController printer)
        {
            if (!printer.SupportedCommands.Contains(DeviceCommands.OpenNonFiscal) ||
                (!printer.SupportedCommands.Contains(DeviceCommands.PrintTextNonFiscal) &&
                 !printer.SupportedCommands.Contains(DeviceCommands.PrintKeyValueNonFiscal)) ||
                !printer.SupportedCommands.Contains(DeviceCommands.CloseNonFiscal))
            {
                return;
            }

            KeyValuePair <string, string> [] lines = receiptReport.GetReportLines();
            txvPreview.Buffer.Text = receiptReport.Display(lines);

            devMan.TryDeviceCommand(delegate
            {
                printer.OpenNonFiscal(false);

                if (printer.SupportedCommands.Contains(DeviceCommands.PrintTitleNonFiscal))
                {
                    printer.PrintTitleNonFiscal(receiptReport.Title);
                }
                else
                {
                    printer.PrintTextNonFiscal(receiptReport.Title.AlignCenter(printer.NonFiscalTextCharsPerLine));
                }

                printer.PrintTextNonFiscal(DriverBase.SEPARATOR);
            });

            if (printer.SupportedCommands.Contains(DeviceCommands.PrintKeyValueNonFiscal))
            {
                for (int i = 0; i < lines.Length; i++)
                {
                    if (i % 5 == 0)
                    {
                        ShowProgress(((double)i * 100) / lines.Length);
                    }

                    string key = lines [i].Key;
                    string val = lines [i].Value;
                    devMan.TryDeviceCommand(() => printer.PrintKeyValueNonFiscal(key, val, " "));
                }
            }
            else
            {
                for (int i = 0; i < lines.Length; i++)
                {
                    if (i % 5 == 0)
                    {
                        ShowProgress(((double)i * 100) / lines.Length);
                    }

                    string key = lines [i].Key;
                    string val = lines [i].Value;
                    devMan.TryDeviceCommand(() => printer.PrintTextNonFiscal(ReceiptReport.GetReportLine(key, val, printer.NonFiscalTextCharsPerLine)));
                }
            }

            devMan.TryDeviceCommand(printer.CloseNonFiscal);
        }
Beispiel #3
0
        private void btnPrint_Clicked(object o, EventArgs args)
        {
            if (!ValidateFilters())
            {
                return;
            }

            DisplayReport();

            if (string.IsNullOrEmpty(txvPreview.Buffer.Text))
            {
                using (MessageError dlgMsg = new MessageError(
                           Translator.GetString("No matches."), "Icons.Report16.png",
                           ErrorSeverity.Information, null)) {
                    dlgMsg.Run();
                }
            }
            else
            {
                try {
                    exportProgress = new MessageProgress(Translator.GetString("Printing report..."), null, null);
                    exportProgress.Show();

                    FormHelper.TryReceiptPrinterCommand(delegate
                    {
                        DeviceManagerBase devMan = BusinessDomain.DeviceManager;
                        ICashReceiptPrinterController printer = devMan.CustomerOrderPrinter as ICashReceiptPrinterController;
                        if (printer != null)
                        {
                            PrintNonFiscal(devMan, printer);
                        }
                        else
                        {
                            IKitchenPrinterController kitchenPrinter = devMan.CustomerOrderPrinter as IKitchenPrinterController;
                            if (kitchenPrinter != null)
                            {
                                PrintKitchen(devMan, kitchenPrinter);
                            }
                        }
                    }, false);
                } finally {
                    exportProgress.Dispose();
                    exportProgress = null;
                }
            }
        }
        public FiscalRegisterCash()
        {
            cashReceiptDriver = BusinessDomain.DeviceManager.SalesDataControllerDriver as ICashReceiptPrinterController
                                ?? BusinessDomain.DeviceManager.CashReceiptPrinterDriver;
            if (cashReceiptDriver == null)
            {
                throw new HardwareErrorException(new ErrorState(ErrorState.CashReceiptPrinterDisconnected, HardwareErrorSeverity.Error));
            }

            Initialize();

            if (cashReceiptDriver.SupportedCommands.Contains(DeviceCommands.RegisterCash))
            {
                rbnCashInput.Sensitive       = true;
                rbnCashOutput.Sensitive      = true;
                btnChoose.Sensitive          = true;
                txvCashDescription.Sensitive = true;
                txvReason.Sensitive          = true;
                btnOK.Sensitive = true;
            }

            lblAmountValue.SetText(Currency.ToString(0, PriceType.SaleTotal));
            btnChoose.Clicked += btnChoose_Clicked;
        }
Beispiel #5
0
        /// <summary>
        /// Handles the hardware error passed and shows the appropriate message
        /// </summary>
        /// <param name="ex">The HardwareErrorException to be handled</param>
        /// <param name="buttonsMask">The AND mask to be applied for the Message buttons</param>
        public static HardwareErrorResponse HandleHardwareError(HardwareErrorException ex, MessageButtons buttonsMask = MessageButtons.All)
        {
            bool retry;
            HardwareErrorResponse ret;

            do
            {
                retry = false;
                ret   = ShowHardwareErrorMessage(ex, buttonsMask);

                ICashReceiptPrinterController cashReceiptPrinter = BusinessDomain.DeviceManager.CashReceiptPrinterDriver;
                IConnectableDevice            nonFiscalPrinter   = BusinessDomain.DeviceManager.CustomerOrderPrinter;
                try {
                    if (ret.Retry)
                    {
                        if (ret.RetryWithoutPrint && cashReceiptPrinter == null && nonFiscalPrinter == null)
                        {
                            ret.RetryWithoutPrint = false;
                            ret.CancelLastReceipt = true;
                        }

                        if (ret.RetryWithoutPrint)
                        {
                            if (cashReceiptPrinter != null &&
                                cashReceiptPrinter.SupportedCommands.Contains(DeviceCommands.GetStatus))
                            {
                                cashReceiptPrinter.GetStatus();
                                if (cashReceiptPrinter.LastErrorState.CheckError(ErrorState.NoPaper) ||
                                    cashReceiptPrinter.LastErrorState.Check(ErrorState.WaitingPaperReplaceConfirmation))
                                {
                                    retry = true;
                                    continue;
                                }

                                if (cashReceiptPrinter.LastErrorState.Check(ErrorState.FiscalCheckOpen))
                                {
                                    ret.RetryWithoutPrint = false;
                                    ret.CancelLastReceipt = true;
                                }
                                else
                                {
                                    ret.CancelLastReceipt = false;
                                }
                            }
                        }

                        if (ret.RetryWithoutPrint)
                        {
                            if (nonFiscalPrinter != null &&
                                nonFiscalPrinter.SupportedCommands.Contains(DeviceCommands.GetStatus))
                            {
                                nonFiscalPrinter.GetStatus();
                                if (nonFiscalPrinter.LastErrorState.CheckError(ErrorState.NoPaper) ||
                                    nonFiscalPrinter.LastErrorState.Check(ErrorState.WaitingPaperReplaceConfirmation))
                                {
                                    retry = true;
                                    continue;
                                }

                                if (nonFiscalPrinter.LastErrorState.Check(ErrorState.NonFiscalCheckOpen))
                                {
                                    ret.RetryWithoutPrint = false;
                                    ret.CancelLastReceipt = true;
                                }
                                else
                                {
                                    ret.CancelLastReceipt = false;
                                }
                            }
                        }
                    }

                    if (ret.CancelLastReceipt)
                    {
                        if (cashReceiptPrinter != null &&
                            cashReceiptPrinter.LastErrorState.Check(ErrorState.FiscalCheckOpen))
                        {
                            bool annulled;
                            BusinessDomain.DeviceManager.CancelFiscalReceipt(out annulled);
                            if (!annulled)
                            {
                                ret.RetryWithoutPrint = true;
                            }
                        }
                        if (nonFiscalPrinter != null &&
                            nonFiscalPrinter.LastErrorState.Check(ErrorState.NonFiscalCheckOpen))
                        {
                            BusinessDomain.DeviceManager.CancelNonFiscalReceipt();
                        }
                    }
                } catch (HardwareErrorException) {
                }
            } while (retry);

            return(ret);
        }
Beispiel #6
0
        public FiscalReports()
        {
            cashReceiptDriver = BusinessDomain.DeviceManager.SalesDataControllerDriver as ICashReceiptPrinterController
                                ?? BusinessDomain.DeviceManager.CashReceiptPrinterDriver;
            if (cashReceiptDriver == null)
            {
                throw new HardwareErrorException(new ErrorState(ErrorState.CashReceiptPrinterDisconnected, HardwareErrorSeverity.Error));
            }

            Initialize();

            #region Daily reports

            bool supportsAny = false;
            if (cashReceiptDriver.SupportedCommands.Contains(DeviceCommands.DailyEJReport))
            {
                rbnDailyEJReport.Sensitive = true;
                rbnDailyEJReport.Active    = true;
                supportsAny = true;
            }
            if (cashReceiptDriver.SupportedCommands.Contains(DeviceCommands.DailyZReport))
            {
                rbnDailyZReport.Sensitive = true;
                rbnDailyZReport.Active    = true;
                supportsAny = true;
            }
            if (cashReceiptDriver.SupportedCommands.Contains(DeviceCommands.DailyXReport))
            {
                rbnDailyXReport.Sensitive = true;
                rbnDailyXReport.Active    = true;
                supportsAny = true;
            }
            if (!supportsAny)
            {
                frmDailyReports.Sensitive = false;
            }

            #endregion

            #region Special reports

            supportsAny = false;
            if (cashReceiptDriver.SupportedCommands.Contains(DeviceCommands.RAMResetsReport))
            {
                rbnRAMResetsReport.Sensitive = true;
                rbnRAMResetsReport.Active    = true;
                supportsAny = true;
            }
            if (cashReceiptDriver.SupportedCommands.Contains(DeviceCommands.VATRateChangesReport))
            {
                rbnVATChangesReport.Sensitive = true;
                rbnVATChangesReport.Active    = true;
                supportsAny = true;
            }
            if (cashReceiptDriver.SupportedCommands.Contains(DeviceCommands.OperatorsReport))
            {
                rbnOperatorsReport.Sensitive = true;
                rbnOperatorsReport.Active    = true;
                supportsAny = true;
            }

            if (!supportsAny)
            {
                frmSpecialReports.Sensitive = false;
            }

            #endregion

            #region Reports by dates reports

            supportsAny = false;
            if (cashReceiptDriver.SupportedCommands.Contains(DeviceCommands.DetailFMReportByDates))
            {
                rbnDateDetailReport.Sensitive = true;
                rbnDateDetailReport.Active    = true;
                supportsAny = true;
            }
            if (cashReceiptDriver.SupportedCommands.Contains(DeviceCommands.ShortFMReportByDates))
            {
                rbnDateReport.Sensitive = true;
                rbnDateReport.Active    = true;
                supportsAny             = true;
            }
            if (!supportsAny)
            {
                frmDateReports.Sensitive = false;
            }

            #endregion

            #region Reports by numbers reports

            supportsAny = false;
            if (cashReceiptDriver.SupportedCommands.Contains(DeviceCommands.DetailFMReportByNumbers))
            {
                rbnNumberDetailReport.Sensitive = true;
                rbnNumberDetailReport.Active    = true;
                supportsAny = true;
            }
            if (cashReceiptDriver.SupportedCommands.Contains(DeviceCommands.ShortFMReportByNumbers))
            {
                rbnNumberReport.Sensitive = true;
                rbnNumberReport.Active    = true;
                supportsAny = true;
            }
            if (!supportsAny)
            {
                frmNumberReports.Sensitive = false;
            }

            #endregion
        }