Beispiel #1
0
        public static pos_worksessionperiod GetSessionPeriod(WorkSessionPeriodType pWorkSessionPeriodType)
        {
            string whereTerminal = String.Empty;

            if (pWorkSessionPeriodType == WorkSessionPeriodType.Terminal)
            {
                whereTerminal = string.Format("Terminal = '{0}' AND ", GlobalFramework.LoggedTerminal.Oid);
            }

            string sql = string.Format(@"SELECT Oid FROM pos_worksessionperiod WHERE {1}PeriodType = '{0}' AND SessionStatus = 0;", Convert.ToInt16(pWorkSessionPeriodType), whereTerminal);
            Guid   workSessionPeriodOid = FrameworkUtils.GetGuidFromQuery(sql);

            if (workSessionPeriodOid != Guid.Empty)
            {
                pos_worksessionperiod resultWorkSessionPeriod = GlobalFramework.SessionXpo.GetObjectByKey <pos_worksessionperiod>(workSessionPeriodOid);
                //Add Parent Reference, not used because we use GlobalFramework.WorkSessionPeriodDay and not GlobalFramework.WorkSessionPeriodTerminal.Parent
                if (pWorkSessionPeriodType == WorkSessionPeriodType.Terminal)
                {
                    //Child > Parent Reference
                    resultWorkSessionPeriod.Parent = GlobalFramework.WorkSessionPeriodDay;
                }

                return(resultWorkSessionPeriod);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        public static XPCollection GetSessionPeriodTotal(Session pSession, pos_worksessionperiod pWorkSessionPeriod)
        {
            CriteriaOperator criteria           = CriteriaOperator.Parse(string.Format("Period = '{0}'", pWorkSessionPeriod.Oid));
            SortProperty     sortProperty       = new SortProperty("Ord", SortingDirection.Ascending);
            XPCollection     resultXPCollection = new XPCollection(pSession, typeof(pos_worksessionperiodtotal), criteria, sortProperty);

            return(resultXPCollection);
        }
Beispiel #3
0
        /// <summary>
        /// Show Close Message, Shared for Day and Terminal Sessions
        /// </summary>
        /// <param name="pWorkSessionPeriod"></param>
        /// <returns></returns>
        public void ShowClosePeriodMessage(Window pSourceWindow, pos_worksessionperiod pWorkSessionPeriod)
        {
            string messageResource = (pWorkSessionPeriod.PeriodType == WorkSessionPeriodType.Day) ?
                                     resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_worksession_day_close_successfully") :
                                     resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_worksession_terminal_close_successfully")
            ;
            string messageTotalSummary = string.Empty;
            //used to store number of payments used, to increase dialog window size
            int workSessionPeriodTotalCount = 0;
            //Window Height Helper vars
            int lineHeight   = 28;
            int windowHeight = 300;

            //Get Session Period Details
            Hashtable resultHashTable = ProcessWorkSessionPeriod.GetSessionPeriodSummaryDetails(pWorkSessionPeriod);
            //Get Total Money in CashDrawer On Open/Close
            string totalMoneyInCashDrawerOnOpen = string.Format("{0}: {1}", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_total_cashdrawer_on_open"), FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyInCashDrawerOnOpen"]));
            string totalMoneyInCashDrawer       = string.Format("{0}: {1}", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_total_cashdrawer"), FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyInCashDrawer"]));
            //Get Total Money and TotalMoney Out (NonPayments)
            string totalMoneyIn  = string.Format("{0}: {1}", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_cashdrawer_money_in"), FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyIn"]));
            string totalMoneyOut = string.Format("{0}: {1}", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_cashdrawer_money_out"), FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyOut"]));

            //Init Message
            messageTotalSummary = string.Format("{1}{0}{2}{0}{3}{0}{4}{0}", Environment.NewLine, totalMoneyInCashDrawerOnOpen, totalMoneyInCashDrawer, totalMoneyIn, totalMoneyOut);

            //Get Payments Totals
            try
            {
                XPCollection workSessionPeriodTotal = ProcessWorkSessionPeriod.GetSessionPeriodTotal(pWorkSessionPeriod);
                if (workSessionPeriodTotal.Count > 0)
                {
                    messageTotalSummary += string.Format("{0}{1}{0}", Environment.NewLine, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_total_by_type_of_payment"));
                    foreach (pos_worksessionperiodtotal item in workSessionPeriodTotal)
                    {
                        messageTotalSummary += string.Format("{1}-{2}: {3}{0}", Environment.NewLine, item.PaymentMethod.Acronym, item.PaymentMethod.Designation, FrameworkUtils.DecimalToStringCurrency(item.Total));
                    }
                    workSessionPeriodTotalCount = workSessionPeriodTotal.Count;
                }

                windowHeight = (workSessionPeriodTotalCount > 0) ? windowHeight + ((workSessionPeriodTotalCount + 2) * lineHeight) : windowHeight + lineHeight;

                Utils.ShowMessageTouch(
                    pSourceWindow,
                    DialogFlags.Modal,
                    new Size(600, windowHeight),
                    MessageType.Info,
                    ButtonsType.Close,
                    "Info",
                    string.Format(messageResource, messageTotalSummary)
                    );
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
        }
        public static bool PersistWorkSessionMovement(Session pSession, pos_worksessionperiod pWorkSessionPeriod, pos_worksessionmovementtype pWorkSessionMovementType, fin_documentfinancemaster pDocumentFinanceMaster, fin_documentfinancepayment pDocumentFinancePayment, sys_userdetail pUserDetail, pos_configurationplaceterminal pTerminal, DateTime pDate, decimal pMovementAmount, string pDescription, uint pOrd = 1)
        {
            //Prevent Deleted Objects, Get Fresh Objects
            sys_userdetail userDetail = pSession.GetObjectByKey <sys_userdetail>(GlobalFramework.LoggedUser.Oid);
            pos_configurationplaceterminal terminal = pSession.GetObjectByKey <pos_configurationplaceterminal>(GlobalFramework.LoggedTerminal.Oid);
            pos_worksessionmovementtype    workSessionMovementType = pSession.GetObjectByKey <pos_worksessionmovementtype>(pWorkSessionMovementType.Oid);

            try
            {
                pos_worksessionmovement workSessionMovement = new pos_worksessionmovement(pSession)
                {
                    Ord = pOrd,
                    WorkSessionPeriod       = pWorkSessionPeriod,
                    WorkSessionMovementType = workSessionMovementType,
                    UserDetail     = userDetail,
                    Terminal       = terminal,
                    Date           = pDate,
                    MovementAmount = pMovementAmount,
                    Description    = pDescription
                };
                //Assign parent DocumentFinanceMaster and PaymentMethod
                if (pDocumentFinanceMaster != null)
                {
                    workSessionMovement.DocumentFinanceMaster = pDocumentFinanceMaster;
                    workSessionMovement.DocumentFinanceType   = pDocumentFinanceMaster.DocumentType;
                    workSessionMovement.PaymentMethod         = pDocumentFinanceMaster.PaymentMethod;
                }
                //Assign parent DocumentFinancePayment and PaymentMethod
                if (pDocumentFinancePayment != null)
                {
                    workSessionMovement.DocumentFinancePayment = pDocumentFinancePayment;
                    workSessionMovement.DocumentFinanceType    = pDocumentFinancePayment.DocumentType;
                    workSessionMovement.PaymentMethod          = pDocumentFinancePayment.PaymentMethod;
                }

                //Save WorkSessionMovement if not in UOW
                if (pSession.GetType() == typeof(Session))
                {
                    workSessionMovement.Save();
                }

                return(true);
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
                return(false);
            }
        }
        public ThermalPrinterInternalDocumentWorkSession(sys_configurationprinters pPrinter, pos_worksessionperiod pWorkSessionPeriod, SplitCurrentAccountMode pSplitCurrentAccountMode)
            : base(pPrinter)
        {
            _workSessionPeriod       = pWorkSessionPeriod;
            _splitCurrentAccountMode = pSplitCurrentAccountMode;

            //Define TicketTitle for Day
            if (_workSessionPeriod.PeriodType == WorkSessionPeriodType.Day)
            {
                _ticketTitle = (pWorkSessionPeriod.SessionStatus == WorkSessionPeriodStatus.Open) ? resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "ticket_title_worksession_day_resume") : resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "ticket_title_worksession_day_close");
            }
            //Define TicketTitle/TicketSubTitle for Terminal
            else
            {
                _ticketTitle    = (pWorkSessionPeriod.SessionStatus == WorkSessionPeriodStatus.Open) ? resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "ticket_title_worksession_terminal_resume") : resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "ticket_title_worksession_terminal_close");
                _ticketSubTitle = (pWorkSessionPeriod.PeriodType == WorkSessionPeriodType.Terminal) ? _workSessionPeriod.Terminal.Designation : string.Empty;
            }

            //Add Extra text to TicketSubTitle
            string ticketSubTitleExtra = string.Empty;

            switch (_splitCurrentAccountMode)
            {
            case SplitCurrentAccountMode.All:
                break;

            case SplitCurrentAccountMode.NonCurrentAcount:
                //Nao imprimir sub-titulo para contas não corrente
                ticketSubTitleExtra = "";
                //ticketSubTitleExtra = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_without_current_acount");
                break;

            case SplitCurrentAccountMode.CurrentAcount:
                ticketSubTitleExtra = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_current_account");
                break;
            }

            //Generate Final TicketSubTitle
            if (_ticketSubTitle != string.Empty && ticketSubTitleExtra != string.Empty)
            {
                _ticketSubTitle = string.Format("{0} : ({1})", _ticketSubTitle, ticketSubTitleExtra);
            }
            else if (_ticketSubTitle == string.Empty && ticketSubTitleExtra != string.Empty)
            {
                _ticketSubTitle = string.Format("({0})", ticketSubTitleExtra);
            }
        }
        //XpoMode
        public TreeViewWorkSessionPeriod(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(pos_worksessionperiod);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            pos_worksessionperiod defaultValue = (pDefaultValue != null) ? pDefaultValue as pos_worksessionperiod : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : null;

            //Configure columnProperties
            List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>();

            columnProperties.Add(new GenericTreeViewColumnProperty("Designation")
            {
                Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_designation")
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("DateStart")
            {
                Type = typeof(DateTime), Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_date_start")
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("DateEnd")
            {
                Type = typeof(DateTime), Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_date_end")
            });

            //Configure Criteria/XPCollection/Model
            //CriteriaOperator.Parse("Code >= 100 and Code <= 9999");
            CriteriaOperator criteria = pXpoCriteria;

            SortProperty[] sortProperty = new SortProperty[1];
            sortProperty[0] = new SortProperty("DateStart", SortingDirection.Ascending);
            XPCollection xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria, sortProperty);

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );
        }
