Beispiel #1
0
        /// <summary>
        /// Blind closes the current shift.
        /// </summary>
        /// <param name="transaction">The current transaction instance.</param>
        public void BlindCloseShift(IPosTransaction transaction)
        {
            if (transaction == null)
            {
                NetTracer.Warning("transaction parameter is null");
                throw new ArgumentNullException("transaction");
            }

            // Are you sure you want to close the batch?
            DialogResult dialogResult = this.Application.Services.Dialog.ShowMessage(51308, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            {
                if (dialogResult == DialogResult.Yes)
                {
                    BatchData batchData = new BatchData(Application.Settings.Database.Connection, Application.Settings.Database.DataAreaID);

                    transaction.Shift.Status           = PosBatchStatus.BlindClosed;
                    transaction.Shift.StatusDateTime   = DateTime.Now;
                    transaction.Shift.OpenedAtTerminal = string.Empty;
                    transaction.Shift.CashDrawer       = string.Empty;

                    batchData.UpdateBatch(transaction.Shift);
                    ShiftUsersCache.Remove(transaction.Shift);
                    transaction.Shift.Print();

                    this.Application.Services.Dialog.ShowMessage(51342);
                }
                else
                {
                    ((PosTransaction)transaction).EntryStatus = PosTransaction.TransactionStatus.Cancelled;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Suspend the current batch.
        /// </summary>
        /// <param name="transaction">The current transaction instance.</param>
        public void SuspendShift(IPosTransaction transaction)
        {
            if (transaction == null)
            {
                NetTracer.Warning("transaction parameter is null");
                throw new ArgumentNullException("transaction");
            }

            BatchData batchData = new BatchData(Application.Settings.Database.Connection,
                                                Application.Settings.Database.DataAreaID);

            transaction.Shift.OpenedAtTerminal = string.Empty;
            transaction.Shift.CashDrawer       = string.Empty;
            transaction.Shift.Status           = PosBatchStatus.Suspended;
            transaction.Shift.StatusDateTime   = DateTime.Now;

            batchData.UpdateBatch(transaction.Shift);
            ShiftUsersCache.Remove(transaction.Shift);
            transaction.Shift.Print();

            this.Application.Services.Dialog.ShowMessage(51342);
        }
Beispiel #3
0
        /// <summary>
        /// Closes the current shift and print it as Z-Report.
        /// </summary>
        /// <param name="transaction">The current transaction instance.</param>
        public void CloseShift(IPosTransaction transaction)
        {
            if (transaction == null)
            {
                NetTracer.Warning("transaction parameter is null");
                throw new ArgumentNullException("transaction");
            }

            Batch batch = null;

            // Are you sure you want to close the shift ?
            if (this.Application.Services.Dialog.ShowMessage(51302, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                batch = new Batch(transaction.Shift);

                // Verify if all offline transacitons has been uploaded.
                if (!batch.VerifyOfflineTransactions())
                {
                    batch = null;
                    this.Application.Services.Dialog.ShowMessage(51341);
                }
            }

            // Calculate and verify amounts.
            if (batch != null)
            {
                // Calculate batch in background
                POSFormsManager.ShowPOSMessageWithBackgroundWorker(51303, delegate { batch.Calculate(); });

                Action <decimal, int, int> verifyAmount = delegate(decimal amount, int errorMsg, int warningMsg)
                {
                    if (amount == 0)
                    {
                        // Warning or error based on configration in HQ.
                        if ((Functions.RequireAmountDeclaration &&
                             this.Application.Services.Dialog.ShowMessage(errorMsg, MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) ||
                            (this.Application.Services.Dialog.ShowMessage(warningMsg, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No))
                        {
                            batch = null;
                        }
                    }
                };

                // Verify starting amounts.
                if (batch != null)
                {
                    verifyAmount(batch.StartingAmountTotal, 51344, 51343);
                }

                // Verify tender delcartion.
                if (batch != null)
                {
                    verifyAmount(batch.DeclareTenderAmountTotal, 51346, 51345);
                }
            }

            // Close the batch and Print Z report if everything is ok.
            if (batch != null)
            {
                batch.Status           = PosBatchStatus.Closed;
                batch.CloseDateTime    = DateTime.Now;
                batch.ClosedAtTerminal = ApplicationSettings.Terminal.TerminalId;

                BatchData batchData = new BatchData(Application.Settings.Database.Connection, Application.Settings.Database.DataAreaID);
                batchData.CloseBatch(batch);
                transaction.Shift.Status = PosBatchStatus.Closed;
                ShiftUsersCache.Remove(transaction.Shift);

                // Print Z report if user has permissions.
                IUserAccessSystem userAccessSystem = Application.BusinessLogic.UserAccessSystem;

                if (userAccessSystem.UserHasAccess(ApplicationSettings.Terminal.TerminalOperator.OperatorId, PosisOperations.PrintZ))
                {
                    POSFormsManager.ShowPOSMessageWithBackgroundWorker(99, delegate { batch.Print(ReportType.ZReport); });
                }

                this.Application.Services.Dialog.ShowMessage(51342); // Operation complete
            }
            else
            {
                NetTracer.Information("Setting status of the transaction to 'cancelled'");
                ((PosTransaction)transaction).EntryStatus = PosTransaction.TransactionStatus.Cancelled;
            }
        }