Beispiel #7
0
        public static bool SessionPeriodOpen(WorkSessionPeriodType pWorkSessionPeriodType, string pDescription = "")
        {
            try
            {
                string periodType  = (pWorkSessionPeriodType == WorkSessionPeriodType.Day) ? "Day" : "Terminal";
                string description = (pDescription != String.Empty) ? string.Format(" - {0}", pDescription) : String.Empty;
                pos_configurationplaceterminal terminal = GlobalFramework.SessionXpo.GetObjectByKey <pos_configurationplaceterminal>(GlobalFramework.LoggedTerminal.Oid);
                DateTime dateTime = FrameworkUtils.CurrentDateTimeAtomic();

                pos_worksessionperiod workSessionPeriod = new pos_worksessionperiod(GlobalFramework.SessionXpo)
                {
                    PeriodType    = pWorkSessionPeriodType,
                    SessionStatus = WorkSessionPeriodStatus.Open,
                    Designation   = string.Format("{0} - {1}{2}", periodType, dateTime.ToString(SettingsApp.DateTimeFormat), description),
                    DateStart     = dateTime,
                    Terminal      = terminal
                };
                //Assign Parent
                if (pWorkSessionPeriodType == WorkSessionPeriodType.Terminal)
                {
                    workSessionPeriod.Parent = GlobalFramework.SessionXpo.GetObjectByKey <pos_worksessionperiod>(GlobalFramework.WorkSessionPeriodDay.Oid);
                }
                //Persist
                workSessionPeriod.Save();

                if (pWorkSessionPeriodType == WorkSessionPeriodType.Day)
                {
                    GlobalFramework.WorkSessionPeriodDay = workSessionPeriod;
                }
                else
                {
                    GlobalFramework.WorkSessionPeriodTerminal = workSessionPeriod;
                }
                return(true);
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
                return(false);
            }
        }
Beispiel #8
0
        public static string GetSessionPeriodMovementTotalDebug(pos_worksessionperiod pWorkSessionPeriod, bool pOutputToLog)
        {
            string result       = String.Empty;
            string resultDetail = string.Format("WorkSessionPeriod:[{0}] Type:[{1}]", pWorkSessionPeriod.Oid, pWorkSessionPeriod.PeriodType);
            string resultValues = String.Empty;
            string resultFields = String.Empty;

            foreach (MovementTypeTotal typeTotal in Enum.GetValues(typeof(MovementTypeTotal)))
            {
                resultFields += string.Format("{0}\t", typeTotal);
                resultValues += string.Format("{0}\t", GetSessionPeriodMovementTotal(pWorkSessionPeriod, typeTotal).ToString());
            }

            result = string.Format("{0}{1}{2}{3}{4}{5}{6}", Environment.NewLine, resultDetail, Environment.NewLine, resultFields, Environment.NewLine, resultValues, Environment.NewLine);
            if (pOutputToLog)
            {
                _log.Debug(result);
            }

            return(result);
        }
Beispiel #9
0
        private bool UpdateClock()
        {
            if (GlobalApp.WindowPos.Visible)
            {
                _labelClock.Text = FrameworkUtils.CurrentDateTime(_clockFormat);

                //Call Current OrderMain Update Status
                if (GlobalFramework.SessionApp.CurrentOrderMainOid != Guid.Empty && GlobalFramework.SessionApp.OrdersMain.ContainsKey(GlobalFramework.SessionApp.CurrentOrderMainOid))
                {
                    UpdateGUITimer(GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid], _ticketList);
                }

                //Update UI Button and Get WorkSessionPeriodDay if is Opened by Other Terminal
                if (GlobalFramework.WorkSessionPeriodTerminal == null ||
                    (GlobalFramework.WorkSessionPeriodTerminal != null && GlobalFramework.WorkSessionPeriodTerminal.SessionStatus == WorkSessionPeriodStatus.Close))
                {
                    pos_worksessionperiod workSessionPeriodDay = ProcessWorkSessionPeriod.GetSessionPeriod(WorkSessionPeriodType.Day);

                    if (workSessionPeriodDay == null)
                    {
                        GlobalFramework.WorkSessionPeriodDay = null;
                        UpdateWorkSessionUI();
                    }
                    else
                    {
                        if (workSessionPeriodDay.SessionStatus == WorkSessionPeriodStatus.Open)
                        {
                            GlobalFramework.WorkSessionPeriodDay = workSessionPeriodDay;
                            UpdateWorkSessionUI();
                        }
                    }
                }
            }
            // returning true means that the timeout routine should be invoked
            // again after the timeout period expires. Returning false would
            // terminate the timeout.
            return(true);
        }
Beispiel #10
0
        public static Hashtable GetSessionPeriodSummaryDetails(pos_worksessionperiod pWorkSessionPeriod)
        {
            //Get Total Money and TotalMoney Out (NonPayments)
            decimal totalMoneyIn  = ProcessWorkSessionPeriod.GetSessionPeriodMovementTotal(pWorkSessionPeriod, MovementTypeTotal.MoneyIn);
            decimal totalMoneyOut = -ProcessWorkSessionPeriod.GetSessionPeriodMovementTotal(pWorkSessionPeriod, MovementTypeTotal.MoneyOut);

            //Get Total Money in Cash when Open/Close for Day and Terminals
            decimal totalMoneyInCashDrawerOnOpen;
            decimal totalMoneyInCashDrawer;

            if (pWorkSessionPeriod.PeriodType == WorkSessionPeriodType.Day)
            {
                totalMoneyInCashDrawerOnOpen = ProcessWorkSessionPeriod.GetSessionPeriodDayCashDrawerOpenOrCloseAmount(pWorkSessionPeriod, true);
                totalMoneyInCashDrawer       = ProcessWorkSessionPeriod.GetSessionPeriodDayCashDrawerOpenOrCloseAmount(pWorkSessionPeriod, false);
            }
            else
            {
                totalMoneyInCashDrawerOnOpen = ProcessWorkSessionPeriod.GetSessionPeriodCashDrawerOpenOrCloseAmount(pWorkSessionPeriod, "CASHDRAWER_OPEN");
                //Get Total in CashDrawer On Close or on Working: Using latest CASHDRAWER_CLOSE get from terminal method if Terminal Session
                if (pWorkSessionPeriod.SessionStatus == WorkSessionPeriodStatus.Close)
                {
                    totalMoneyInCashDrawer = ProcessWorkSessionPeriod.GetSessionPeriodCashDrawerOpenOrCloseAmount(pWorkSessionPeriod, "CASHDRAWER_CLOSE");
                }
                else
                {
                    totalMoneyInCashDrawer = ProcessWorkSessionPeriod.GetSessionPeriodMovementTotal(pWorkSessionPeriod, MovementTypeTotal.MoneyInCashDrawer);
                }
            }

            Hashtable resultHashTable = new Hashtable();

            resultHashTable.Add("totalMoneyInCashDrawerOnOpen", totalMoneyInCashDrawerOnOpen);
            resultHashTable.Add("totalMoneyInCashDrawer", totalMoneyInCashDrawer);
            resultHashTable.Add("totalMoneyIn", totalMoneyIn);
            resultHashTable.Add("totalMoneyOut", totalMoneyOut);

            return(resultHashTable);
        }
Beispiel #11
0
        /// <summary>
        /// Close WorkSessionPeriod, work in all PeriodTypes Day and Terminal
        /// </summary>
        /// <param name="pWorkSessionPeriod"></param>
        public static bool SessionPeriodClose(pos_worksessionperiod pWorkSessionPeriod)
        {
            bool result = false;

            //Store Totals first, with a UOF, Error return without close session, we process error outside
            bool resultPersistTotals = ProcessWorkSessionPeriod.PersistWorkSessionTotals(pWorkSessionPeriod);

            if (resultPersistTotals)
            {
                try
                {
                    pos_worksessionperiod workSessionPeriod = GlobalFramework.SessionXpo.GetObjectByKey <pos_worksessionperiod>(pWorkSessionPeriod.Oid);
                    DateTime dateTime = FrameworkUtils.CurrentDateTimeAtomic();
                    workSessionPeriod.DateEnd       = dateTime;
                    workSessionPeriod.SessionStatus = WorkSessionPeriodStatus.Close;
                    workSessionPeriod.Save();

                    //Assign to Singleton
                    if (workSessionPeriod.PeriodType == WorkSessionPeriodType.Day)
                    {
                        GlobalFramework.WorkSessionPeriodDay = workSessionPeriod;
                    }
                    else
                    {
                        GlobalFramework.WorkSessionPeriodTerminal = workSessionPeriod;
                    }

                    result = true;
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                }
            }
            return(result);
        }
Beispiel #12
0
        /// <summary>
        /// Get Last CASHDRAWER_OPEN/CASHDRAWER_CLOSE Value, Required WorkSessionPeriod, to Re-Print Sessions from Other Terminals, do not use GlobalFramework.LoggedTerminal.Oid
        /// </summary>
        public static decimal GetSessionPeriodTerminalCashDrawerOpenOrCloseAmount(Session pSession, pos_worksessionperiod pWorkSessionPeriod, String pMoventTypeToken)
        {
            //If Has a Valid pWorkSessionPeriod get Terminal from it, else use logged Terminal
            Guid whereTerminalGuid = (pWorkSessionPeriod != null) ? pWorkSessionPeriod.Terminal.Oid : GlobalFramework.LoggedTerminal.Oid;

            //Required, CASHDRAWER_OPEN always comes from WorkSessionPeriod, and CASHDRAWER_CLOSE comes from latest cash close record (DESC)
            string whereOpen = (pMoventTypeToken == "CASHDRAWER_OPEN") ? string.Format(" AND wspPeriod = '{0}'", pWorkSessionPeriod.Oid) : String.Empty;

            string sql = string.Format(@"
                SELECT 
                    wsmMovementAmount  
                FROM 
                    view_worksessionmovement
                WHERE 
                    (cptTerminal = '{0}' AND wmtMovementTypeToken = '{1}'{2}) 
                ORDER BY 
                    wsmDate DESC;"
                                       , whereTerminalGuid
                                       , pMoventTypeToken
                                       , whereOpen
                                       );

            decimal resultAmount = Convert.ToDecimal(pSession.ExecuteScalar(sql));

            //_log.Debug(string.Format("pMoventTypeToken sql: [{0}]", sql));

            return(resultAmount);
        }
 //Main Method  - With and Without Session
 public static bool PersistWorkSessionMovement(pos_worksessionperiod pWorkSessionPeriod, pos_worksessionmovementtype pWorkSessionMovementType, fin_documentfinancemaster pDocumentFinanceMaster, fin_documentfinancepayment pDocumentFinancePayment, sys_userdetail pUserDetail, pos_configurationplaceterminal pTerminal, DateTime pDate, decimal pMovementAmount, string pDescription, uint pOrd = 1)
 {
     return(PersistWorkSessionMovement(GlobalFramework.SessionXpo, pWorkSessionPeriod, pWorkSessionMovementType, pDocumentFinanceMaster, pDocumentFinancePayment, pUserDetail, pTerminal, pDate, pMovementAmount, pDescription));
 }
Beispiel #14
0
 public static XPCollection GetSessionPeriodTotal(pos_worksessionperiod pWorkSessionPeriod)
 {
     return(GetSessionPeriodTotal(GlobalFramework.SessionXpo, pWorkSessionPeriod));
 }
        public bool PrintWorkSessionMovement(sys_configurationprinters pPrinter, pos_worksessionperiod pWorkSessionPeriod, SplitCurrentAccountMode pSplitCurrentAccountMode)
        {
            bool result = false;

            if (pPrinter != null)
            {
                sys_configurationprinters          printer  = pPrinter;
                sys_configurationprinterstemplates template = (sys_configurationprinterstemplates)FrameworkUtils.GetXPGuidObject(typeof(sys_configurationprinterstemplates), SettingsApp.XpoOidConfigurationPrintersTemplateWorkSessionMovement);
                string splitCurrentAccountFilter            = string.Empty;
                string fileTicket = template.FileTemplate;

                switch (pSplitCurrentAccountMode)
                {
                case SplitCurrentAccountMode.All:
                    break;

                case SplitCurrentAccountMode.NonCurrentAcount:
                    //Diferent from DocumentType CC
                    splitCurrentAccountFilter = string.Format("AND DocumentType <> '{0}'", SettingsApp.XpoOidDocumentFinanceTypeCurrentAccountInput);
                    break;

                case SplitCurrentAccountMode.CurrentAcount:
                    //Only DocumentType CC
                    splitCurrentAccountFilter = string.Format("AND DocumentType = '{0}'", SettingsApp.XpoOidDocumentFinanceTypeCurrentAccountInput);
                    break;
                }

                try
                {
                    //Shared Where for details and totals Queries
                    string sqlWhere = string.Empty;

                    if (pWorkSessionPeriod.PeriodType == WorkSessionPeriodType.Day)
                    {
                        sqlWhere = string.Format("PeriodParent = '{0}'{1}", pWorkSessionPeriod.Oid, splitCurrentAccountFilter);
                    }
                    else
                    {
                        sqlWhere = string.Format("Period = '{0}'{1}", pWorkSessionPeriod.Oid, splitCurrentAccountFilter);
                    }

                    //Shared for Both Modes
                    if (sqlWhere != string.Empty)
                    {
                        sqlWhere = string.Format(" AND {0}", sqlWhere);
                    }

                    //Format to Display Vars
                    string dateCloseDisplay = (pWorkSessionPeriod.SessionStatus == WorkSessionPeriodStatus.Open) ? resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_in_progress") : pWorkSessionPeriod.DateEnd.ToString(SettingsApp.DateTimeFormat);

                    //Get Session Period Details
                    Hashtable resultHashTable = ProcessWorkSessionPeriod.GetSessionPeriodSummaryDetails(pWorkSessionPeriod);

                    //Print Header Summary
                    DataRow   dataRow   = null;
                    DataTable dataTable = new DataTable();
                    dataTable.Columns.Add(new DataColumn("Label", typeof(string)));
                    dataTable.Columns.Add(new DataColumn("Value", typeof(string)));
                    //Open DateTime
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_open_datetime"));
                    dataRow[1] = pWorkSessionPeriod.DateStart.ToString(SettingsApp.DateTimeFormat);
                    dataTable.Rows.Add(dataRow);
                    //Close DataTime
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_close_datetime"));
                    dataRow[1] = dateCloseDisplay;
                    dataTable.Rows.Add(dataRow);
                    //Open Total CashDrawer
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_open_total_cashdrawer"));
                    dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyInCashDrawerOnOpen"]);
                    dataTable.Rows.Add(dataRow);
                    //Close Total CashDrawer
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_close_total_cashdrawer"));
                    dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyInCashDrawer"]);
                    dataTable.Rows.Add(dataRow);
                    //Total Money In
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_total_money_in"));
                    dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyIn"]);
                    dataTable.Rows.Add(dataRow);
                    //Total Money Out
                    dataRow    = dataTable.NewRow();
                    dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_total_money_out"));
                    dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyOut"]);
                    dataTable.Rows.Add(dataRow);
                    //Configure Ticket Column Properties
                    List <TicketColumn> columns = new List <TicketColumn>();
                    columns.Add(new TicketColumn("Label", "", Convert.ToInt16(_maxCharsPerLineNormal / 2) - 2, TicketColumnsAlign.Right));
                    columns.Add(new TicketColumn("Value", "", Convert.ToInt16(_maxCharsPerLineNormal / 2) - 2, TicketColumnsAlign.Left));
                    TicketTable ticketTable = new TicketTable(dataTable, columns, _thermalPrinterGeneric.MaxCharsPerLineNormalBold);
                    //Print Ticket Table
                    ticketTable.Print(_thermalPrinterGeneric);
                    //Line Feed
                    _thermalPrinterGeneric.LineFeed();

                    //Get Final Rendered DataTable Groups
                    Dictionary <DataTableGroupPropertiesType, DataTableGroupProperties> dictGroupProperties = GenDataTableWorkSessionMovementResume(pWorkSessionPeriod.PeriodType, pSplitCurrentAccountMode, sqlWhere);

                    //Prepare Local vars for Group Loop
                    XPSelectData xPSelectData = null;
                    string       designation  = string.Empty;
                    decimal      quantity     = 0.0m;
                    decimal      total        = 0.0m;
                    string       unitMeasure  = string.Empty;
                    //Store Final Totals
                    decimal summaryTotalQuantity = 0.0m;
                    decimal summaryTotal         = 0.0m;
                    //Used to Custom Print Table Ticket Rows
                    List <string> tableCustomPrint = new List <string>();

                    //Start to process Group
                    int groupPosition = -1;
                    //Assign Position to Print Payment Group Split Title
                    int groupPositionTitlePayments = (pWorkSessionPeriod.PeriodType == WorkSessionPeriodType.Day) ? 9 : 8;
                    //If CurrentAccount Mode decrease 1, it dont have PaymentMethods
                    if (pSplitCurrentAccountMode == SplitCurrentAccountMode.CurrentAcount)
                    {
                        groupPositionTitlePayments--;
                    }


                    foreach (KeyValuePair <DataTableGroupPropertiesType, DataTableGroupProperties> item in dictGroupProperties)
                    //foreach (DataTableGroupProperties item in dictGroupProperties.Values)
                    {
                        if (item.Value.Enabled)
                        {
                            //Increment Group Position
                            groupPosition++;

                            //Print Group Titles (FinanceDocuments|Payments)
                            if (groupPosition == 0)
                            {
                                _thermalPrinterGeneric.WriteLine(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_resume_finance_documents"), WriteLineTextMode.Big);
                                _thermalPrinterGeneric.LineFeed();
                            }
                            else if (groupPosition == groupPositionTitlePayments)
                            {
                                //When finish FinanceDocuemnts groups, print Last Row, the Summary Totals Row
                                _thermalPrinterGeneric.WriteLine(tableCustomPrint[tableCustomPrint.Count - 1], WriteLineTextMode.DoubleHeight);
                                _thermalPrinterGeneric.LineFeed();

                                _thermalPrinterGeneric.WriteLine(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_resume_paymens_documents"), WriteLineTextMode.Big);
                                _thermalPrinterGeneric.LineFeed();
                            }

                            //Reset Totals
                            summaryTotalQuantity = 0.0m;
                            summaryTotal         = 0.0m;

                            //Get Group Data from group Query
                            xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(item.Value.Sql);

                            //Generate Columns
                            columns = new List <TicketColumn>();
                            columns.Add(new TicketColumn("GroupTitle", item.Value.Title, 0, TicketColumnsAlign.Left));
                            columns.Add(new TicketColumn("Quantity", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_quantity_acronym"), 8, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}"));
                            //columns.Add(new TicketColumn("UnitMeasure", string.Empty, 3));
                            columns.Add(new TicketColumn("Total", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_totalfinal_acronym"), 10, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}"));

                            //Init DataTable
                            dataTable = new DataTable();
                            dataTable.Columns.Add(new DataColumn("GroupDesignation", typeof(string)));
                            dataTable.Columns.Add(new DataColumn("Quantity", typeof(decimal)));
                            //dataTable.Columns.Add(new DataColumn("UnitMeasure", typeof(string)));
                            dataTable.Columns.Add(new DataColumn("Total", typeof(decimal)));

                            //If Has data
                            if (xPSelectData.Data.Length > 0)
                            {
                                foreach (SelectStatementResultRow row in xPSelectData.Data)
                                {
                                    designation = Convert.ToString(row.Values[xPSelectData.GetFieldIndex("Designation")]);
                                    quantity    = Convert.ToDecimal(row.Values[xPSelectData.GetFieldIndex("Quantity")]);
                                    unitMeasure = Convert.ToString(row.Values[xPSelectData.GetFieldIndex("UnitMeasure")]);
                                    total       = Convert.ToDecimal(row.Values[xPSelectData.GetFieldIndex("Total")]);
                                    // Override Encrypted values
                                    if (GlobalFramework.PluginSoftwareVendor != null && item.Key.Equals(DataTableGroupPropertiesType.DocumentsUser) || item.Key.Equals(DataTableGroupPropertiesType.PaymentsUser))
                                    {
                                        designation = GlobalFramework.PluginSoftwareVendor.Decrypt(designation);
                                    }
                                    //Sum Summary Totals
                                    summaryTotalQuantity += quantity;
                                    summaryTotal         += total;
                                    //_log.Debug(string.Format("Designation: [{0}], quantity: [{1}], unitMeasure: [{2}], total: [{3}]", designation, quantity, unitMeasure, total));
                                    //Create Row
                                    dataRow    = dataTable.NewRow();
                                    dataRow[0] = designation;
                                    dataRow[1] = quantity;
                                    //dataRow[2] = unitMeasure;
                                    dataRow[2] = total;
                                    dataTable.Rows.Add(dataRow);
                                }
                            }
                            else
                            {
                                //Create Row
                                dataRow    = dataTable.NewRow();
                                dataRow[0] = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_cashdrawer_without_movements");
                                dataRow[1] = 0.0m;
                                //dataRow[2] = string.Empty;//UnitMeasure
                                dataRow[2] = 0.0m;
                                dataTable.Rows.Add(dataRow);
                            }

                            //Add Final Summary Row
                            dataRow    = dataTable.NewRow();
                            dataRow[0] = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_total");
                            dataRow[1] = summaryTotalQuantity;
                            //dataRow[2] = string.Empty;
                            dataRow[2] = summaryTotal;
                            dataTable.Rows.Add(dataRow);

                            //Prepare TicketTable
                            ticketTable = new TicketTable(dataTable, columns, _thermalPrinterGeneric.MaxCharsPerLineNormal);

                            //Custom Print Loop, to Print all Table Rows, and Detect Rows to Print in DoubleHeight (Title and Total)
                            tableCustomPrint = ticketTable.GetTable();
                            WriteLineTextMode rowTextMode;

                            //Dynamic Print All except Last One (Totals), Double Height in Titles
                            for (int i = 0; i < tableCustomPrint.Count - 1; i++)
                            {
                                //Prepare TextMode Based on Row
                                rowTextMode = (i == 0) ? WriteLineTextMode.DoubleHeight : WriteLineTextMode.Normal;
                                //Print Row
                                _thermalPrinterGeneric.WriteLine(tableCustomPrint[i], rowTextMode);
                            }

                            //Line Feed
                            _thermalPrinterGeneric.LineFeed();
                        }
                    }

                    //When finish all groups, print Last Row, the Summary Totals Row, Ommited in Custom Print Loop
                    _thermalPrinterGeneric.WriteLine(tableCustomPrint[tableCustomPrint.Count - 1], WriteLineTextMode.DoubleHeight);

                    result = true;
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                    throw new Exception(ex.Message);
                }
            }

            return(result);
        }
Beispiel #16
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //PrintWorkSessionMovement

        public static bool PrintWorkSessionMovement(Window pSourceWindow, sys_configurationprinters pPrinter, pos_worksessionperiod pWorkSessionPeriod)
        {
            bool result = false;
            sys_configurationprinterstemplates template = (sys_configurationprinterstemplates)FrameworkUtils.GetXPGuidObject(typeof(sys_configurationprinterstemplates), SettingsApp.XpoOidConfigurationPrintersTemplateWorkSessionMovement);

            try
            {
                if (SharedPrintTicket(pSourceWindow, pPrinter, TicketType.WorkSession))
                {
                    //PrintWorkSessionMovement
                    result = PrintRouter.PrintWorkSessionMovement(pPrinter, pWorkSessionPeriod);
                }
            }
            catch (Exception ex)
            {
                Utils.ShowMessageTouchErrorPrintingTicket(pSourceWindow, pPrinter, ex);
            }

            return(result);
        }
Beispiel #17
0
        private Dictionary <string, AccordionNode> GetAccordionDefinition()
        {
            _log.Debug("GetAccordionDefinition Begin");

            //Init accordionDefinition
            Dictionary <string, AccordionNode> accordionDefinition = null;

            try
            {
                accordionDefinition = new Dictionary <string, AccordionNode>();
                Widget startContent;

                //Define Start Content for backoffice mode
                _dashboardButton.Content = Utils.GetGenericTreeViewXPO <DashBoard>(this);
                startContent             = Utils.GetGenericTreeViewXPO <DashBoard>(this);
                //_labelActiveContent.Text = "DASHBOARD";

                ////Define Start Content with Articles TreeView
                //else
                //{
                //    startContent = Utils.GetGenericTreeViewXPO<TreeViewArticle>(this);
                //    //Hide/Show Current Active Content based on user privileges
                //    string currentNodePrivilegesToken = string.Format(_privilegesBackOfficeMenuOperation, "Article".ToUpper());
                //    startContent.Sensitive = FrameworkUtils.HasPermissionTo(currentNodePrivilegesToken);
                //    _labelActiveContent.Text = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_articles");
                //}


                _nodeContent = startContent;

                _hboxContent.PackEnd(_nodeContent);

                //Define used CriteriaOperators/Override Defaults from TreeViews
                CriteriaOperator criteriaOperatorCustomer = CriteriaOperator.Parse("(Disabled IS NULL OR Disabled  <> 1) AND (Hidden IS NULL OR Hidden = 0)");
                CriteriaOperator criteriaConfigurationPreferenceParameterCompany = CriteriaOperator.Parse("(Disabled IS NULL OR Disabled  <> 1) AND (Token <> 'COMPANY_COUNTRY_OID' AND Token <> 'SYSTEM_CURRENCY_OID' AND FormType = 1)");
                CriteriaOperator criteriaConfigurationPreferenceParameterSystem  = CriteriaOperator.Parse("(Disabled IS NULL OR Disabled  <> 1) AND (FormType = 2)");

                //START WORK SESSION AND DAY FOR BACKOFFICE MODE
                if (GlobalFramework.AppUseBackOfficeMode)
                {
                    bool openDay = ProcessWorkSessionPeriod.SessionPeriodOpen(WorkSessionPeriodType.Day, "");
                    if (openDay)
                    {
                        pos_worksessionperiod workSessionPeriodDay = ProcessWorkSessionPeriod.GetSessionPeriod(WorkSessionPeriodType.Day);
                        GlobalFramework.WorkSessionPeriodTerminal = ProcessWorkSessionPeriod.GetSessionPeriod(WorkSessionPeriodType.Day);
                        GlobalFramework.WorkSessionPeriodTerminal.SessionStatus = WorkSessionPeriodStatus.Open;
                    }
                }

                ////TK016235 BackOffice - Mode - Finance Documents for backoffice mode
                Dictionary <string, AccordionNode> _accordionChildDocuments = new Dictionary <string, AccordionNode>();
                _accordionChildDocuments.Add("DocumentsNew", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_button_label_new_finance_documents"))
                {
                    Clicked = delegate { Utils.startNewDocumentFromBackOffice(this); }
                });
                _accordionChildDocuments.Add("DocumentsShow", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_button_label_select_record_finance_documents"))
                {
                    Clicked = delegate { Utils.startDocumentsMenuFromBackOffice(this, 1); }
                });
                _accordionChildDocuments.Add("DocumentsPay", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_button_label_select_finance_documents_ft_unpaid"))
                {
                    Clicked = delegate { Utils.startDocumentsMenuFromBackOffice(this, 2); }
                });
                _accordionChildDocuments.Add("DocumentsPayments", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_button_label_select_payments"))
                {
                    Clicked = delegate { Utils.startDocumentsMenuFromBackOffice(this, 3); }
                });
                _accordionChildDocuments.Add("DocumentsCurrentAccount", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_button_label_select_finance_documents_cc"))
                {
                    Clicked = delegate { Utils.startDocumentsMenuFromBackOffice(this, 4); }
                });
                //_accordionChildDocuments.Add("DocumentsListall", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_resume_finance_documents")) {  Content = Utils.GetGenericTreeViewXPO<DashBoard>(this) }); ;
                Utils util = new Utils();
                util._accordionChildDocumentsTemp = _accordionChildDocuments;
                Dictionary <string, AccordionNode> _accordionChildReports = new Dictionary <string, AccordionNode>();
                _accordionChildReports.Add("DocumentsReports", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_reports"))
                {
                    Clicked = delegate { Utils.startReportsMenuFromBackOffice(this); }
                });

                //Articles
                Dictionary <string, AccordionNode> _accordionChildArticles = new Dictionary <string, AccordionNode>();
                //, Clicked = testClickedEventHandlerFromOutside }
                _accordionChildArticles.Add("ArticleFamily", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_families"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewArticleFamily>(this)
                });;
                _accordionChildArticles.Add("ArticleSubFamily", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_subfamilies"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewArticleSubFamily>(this)
                });
                _accordionChildArticles.Add("Article", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_articles"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewArticle>(this)
                });
                _accordionChildArticles.Add("ArticleType", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_article_types"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewArticleType>(this)
                });
                _accordionChildArticles.Add("ArticleClass", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_article_class"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewArticleClass>(this)
                });
                _accordionChildArticles.Add("ConfigurationPriceType", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_price_type"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPriceType>(this)
                });
                Utils.startTreeViewFromBackOffice(_accordionChildArticles);
                // Disable to Speed uo Opening BO, noew we have Stock Reports
                //_accordionChildArticles.Add("ArticleStock", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_stock_movements) { Content = Utils.GetGenericTreeViewXPO<TreeViewArticleStock>(this) });

                //Customers
                Dictionary <string, AccordionNode> _accordionChildCustomers = new Dictionary <string, AccordionNode>();
                _accordionChildCustomers.Add("Customer", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_customers"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewCustomer>(this, criteriaOperatorCustomer)
                });
                _accordionChildCustomers.Add("CustomerType", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_customer_types"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewCustomerType>(this)
                });
                _accordionChildCustomers.Add("CustomerDiscountGroup", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_customer_discount_groups"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewCustomerDiscountGroup>(this)
                });

                //Users
                Dictionary <string, AccordionNode> _accordionChildUsers = new Dictionary <string, AccordionNode>();
                _accordionChildUsers.Add("UserDetail", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_users"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewUser>(this)
                });
                //Commented by Mario: Not Usefull, UserPermissionProfile has same funtionality
                //_accordionChildUsers.Add("UserProfile", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_profile) { Content = Utils.GetGenericTreeViewXPO<TreeViewUserProfile>(this) });
                //WARNING: Works with diferent constructs, its still need to be improved : new TreeViewUserProfilePermissions(this)
                _accordionChildUsers.Add("UserPermissionProfile", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_user_permissions"))
                {
                    Content = new TreeViewUserProfilePermissions(this)
                });
                _accordionChildUsers.Add("UserCommissionGroup", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_user_commission_groups"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewUserCommissionGroup>(this)
                });
                //Moved to Custom Toolbar
                //_accordionChildUsers.Add("System_ApplyPrivileges", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_user_apply_privileges) { Clicked = delegate { Accordion.UpdateMenuPrivileges(); } });

                //Documents
                Dictionary <string, AccordionNode> _accordionDocuments = new Dictionary <string, AccordionNode>();
                _accordionDocuments.Add("DocumentFinanceYears", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documentfinance_years"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewDocumentFinanceYears>(this)
                });
                _accordionDocuments.Add("DocumentFinanceSeries", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documentfinance_series"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewDocumentFinanceSeries>(this)
                });
                _accordionDocuments.Add("DocumentFinanceType", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documentfinance_type"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewDocumentFinanceType>(this)
                });
                //_accordionDocuments.Add("DocumentFinanceYearSerieTerminal", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documentfinance_yearsseriesterminal) { Content = Utils.GetGenericTreeViewXPO<TreeViewDocumentFinanceYearSerieTerminal>(this) });
                _accordionDocuments.Add("ConfigurationVatRate", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_vat_rates"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationVatRate>(this)
                });
                _accordionDocuments.Add("ConfigurationVatExemptionReason", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_vat_exemption_reason"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationVatExceptionReason>(this)
                });
                _accordionDocuments.Add("ConfigurationPaymentCondition", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_payment_conditions"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPaymentCondition>(this)
                });
                _accordionDocuments.Add("ConfigurationPaymentMethod", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_payment_methods"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPaymentMethod>(this)
                });

                //AuxiliarTables
                Dictionary <string, AccordionNode> _accordionChildAuxiliarTables = new Dictionary <string, AccordionNode>();
                //_accordionChildAuxiliarTables.Add("ConfigurationCashRegister", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_cash_registers) { Content = Utils.GetGenericTreeView<TreeViewConfigurationCashRegister>(this) });
                _accordionChildAuxiliarTables.Add("ConfigurationCountry", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_country"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationCountry>(this)
                });
                _accordionChildAuxiliarTables.Add("ConfigurationCurrency", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_ConfigurationCurrency"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationCurrency>(this)
                });
                //_accordionChildAuxiliarTables.Add("ConfigurationDevice", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_devices) { Content = Utils.GetGenericTreeView<TreeViewConfigurationDevice>(this) });
                //_accordionChildAuxiliarTables.Add("ConfigurationKeyboard", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_keyboards) { Content = Utils.GetGenericTreeView<TreeViewConfigurationKeyboard>(this) });
                //_accordionChildAuxiliarTables.Add("ConfigurationMaintenance", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_maintenance) { Content = Utils.GetGenericTreeView<TreeViewConfigurationMaintenance>(this) });
                _accordionChildAuxiliarTables.Add("ConfigurationPlace", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_places"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPlace>(this)
                });
                /* IN009035 */
                string configurationPlaceTableLabel = SettingsApp.IsDefaultTheme ? resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_place_tables") : resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_orders");
                _accordionChildAuxiliarTables.Add("ConfigurationPlaceTable", new AccordionNode(configurationPlaceTableLabel)
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPlaceTable>(this)
                });
                _accordionChildAuxiliarTables.Add("ConfigurationPlaceMovementType", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_places_movement_type"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPlaceMovementType>(this)
                });
                _accordionChildAuxiliarTables.Add("ConfigurationUnitMeasure", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_units_measure"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationUnitMeasure>(this)
                });
                _accordionChildAuxiliarTables.Add("ConfigurationUnitSize", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_units_size"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationUnitSize>(this)
                });
                _accordionChildAuxiliarTables.Add("ConfigurationHolidays", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_holidays"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationHolidays>(this)
                });

                //Devices
                Dictionary <string, AccordionNode> _accordionDevices = new Dictionary <string, AccordionNode>();
                _accordionDevices.Add("ConfigurationPrintersType", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_ConfigurationPrintersType"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPrintersType>(this)
                });
                _accordionDevices.Add("ConfigurationPrinters", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_ConfigurationPrinters"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPrinters>(this)
                });
                _accordionDevices.Add("ConfigurationInputReader", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_ConfigurationInputReader"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationInputReader>(this)
                });
                _accordionDevices.Add("ConfigurationPoleDisplay", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_ConfigurationPoleDisplay"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPoleDisplay>(this)
                });
                _accordionDevices.Add("ConfigurationWeighingMachine", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_ConfigurationWeighingMachine"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationWeighingMachine>(this)
                });
                // Deprecated
                //_accordionPrinters.Add("ConfigurationPrintersTemplates", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_ConfigurationPrintersTemplates) { Content = Utils.GetGenericTreeViewXPO<TreeViewConfigurationPrintersTemplates>(this) });
                //_accordionPrinters.Add("ExternalApp_Composer", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_callposcomposer) { Content = null, ExternalAppFileName = SettingsApp.ExecutableComposer });

                //Configuration
                Dictionary <string, AccordionNode> _accordionChildConfiguration = new Dictionary <string, AccordionNode>();
                _accordionChildConfiguration.Add("ConfigurationPreferenceParameterCompany", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_preferenceparameter_company"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPreferenceParameter>(this, criteriaConfigurationPreferenceParameterCompany)
                });
                _accordionChildConfiguration.Add("ConfigurationPreferenceParameterSystem", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_preferenceparameter_system"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPreferenceParameter>(this, criteriaConfigurationPreferenceParameterSystem)
                });
                _accordionChildConfiguration.Add("ConfigurationPlaceTerminal", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_places_terminals"))
                {
                    Content = Utils.GetGenericTreeViewXPO <TreeViewConfigurationPlaceTerminal>(this)
                });


                //import
                Dictionary <string, AccordionNode> _accordionChildImport = new Dictionary <string, AccordionNode>();
                _accordionChildImport.Add("System_Import_Articles", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_import_articles"))
                {
                    Clicked = delegate { ExcelProcessing.OpenFilePicker(this, ImportExportFileOpen.OpenExcelArticles); }
                });
                _accordionChildImport.Add("System_Import_Costumers", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_import_costumers"))
                {
                    Clicked = delegate { ExcelProcessing.OpenFilePicker(this, ImportExportFileOpen.OpenExcelCostumers); }
                });


                // Add Menu Items Based On Plugins PluginSoftwareVendor
                Dictionary <string, AccordionNode> _accordionChildExport = new Dictionary <string, AccordionNode>();
                //Export
                if (GlobalFramework.PluginSoftwareVendor != null && SettingsApp.ConfigurationSystemCountry.Oid == SettingsApp.XpoOidConfigurationCountryPortugal)
                {
                    _accordionChildExport.Add("System_ExportSaftPT_SaftPt", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_export_saftpt_whole_year"))
                    {
                        Clicked = delegate { FrameworkCalls.ExportSaftPt(this, ExportSaftPtMode.WholeYear); }
                    });
                    _accordionChildExport.Add("System_ExportSaftPT_E-Fatura", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_export_saftpt_last_month"))
                    {
                        Clicked = delegate { FrameworkCalls.ExportSaftPt(this, ExportSaftPtMode.LastMonth); }
                    });
                    _accordionChildExport.Add("System_ExportSaftPT_Custom", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_export_saftpt_custom"))
                    {
                        Clicked = delegate { FrameworkCalls.ExportSaftPt(this, ExportSaftPtMode.Custom); }
                    });
                }
                _accordionChildExport.Add("System_Export_Articles", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_export_articles"))
                {
                    Clicked = delegate { ExcelProcessing.OpenFilePicker(this, ImportExportFileOpen.ExportArticles); }
                });
                _accordionChildExport.Add("System_Export_Costumers", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_export_costumers"))
                {
                    Clicked = delegate { ExcelProcessing.OpenFilePicker(this, ImportExportFileOpen.ExportCustomers); }
                });
                //System
                Dictionary <string, AccordionNode> _accordionChildSystem = new Dictionary <string, AccordionNode>();
                /* IN006001 - "System" > "Notification" menu option */
                _accordionChildSystem.Add("System_Notification", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_notification"))
                {
                    Clicked = delegate { Utils.ShowNotifications(this, true); }
                });
                // Add Menu Items Based On Plugins PluginSoftwareVendor
                if (GlobalFramework.PluginSoftwareVendor != null)
                {
                    _accordionChildSystem.Add("System_DataBaseBackup", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_database_backup"))
                    {
                        Clicked = delegate { DataBaseBackup.Backup(this); }
                    });
                    _accordionChildSystem.Add("System_DataBaseRestore_FromSystem", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_database_restore"))
                    {
                        Clicked = delegate { DataBaseBackup.Restore(this, DataBaseRestoreFrom.SystemBackup); }
                    });
                    _accordionChildSystem.Add("System_DataBaseRestore_FromFile", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_database_restore_from_file"))
                    {
                        Clicked = delegate { DataBaseBackup.Restore(this, DataBaseRestoreFrom.ChooseFromFilePickerDialog); }
                    });
                }
                _accordionChildSystem.Add("System_Menu", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_application_logout_user"))
                {
                    Clicked = ClickedSystemLogout
                });
                //                _accordionChildSystem.Add("System_Pos", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_pos) { Clicked = ClickedSystemPos });
                //_accordionChildSystem.Add("System_Quit", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_quit")) { Clicked = delegate { LogicPos.Quit(this); } });

                //Compose Main Accordion Parent Buttons
                //TK016235 BackOffice - Mode
                if (GlobalFramework.AppUseBackOfficeMode)
                {
                    accordionDefinition.Add("TopMenuFinanceDocuments", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_button_label_select_record_finance_documents"))
                    {
                        Childs = _accordionChildDocuments, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_documentos.png")
                    });
                }
                accordionDefinition.Add("TopMenuArticles", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_articles"))
                {
                    Childs = _accordionChildArticles, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_artigos.png")
                });
                accordionDefinition.Add("TopMenuDocuments", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documents"))
                {
                    Childs = _accordionDocuments, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_informacao_fiscal.png")
                });
                accordionDefinition.Add("TopMenuCustomers", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_customers"))
                {
                    Childs = _accordionChildCustomers, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_clientes.png")
                });
                accordionDefinition.Add("TopMenuUsers", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_users"))
                {
                    Childs = _accordionChildUsers, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_utilizadores.png")
                });
                accordionDefinition.Add("TopMenuDevices", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_devices"))
                {
                    Childs = _accordionDevices, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_impressoras.png")
                });
                accordionDefinition.Add("TopMenuOtherTables", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_other_tables"))
                {
                    Childs = _accordionChildAuxiliarTables, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_outras_tabelas.png")
                });
                accordionDefinition.Add("TopMenuConfiguration", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_configuration"))
                {
                    Childs = _accordionChildConfiguration, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_configuracao.png")
                });
                //TK016235 BackOffice - Mode
                if (GlobalFramework.AppUseBackOfficeMode)
                {
                    accordionDefinition.Add("TopMenuReports", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_reports"))
                    {
                        Childs = _accordionChildReports, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_relatorios.png")
                    });
                }

                accordionDefinition.Add("TopMenuImport", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_import"))
                {
                    Childs = _accordionChildImport, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_import.png")
                });

                if (_accordionChildExport.Count > 0)
                {
                    accordionDefinition.Add("TopMenuExport", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_export"))
                    {
                        Childs = _accordionChildExport, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_export.png")
                    });
                }
                accordionDefinition.Add("TopMenuSystem", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_system"))
                {
                    Childs = _accordionChildSystem, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_sistema.png")
                });



                //Assets/Images/Icons/Accordion/pos_backoffice_sistema.png
                //Assets/Images/Icons/icon_pos_toolbar_back_office.png
                //TK016235 BackOffice - Mode
                //if (!GlobalFramework.AppUseBackOfficeMode)
                //{
                //    Dictionary<string, AccordionNode> _accordionChildSystemPOSMainWindow = new Dictionary<string, AccordionNode>();
                //    _accordionChildSystemPOSMainWindow.Add("System_Pos", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_pos")) { Clicked = ClickedSystemPos });
                //    accordionDefinition.Add("TopMenuPOSMainWindow", new AccordionNode(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_pos")) { Childs = _accordionChildSystemPOSMainWindow, GroupIcon = new Image("Assets/Images/Icons/Accordion/pos_backoffice_sistema.png") });
                //}
                _log.Debug("GetAccordionDefinition End");
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }

            return(accordionDefinition);
        }
Beispiel #18
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

        public static bool PrintWorkSessionMovement(sys_configurationprinters pPrinter, pos_worksessionperiod pWorkSessionPeriod)
        {
            bool result = false;

            if (pPrinter != null)
            {
                try
                {
                    switch (GetPrinterToken(pPrinter.PrinterType.Token))
                    {
                    //Impressora SINOCAN em ambiente Windows
                    case "THERMAL_PRINTER_WINDOWS":
                    //Impressora SINOCAN em ambiente Linux
                    case "THERMAL_PRINTER_LINUX":
                    //Impressora SINOCAN em ambiente WindowsLinux/Socket
                    case "THERMAL_PRINTER_SOCKET":
                        //NonCurrentAcount
                        ThermalPrinterInternalDocumentWorkSession thermalPrinterInternalDocumentWorkSession = new ThermalPrinterInternalDocumentWorkSession(pPrinter, pWorkSessionPeriod, SplitCurrentAccountMode.NonCurrentAcount);
                        thermalPrinterInternalDocumentWorkSession.Print();
                        //CurrentAcount
                        //Use Config to print this
                        if (Convert.ToBoolean(GlobalFramework.PreferenceParameters["USE_CC_DAILY_TICKET"]))
                        {
                            thermalPrinterInternalDocumentWorkSession = new ThermalPrinterInternalDocumentWorkSession(pPrinter, pWorkSessionPeriod, SplitCurrentAccountMode.CurrentAcount);
                            thermalPrinterInternalDocumentWorkSession.Print();
                        }
                        break;

                    case "GENERIC_PRINTER_WINDOWS":
                        break;

                    case "REPORT_EXPORT_PDF":
                        break;
                    }
                    result = true;
                }
                catch (Exception ex)
                {
                    _log.Warn(ex.Message, ex);
                    throw new Exception(ex.Message);
                }
            }
            return(result);
        }
        public static void Print(sys_configurationprinters pPrinter)
        {
            try
            {
                //Parameters
                pos_worksessionperiod workSessionPeriod = (pos_worksessionperiod)GlobalFramework.SessionXpo.GetObjectByKey(typeof(pos_worksessionperiod), SettingsApp.XpoPrintWorkSessionPeriod);

                //Print WorkSession
                if (workSessionPeriod != null)
                {
                    //Get Filter Field : To filter Day or Terminal
                    string periodField = (workSessionPeriod.PeriodType == WorkSessionPeriodType.Day) ? "wspPeriodParent" : "wspPeriod";

                    string sqlShared = @"
                        SELECT 
                            COUNT(*) as Count
                        FROM 
                            view_worksessionmovement 
                        WHERE
                            (dfmDocument IS NOT NULL AND wmtMovementTypeToken = 'FINANCE_DOCUMENT')  
                            AND {0} = '{1}' 
                            AND wsmDocumentFinanceType {2} '{3}';
                    ";

                    //Generate Queries
                    string sqlNonCurrentAccount = string.Format(sqlShared, periodField, workSessionPeriod.Oid, "<>", SettingsApp.XpoOidDocumentFinanceTypeCurrentAccountInput);
                    string sqlCurrentAccount    = string.Format(sqlShared, periodField, workSessionPeriod.Oid, "=", SettingsApp.XpoOidDocumentFinanceTypeCurrentAccountInput);
                    //Get Queries Results
                    object totRecsNonCurrentAccount = GlobalFramework.SessionXpo.ExecuteScalar(sqlNonCurrentAccount);
                    object totRecsCurrentAccount    = GlobalFramework.SessionXpo.ExecuteScalar(sqlCurrentAccount);
                    //Shared
                    ThermalPrinterInternalDocumentWorkSession thermalPrinterInternalDocumentWorkSession;
                    //Tests
                    bool printSplitCurrentAccountModeNonCurrentAcount = true;
                    bool printSplitCurrentAccountModeCurrentAcount    = true;
                    bool printSplitCurrentAccountModeAll = true;

                    //Test Print Document
                    //Always print NonCurrent Account Movements, even if dont have any Movements, Show zero values
                    if (printSplitCurrentAccountModeNonCurrentAcount)
                    {
                        thermalPrinterInternalDocumentWorkSession = new ThermalPrinterInternalDocumentWorkSession(pPrinter, workSessionPeriod, SplitCurrentAccountMode.NonCurrentAcount);
                        thermalPrinterInternalDocumentWorkSession.Print();
                    }

                    //Test Combine NonCC and CC (All)
                    if (printSplitCurrentAccountModeAll)
                    {
                        thermalPrinterInternalDocumentWorkSession = new ThermalPrinterInternalDocumentWorkSession(pPrinter, workSessionPeriod, SplitCurrentAccountMode.All);
                        thermalPrinterInternalDocumentWorkSession.Print();
                    }

                    //Only Prints Current Account Movements if if Has Movements
                    if (printSplitCurrentAccountModeCurrentAcount && Convert.ToInt16(totRecsCurrentAccount) > 0)
                    {
                        thermalPrinterInternalDocumentWorkSession = new ThermalPrinterInternalDocumentWorkSession(pPrinter, workSessionPeriod, SplitCurrentAccountMode.CurrentAcount);
                        thermalPrinterInternalDocumentWorkSession.Print();
                    }

                    Console.WriteLine("ThermalPrinterInternalDocumentWorkSession Printed");
                }
                else
                {
                    Console.WriteLine("ERROR: ThermalPrinterInternalDocumentWorkSession");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #20
0
        public static bool PersistWorkSessionTotals(pos_worksessionperiod pWorkSessionPeriod)
        {
            try
            {
                //Start UnitOfWork
                using (UnitOfWork uowSession = new UnitOfWork())
                {
                    uint                           paymentMethodOrd   = 0;
                    string                         paymentMethodToken = String.Empty;
                    MovementTypeTotal              movementTypeTotal  = MovementTypeTotal.None;
                    pos_worksessionperiod          workSessionPeriod;
                    fin_configurationpaymentmethod configurationPaymentMethod;
                    pos_worksessionperiodtotal     workSessionPeriodTotal;
                    //Can filter by Day or Terminal type
                    string wherePeriodField = (pWorkSessionPeriod.PeriodType == WorkSessionPeriodType.Terminal) ? "wspPeriod" : "wspPeriodParent";

                    string sql = string.Format(@"
                        SELECT 
                              DISTINCT(cpmPaymentMethodToken) as Token,
                              cpmPaymentMethodOrd as Ord
                        FROM 
                            view_worksessionmovement 
                        WHERE 
                            cpmPaymentMethodToken IS NOT NULL AND {0} = '{1}'
                        ORDER 
                            BY cpmPaymentMethodOrd
                        ;"
                                               , wherePeriodField
                                               , pWorkSessionPeriod.Oid
                                               );

                    XPSelectData xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(uowSession, sql);
                    foreach (SelectStatementResultRow row in xPSelectData.Data)
                    {
                        paymentMethodOrd   = Convert.ToUInt16(row.Values[xPSelectData.GetFieldIndex("Ord")]);
                        paymentMethodToken = row.Values[xPSelectData.GetFieldIndex("Token")].ToString();

                        switch (paymentMethodToken)
                        {
                        case "MONEY":
                            movementTypeTotal = MovementTypeTotal.Money;
                            break;

                        case "BANK_CHECK":
                            movementTypeTotal = MovementTypeTotal.BankCheck;
                            break;

                        case "CASH_MACHINE":
                            movementTypeTotal = MovementTypeTotal.CashMachine;
                            break;

                        case "CREDIT_CARD":
                            movementTypeTotal = MovementTypeTotal.Credit;
                            break;

                        case "VISA":
                            movementTypeTotal = MovementTypeTotal.Visa;
                            break;

                        case "CURRENT_ACCOUNT":
                            movementTypeTotal = MovementTypeTotal.CurrentAccount;
                            break;
                        }

                        if (movementTypeTotal != MovementTypeTotal.None)
                        {
                            //Get XPObjects
                            workSessionPeriod          = uowSession.GetObjectByKey <pos_worksessionperiod>(pWorkSessionPeriod.Oid);
                            configurationPaymentMethod = (fin_configurationpaymentmethod)FrameworkUtils.GetXPGuidObjectFromField(uowSession, typeof(fin_configurationpaymentmethod), "Token", paymentMethodToken);

                            //Persist WorkSessionPeriodTotal
                            workSessionPeriodTotal = new pos_worksessionperiodtotal(uowSession)
                            {
                                Ord           = paymentMethodOrd,
                                PaymentMethod = configurationPaymentMethod,
                                Total         = GetSessionPeriodMovementTotal(workSessionPeriod, movementTypeTotal),
                                Period        = workSessionPeriod
                            };
                        }
                    }
                    ;

                    try
                    {
                        //Commit UOW Changes
                        uowSession.CommitChanges();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        //Rollback
                        uowSession.RollbackTransaction();
                        _log.Error(ex.Message, ex);
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
                return(false);
            }
        }
Beispiel #21
0
        /// <summary>
        /// Get CashDrawer Open Amount for all Used terminals, Required three queries
        /// </summary>
        public static decimal GetSessionPeriodDayCashDrawerOpenOrCloseAmount(pos_worksessionperiod pWorkSessionPeriod, bool pEnableOpenMode)
        {
            decimal result = 0.0m;

            try
            {
                //1) Get Day CASHDRAWER_OPEN Terminals
                string sqlTerminals = string.Format(@"
                    SELECT 
                        DISTINCT(cptTerminal), cptTerminalOrd
                    FROM 
                        view_worksessionmovement 
                    WHERE 
                        wspPeriodParent = '{0}' AND 
                        wmtMovementTypeToken = 'CASHDRAWER_OPEN'
                    ORDER BY 
                        cptTerminalOrd
                ;"
                                                    , pWorkSessionPeriod.Oid
                                                    );
                SelectedData xpoSelectedDataTerminals = GlobalFramework.SessionXpo.ExecuteQuery(sqlTerminals);

                //2) MODE OPEN - GET FIRST CashDrawer Period for WorkSession Day
                //2) MODE CLOSE - GET LAST CashDrawer Period for WorkSession Day
                //2) Diference is orderBy DESC(OPEN) or ASC(CLOSE)
                string        orderBy = (pEnableOpenMode) ? "ASC" : "DESC";
                string        currentTerminal;
                List <string> listPeriod = new List <string>();
                foreach (SelectStatementResultRow item in xpoSelectedDataTerminals.ResultSet[0].Rows)
                {
                    currentTerminal = item.Values[0].ToString();
                    string sqlPeriod = string.Format(@"
                    SELECT 
                        wspPeriod 
                    FROM 
                        view_worksessionmovement 
                    WHERE 
                        wspPeriodParent = '{0}' AND 
                        cptTerminal = '{1}' AND 
                        wmtMovementTypeToken = 'CASHDRAWER_OPEN' 
                    ORDER BY 
                        wsmDate {2}
                    ;"
                                                     , pWorkSessionPeriod.Oid
                                                     , currentTerminal
                                                     , orderBy
                                                     );
                    listPeriod.Add(GlobalFramework.SessionXpo.ExecuteScalar(sqlPeriod).ToString());
                }

                //If dont have periods return 0
                if (listPeriod.Count <= 0)
                {
                    return(0.0m);
                }

                //3) Get CashDrawer Open Amount for all Terminal > Periods
                string sqlCashDrawerAmount = @"
                SELECT 
                    SUM(wsmMovementAmount) as Total 
                FROM 
                    view_worksessionmovement 
                WHERE 
                    (wmtMovementTypeToken = 'CASHDRAWER_OPEN'{0}) {1}
                ";
                //TODO: Remove This After Tests
                //Problems in SQLServer
                //ORDER BY
                //  cptTerminalOrd

                int    i              = 0;
                string wherePeriod    = String.Empty;
                string whereSeparator = String.Empty;
                foreach (string item in listPeriod)
                {
                    whereSeparator = (i > 0) ? " OR " : String.Empty;
                    wherePeriod   += string.Format("{0}wspPeriod = '{1}'", whereSeparator, item);
                    i++;
                }

                //Shared for Both Modes
                wherePeriod = string.Format(" AND ({0})", wherePeriod);
                //Require to Add for OPEN Mode
                string whereClose = (!pEnableOpenMode) ? " OR wmtMovementTypeToken = 'CASHDRAWER_IN' OR wmtMovementTypeToken = 'CASHDRAWER_OUT'" : String.Empty;

                //Final Query
                sqlCashDrawerAmount = string.Format(sqlCashDrawerAmount, whereClose, wherePeriod);
                //_log.Debug(string.Format("sqlCashDrawerAmount: [{0}]", sqlCashDrawerAmount));
                var cashDrawerAmount = GlobalFramework.SessionXpo.ExecuteScalar(sqlCashDrawerAmount);
                result = (cashDrawerAmount != null) ? Convert.ToDecimal(cashDrawerAmount) : 0.0m;
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }

            return(result);
        }
Beispiel #22
0
        void _touchButtonCashDrawer_Clicked(object sender, EventArgs e)
        {
            bool result;

            //ProcessWorkSessionPeriod.GetSessionPeriodMovementTotalDebug(GlobalFramework.WorkSessionPeriodTerminal, true );
            PosCashDrawerDialog dialogCashDrawer = new PosCashDrawerDialog(this, DialogFlags.DestroyWithParent);

            int response = dialogCashDrawer.Run();

            if (response == (int)ResponseType.Ok)
            {
                //Get Fresh XPO Objects, Prevent Deleted Object Bug
                pos_worksessionperiod workSessionPeriodDay = GlobalFramework.SessionXpo.GetObjectByKey <pos_worksessionperiod>(GlobalFramework.WorkSessionPeriodDay.Oid);
                pos_worksessionperiod workSessionPeriodTerminal;

                switch (dialogCashDrawer.MovementType.Token)
                {
                case "CASHDRAWER_OPEN":

                    //Start Terminal Period
                    result = ProcessWorkSessionPeriod.SessionPeriodOpen(WorkSessionPeriodType.Terminal, dialogCashDrawer.MovementDescription);

                    if (result)
                    {
                        //Update UI
                        GlobalApp.WindowPos.UpdateWorkSessionUI();
                        GlobalApp.WindowPos.TicketList.UpdateOrderStatusBar();

                        //Here we already have GlobalFramework.WorkSessionPeriodTerminal, assigned on ProcessWorkSessionPeriod.SessionPeriodStart
                        //Get Fresh XPO Objects, Prevent Deleted Object Bug
                        workSessionPeriodTerminal = GlobalFramework.SessionXpo.GetObjectByKey <pos_worksessionperiod>(GlobalFramework.WorkSessionPeriodTerminal.Oid);

                        result = ProcessWorkSessionMovement.PersistWorkSessionMovement(
                            workSessionPeriodTerminal,
                            dialogCashDrawer.MovementType,
                            GlobalFramework.LoggedUser,
                            GlobalFramework.LoggedTerminal,
                            FrameworkUtils.CurrentDateTimeAtomic(),
                            dialogCashDrawer.MovementAmountMoney,
                            dialogCashDrawer.MovementDescription
                            );
                    }

                    if (result)
                    {
                        //PrintWorkSessionMovement
                        FrameworkCalls.PrintCashDrawerOpenAndMoneyInOut(dialogCashDrawer, GlobalFramework.LoggedTerminal.ThermalPrinter, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "ticket_title_worksession_terminal_open"), 0.0m, dialogCashDrawer.TotalAmountInCashDrawer, dialogCashDrawer.MovementDescription);

                        //Enable UI Buttons When Have Open Session
                        GlobalApp.WindowPos.TouchButtonPosToolbarNewFinanceDocument.Sensitive = true;
                        //Open CashDrawer
                        Utils.ShowMessageTouch(dialogCashDrawer, DialogFlags.Modal, new Size(500, 280), MessageType.Info, ButtonsType.Close, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_information"), resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_cashdrawer_open_successfully"));
                    }
                    else
                    {
                        Utils.ShowMessageTouch(dialogCashDrawer, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_error"), resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "app_error_contact_support"));
                    }
                    break;

                case "CASHDRAWER_CLOSE":

                    //Stop Terminal Period
                    result = ProcessWorkSessionPeriod.SessionPeriodClose(GlobalFramework.WorkSessionPeriodTerminal);

                    if (result)
                    {
                        //Update UI
                        GlobalApp.WindowPos.UpdateWorkSessionUI();
                        GlobalApp.WindowPos.LabelCurrentTable.Text = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "status_message_open_cashdrawer");

                        //Get Fresh XPO Objects, Prevent Deleted Object Bug
                        workSessionPeriodTerminal = GlobalFramework.SessionXpo.GetObjectByKey <pos_worksessionperiod>(GlobalFramework.WorkSessionPeriodTerminal.Oid);

                        //Add CASHDRAWER_CLOSE Movement to Day Period
                        result = ProcessWorkSessionMovement.PersistWorkSessionMovement(
                            workSessionPeriodTerminal,
                            dialogCashDrawer.MovementType,
                            GlobalFramework.LoggedUser,
                            GlobalFramework.LoggedTerminal,
                            FrameworkUtils.CurrentDateTimeAtomic(),
                            dialogCashDrawer.MovementAmountMoney,
                            dialogCashDrawer.MovementDescription
                            );

                        //PrintWorkSessionMovement
                        FrameworkCalls.PrintWorkSessionMovement(dialogCashDrawer, GlobalFramework.LoggedTerminal.Printer, GlobalFramework.WorkSessionPeriodTerminal);

                        //Enable UI Buttons When Have Open Session
                        GlobalApp.WindowPos.TouchButtonPosToolbarNewFinanceDocument.Sensitive = false;
                        //Show ClosePeriodMessage
                        ShowClosePeriodMessage(dialogCashDrawer, GlobalFramework.WorkSessionPeriodTerminal);
                    }
                    break;

                case "CASHDRAWER_IN":

                    dialogCashDrawer.TotalAmountInCashDrawer += dialogCashDrawer.MovementAmountMoney;

                    workSessionPeriodTerminal = GlobalFramework.SessionXpo.GetObjectByKey <pos_worksessionperiod>(GlobalFramework.WorkSessionPeriodTerminal.Oid);

                    result = ProcessWorkSessionMovement.PersistWorkSessionMovement(
                        workSessionPeriodTerminal,
                        dialogCashDrawer.MovementType,
                        GlobalFramework.LoggedUser,
                        GlobalFramework.LoggedTerminal,
                        FrameworkUtils.CurrentDateTimeAtomic(),
                        dialogCashDrawer.MovementAmountMoney,
                        dialogCashDrawer.MovementDescription
                        );

                    if (result)
                    {
                        //PrintCashDrawerOpenAndMoneyInOut
                        FrameworkCalls.PrintCashDrawerOpenAndMoneyInOut(dialogCashDrawer, GlobalFramework.LoggedTerminal.ThermalPrinter, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "ticket_title_worksession_money_in"), dialogCashDrawer.MovementAmountMoney, dialogCashDrawer.TotalAmountInCashDrawer, dialogCashDrawer.MovementDescription);
                        //Open CashDrawer
                        PrintRouter.OpenDoor(GlobalFramework.LoggedTerminal.Printer);
                        //Audit
                        FrameworkUtils.Audit("CASHDRAWER_IN", string.Format(
                                                 resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "audit_message_cashdrawer_in"),
                                                 FrameworkUtils.DecimalToStringCurrency(dialogCashDrawer.MovementAmountMoney),
                                                 dialogCashDrawer.MovementDescription)
                                             );

                        //ShowMessage
                        Utils.ShowMessageTouch(dialogCashDrawer, DialogFlags.Modal, new Size(500, 300), MessageType.Info, ButtonsType.Close, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_information"), resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_operation_successfully"));
                    }
                    else
                    {
                        Utils.ShowMessageTouch(dialogCashDrawer, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_error"), resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "app_error_contact_support"));
                    }
                    break;

                //Work with Terminal Session
                case "CASHDRAWER_OUT":

                    dialogCashDrawer.TotalAmountInCashDrawer -= dialogCashDrawer.MovementAmountMoney;

                    workSessionPeriodTerminal = GlobalFramework.SessionXpo.GetObjectByKey <pos_worksessionperiod>(GlobalFramework.WorkSessionPeriodTerminal.Oid);

                    //In Period Terminal
                    result = ProcessWorkSessionMovement.PersistWorkSessionMovement(
                        workSessionPeriodTerminal,
                        dialogCashDrawer.MovementType,
                        GlobalFramework.LoggedUser,
                        GlobalFramework.LoggedTerminal,
                        FrameworkUtils.CurrentDateTimeAtomic(),
                        -dialogCashDrawer.MovementAmountMoney,
                        dialogCashDrawer.MovementDescription
                        );

                    if (result)
                    {
                        //PrintCashDrawerOpenAndMoneyInOut
                        FrameworkCalls.PrintCashDrawerOpenAndMoneyInOut(dialogCashDrawer, GlobalFramework.LoggedTerminal.ThermalPrinter, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "ticket_title_worksession_money_out"), dialogCashDrawer.MovementAmountMoney, dialogCashDrawer.TotalAmountInCashDrawer, dialogCashDrawer.MovementDescription);
                        //Open CashDrawer
                        PrintRouter.OpenDoor(GlobalFramework.LoggedTerminal.Printer);
                        //Audit
                        FrameworkUtils.Audit("CASHDRAWER_OUT", string.Format(
                                                 resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "audit_message_cashdrawer_out"),
                                                 FrameworkUtils.DecimalToStringCurrency(dialogCashDrawer.MovementAmountMoney),
                                                 dialogCashDrawer.MovementDescription)
                                             );
                        //ShowMessage
                        Utils.ShowMessageTouch(dialogCashDrawer, DialogFlags.Modal, new Size(500, 300), MessageType.Info, ButtonsType.Close, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_information"), resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_operation_successfully"));
                    }
                    else
                    {
                        Utils.ShowMessageTouch(dialogCashDrawer, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_error"), resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "app_error_contact_support"));
                    }

                    break;

                case "CASHDRAWER_MONEY_OUT":
                    break;

                default:
                    break;
                }
            }
            ;
            dialogCashDrawer.Destroy();

            //TODO: Remove Comments
            //_log.Debug(string.Format("ProcessWorkSessionPeriod: [{0}]", ProcessWorkSessionPeriod.GetSessionPeriodCashDrawerOpenOrCloseAmount(GlobalFramework.WorkSessionPeriodDay)));
            //if (GlobalFramework.WorkSessionPeriodDay != null) ProcessWorkSessionPeriod.GetSessionPeriodMovementTotalDebug(GlobalFramework.WorkSessionPeriodDay, true);
            //if (GlobalFramework.WorkSessionPeriodTerminal != null) ProcessWorkSessionPeriod.GetSessionPeriodMovementTotalDebug(GlobalFramework.WorkSessionPeriodTerminal, true);
        }
Beispiel #23
0
 public static decimal GetSessionPeriodCashDrawerOpenOrCloseAmount(pos_worksessionperiod pWorkSessionPeriod, String pMoventTypeToken)
 {
     return(GetSessionPeriodTerminalCashDrawerOpenOrCloseAmount(GlobalFramework.SessionXpo, pWorkSessionPeriod, pMoventTypeToken));
 }
Beispiel #24
0
 public static decimal GetSessionPeriodMovementTotal(pos_worksessionperiod pWorkSessionPeriod, MovementTypeTotal pMovementTypeTotal)
 {
     return(GetSessionPeriodMovementTotal(GlobalFramework.SessionXpo, pWorkSessionPeriod, pMovementTypeTotal));
 }
Beispiel #25
0
        public static decimal GetSessionPeriodMovementTotal(Session pSession, pos_worksessionperiod pWorkSessionPeriod, MovementTypeTotal pMovementTypeTotal)
        {
            string sqlShared = @"
                SELECT 
                    SUM(wsmMovementAmount) AS Total 
                FROM 
                    view_worksessionmovement 
                WHERE 
                    ((dfmDocumentStatusStatus IS NULL OR dfmDocumentStatusStatus <> 'A') AND (dfpPaymentStatus IS NULL OR dfpPaymentStatus <> 'A')) 
                    AND
                    {0}
                ;"
            ;

            decimal resultTotal       = 0.0m;
            string  sqlWhereTypeTotal = String.Empty;
            string  sqlWherePeriod    = String.Empty;

            if (pMovementTypeTotal != MovementTypeTotal.None)
            {
                try
                {
                    switch (pMovementTypeTotal)
                    {
                    case MovementTypeTotal.All:
                        sqlWhereTypeTotal = @"((cpmPaymentMethodToken = 'MONEY' AND wmtMovementTypeToken <> 'CASHDRAWER_OPEN' AND wmtMovementTypeToken <> 'FINANCE_DOCUMENT')) OR (cpmPaymentMethodToken <> 'MONEY')";
                        break;

                    case MovementTypeTotal.AllNonMoney:
                        sqlWhereTypeTotal = @"(cpmPaymentMethodToken <> 'MONEY' AND wmtMovementTypeToken <> 'FINANCE_DOCUMENT')";
                        break;

                    case MovementTypeTotal.Money:
                        sqlWhereTypeTotal = @"(cpmPaymentMethodToken = 'MONEY' AND wmtMovementTypeToken <> 'FINANCE_DOCUMENT')";
                        break;

                    //Total Money Ins and Outs, includes Money Payments, and CashOpen
                    case MovementTypeTotal.MoneyInCashDrawer:
                        //sqlWhereTypeTotal = @"(wmtMovementTypeToken = 'CASHDRAWER_IN' OR wmtMovementTypeToken = 'CASHDRAWER_OUT')";
                        sqlWhereTypeTotal = @"(wmtMovementTypeToken = 'CASHDRAWER_OPEN' OR wmtMovementTypeToken = 'CASHDRAWER_IN' OR wmtMovementTypeToken = 'CASHDRAWER_OUT')";
                        break;

                    //Total Money Ins and Outs (Without Sells)
                    case MovementTypeTotal.MoneyIn:
                        sqlWhereTypeTotal = @"(wmtMovementTypeToken = 'CASHDRAWER_IN' AND wsmPaymentMethod IS NULL)";
                        break;

                    case MovementTypeTotal.MoneyOut:
                        sqlWhereTypeTotal = @"(wmtMovementTypeToken = 'CASHDRAWER_OUT' AND wsmPaymentMethod IS NULL)";
                        break;

                    case MovementTypeTotal.BankCheck:
                        sqlWhereTypeTotal = @"(cpmPaymentMethodToken <> 'MONEY' AND cpmPaymentMethodToken = 'BANK_CHECK')";
                        break;

                    case MovementTypeTotal.CashMachine:
                        sqlWhereTypeTotal = @"(cpmPaymentMethodToken <> 'MONEY' AND cpmPaymentMethodToken = 'CASH_MACHINE')";
                        break;

                    case MovementTypeTotal.Credit:
                        sqlWhereTypeTotal = @"(cpmPaymentMethodToken <> 'MONEY' AND cpmPaymentMethodToken = 'CREDIT_CARD')";
                        break;

                    case MovementTypeTotal.Visa:
                        sqlWhereTypeTotal = @"(cpmPaymentMethodToken <> 'MONEY' AND cpmPaymentMethodToken = 'VISA')";
                        break;

                    case MovementTypeTotal.CurrentAccount:
                        sqlWhereTypeTotal = @"(cpmPaymentMethodToken <> 'MONEY' AND cpmPaymentMethodToken = 'CURRENT_ACCOUNT')";
                        break;

                    default:
                        break;
                    }

                    switch (pWorkSessionPeriod.PeriodType)
                    {
                    case WorkSessionPeriodType.Day:
                        //sqlWherePeriod = string.Format(@"AND wspPeriodStatus = 0 AND (wspPeriodParent = '{0}')", pWorkSessionPeriod.Oid);
                        sqlWherePeriod = string.Format(@"AND (wspPeriodParent = '{0}')", pWorkSessionPeriod.Oid);
                        break;

                    case WorkSessionPeriodType.Terminal:
                        //sqlWherePeriod = string.Format(@"AND wspPeriodStatus = 0 AND (wspPeriod = '{0}')", pWorkSessionPeriod.Oid/*GlobalFramework.WorkSessionPeriodTerminal.Oid*/);
                        sqlWherePeriod = string.Format(@"AND (wspPeriod = '{0}')", pWorkSessionPeriod.Oid /*GlobalFramework.WorkSessionPeriodTerminal.Oid*/);
                        break;

                    default:
                        break;
                    }

                    string sql = string.Format(sqlShared, string.Format("(({0}) {1})", sqlWhereTypeTotal, sqlWherePeriod));
                    resultTotal = Convert.ToDecimal(pSession.ExecuteScalar(sql));
                    //_log.Debug(string.Format("pMovementTypeTotal: [{0}], resultTotal: [{1}], sql: [{2}]", pMovementTypeTotal, resultTotal, sql));
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                }
            }
            return(resultTotal);
        }