Пример #1
0
        void buttonPrintInvoiceDiscount_Clicked(object sender, EventArgs e)
        {
            Guid documentTypeGuid = SettingsApp.XpoOidDocumentFinanceTypeInvoice;
            Guid customerGuid     = new Guid("6223881a-4d2d-4de4-b254-f8529193da33");

            //Article:Line1
            Guid        article1Guid = new Guid("72e8bde8-d03b-4637-90f1-fcb265658af0");
            FIN_Article article1     = (FIN_Article)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_Article), article1Guid);
            //Article:Line2
            Guid        article2Guid = new Guid("78638720-e728-4e96-8643-6d6267ff817b");
            FIN_Article article2     = (FIN_Article)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_Article), article2Guid);
            //Place
            Guid placeGuid = new Guid("dd5a3869-db52-42d4-bbed-dec4adfaf62b");
            //Table
            Guid tableGuid = new Guid("64d417f6-ff97-4f4b-bded-4bc9bf9f18d9");

            //Get ArticleBag
            ArticleBag articleBag = new ArticleBag();

            articleBag.Add(article1, placeGuid, tableGuid, PriceType.Price1, 100.0m);
            articleBag.Add(article2, placeGuid, tableGuid, PriceType.Price1, 1.0m);

            //Prepare ProcessFinanceDocumentParameter
            ProcessFinanceDocumentParameter processFinanceDocumentParameter = new ProcessFinanceDocumentParameter(
                documentTypeGuid, articleBag)
            {
                Customer   = customerGuid,
                SourceMode = PersistFinanceDocumentSourceMode.CustomArticleBag
            };
            FIN_DocumentFinanceMaster resultDocument = FrameworkCalls.PersistFinanceDocument(SourceWindow, processFinanceDocumentParameter);
        }
Пример #2
0
        void buttonPrintInvoiceJohnDoe2_Clicked(object sender, EventArgs e)
        {
            Guid documentTypeGuid = SettingsApp.XpoOidDocumentFinanceTypeSimplifiedInvoice;
            Guid customerGuid     = new Guid("f5a382bb-f826-40d8-8910-cfb18df8a41e");//John Doe2

            //Article
            Guid        article1Guid = new Guid("32deb30d-ffa2-45e4-bca6-03569b9e8b08");
            fin_article article1     = (fin_article)GlobalFramework.SessionXpo.GetObjectByKey(typeof(fin_article), article1Guid);
            //Place
            Guid placeGuid = new Guid("dd5a3869-db52-42d4-bbed-dec4adfaf62b");
            //Table
            Guid tableGuid = new Guid("64d417f6-ff97-4f4b-bded-4bc9bf9f18d9");

            //Get ArticleBag
            ArticleBag articleBag = new ArticleBag();

            articleBag.Add(article1, placeGuid, tableGuid, PriceType.Price1, 8.0m);

            //Prepare ProcessFinanceDocumentParameter
            ProcessFinanceDocumentParameter processFinanceDocumentParameter = new ProcessFinanceDocumentParameter(
                documentTypeGuid, articleBag)
            {
                Customer   = customerGuid,
                SourceMode = PersistFinanceDocumentSourceMode.CustomArticleBag
            };
            fin_documentfinancemaster resultDocument = FrameworkCalls.PersistFinanceDocument(SourceWindow, processFinanceDocumentParameter);
        }
Пример #3
0
        //Detect if ArticleBag has a "Recharge Article" and Valid "Customer Card" customer
        //Returns true if is valid, or false if is invalidCustomerCardDetected
        public static bool IsCustomerCardValidForArticleBag(ArticleBag pArticleBag, ERP_Customer pCustomer)
        {
            //Default result is true
            bool result = true;

            try
            {
                FIN_Article article;
                foreach (var item in pArticleBag)
                {
                    //Get Article
                    article = (FIN_Article)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_Article), item.Key.ArticleOid);
                    //Assign Required if ArticleClassCustomerCard Detected
                    if (article.Type.Oid == SettingsApp.XpoOidArticleClassCustomerCard &&
                        (
                            pCustomer.Oid == SettingsApp.XpoOidDocumentFinanceMasterFinalConsumerEntity ||
                            string.IsNullOrEmpty(pCustomer.CardNumber)
                        )
                        )
                    {
                        //Override Default true Result when Invalid Customer is Detected
                        result = false;
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }

            return(result);
        }
Пример #4
0
        void buttonPrintInvoiceExchangeRate_Clicked(object sender, EventArgs e)
        {
            Guid documentTypeGuid = SettingsApp.XpoOidDocumentFinanceTypeInvoice;
            Guid customerGuid     = new Guid("6223881a-4d2d-4de4-b254-f8529193da33");
            Guid currencyGuid     = new Guid("28d692ad-0083-11e4-96ce-00ff2353398c");
            cfg_configurationcurrency currency = (cfg_configurationcurrency)GlobalFramework.SessionXpo.GetObjectByKey(typeof(cfg_configurationcurrency), currencyGuid);

            //Article:Line1
            Guid        article1Guid = new Guid("72e8bde8-d03b-4637-90f1-fcb265658af0");
            fin_article article1     = (fin_article)GlobalFramework.SessionXpo.GetObjectByKey(typeof(fin_article), article1Guid);
            //Article:Line2
            Guid        article2Guid = new Guid("78638720-e728-4e96-8643-6d6267ff817b");
            fin_article article2     = (fin_article)GlobalFramework.SessionXpo.GetObjectByKey(typeof(fin_article), article2Guid);
            //Place
            Guid placeGuid = new Guid("dd5a3869-db52-42d4-bbed-dec4adfaf62b");
            //Table
            Guid tableGuid = new Guid("64d417f6-ff97-4f4b-bded-4bc9bf9f18d9");

            //Get ArticleBag
            ArticleBag articleBag = new ArticleBag();

            articleBag.Add(article1, placeGuid, tableGuid, PriceType.Price1, 100.0m);
            articleBag.Add(article2, placeGuid, tableGuid, PriceType.Price1, 1.0m);

            //Prepare ProcessFinanceDocumentParameter
            ProcessFinanceDocumentParameter processFinanceDocumentParameter = new ProcessFinanceDocumentParameter(
                documentTypeGuid, articleBag)
            {
                Customer     = customerGuid,
                SourceMode   = PersistFinanceDocumentSourceMode.CustomArticleBag,
                Currency     = currencyGuid,
                ExchangeRate = currency.ExchangeRate
            };
            fin_documentfinancemaster resultDocument = FrameworkCalls.PersistFinanceDocument(SourceWindow, processFinanceDocumentParameter);
        }
Пример #5
0
        void buttonPrintInvoiceJohnDoe1_Clicked(object sender, EventArgs e)
        {
            Guid documentTypeGuid = SettingsApp.XpoOidDocumentFinanceTypeSimplifiedInvoice;
            Guid customerGuid     = new Guid("d8ce6455-e1a4-41dc-a475-223c00de3a91");//John Doe1

            //Article
            Guid        article1Guid = new Guid("72e8bde8-d03b-4637-90f1-fcb265658af0");
            fin_article article1     = (fin_article)GlobalFramework.SessionXpo.GetObjectByKey(typeof(fin_article), article1Guid);
            //Place
            Guid placeGuid = new Guid("dd5a3869-db52-42d4-bbed-dec4adfaf62b");
            //Table
            Guid tableGuid = new Guid("64d417f6-ff97-4f4b-bded-4bc9bf9f18d9");

            //Get ArticleBag
            ArticleBag articleBag = new ArticleBag();

            articleBag.Add(article1, placeGuid, tableGuid, PriceType.Price1, 1.0m);

            //Prepare ProcessFinanceDocumentParameter
            ProcessFinanceDocumentParameter processFinanceDocumentParameter = new ProcessFinanceDocumentParameter(
                documentTypeGuid, articleBag)
            {
                Customer   = customerGuid,
                SourceMode = PersistFinanceDocumentSourceMode.CustomArticleBag
            };
            fin_documentfinancemaster resultDocument = FrameworkCalls.PersistFinanceDocument(SourceWindow, processFinanceDocumentParameter);
        }
Пример #6
0
        //NC : Credit Note
        void buttonCreditNote_Clicked(object sender, EventArgs e)
        {
            Guid documentTypeGuid = SettingsApp.XpoOidDocumentFinanceTypeCreditNote;
            Guid reference        = new Guid("daecbf1d-6211-4e74-a8cd-81795e347656");

            //FT FT2015S0001/16
            fin_documentfinancemaster documentReference = (fin_documentfinancemaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(fin_documentfinancemaster), reference);
            //Add Order References
            List <DocumentReference> references = new List <DocumentReference>();

            references.Add(new DocumentReference(documentReference, "Artigo com defeito"));

            //Get ArticleBag from documentFinanceMasterSource
            ArticleBag articleBag = ArticleBag.DocumentFinanceMasterToArticleBag(documentReference);

            //Prepare ProcessFinanceDocumentParameter
            ProcessFinanceDocumentParameter processFinanceDocumentParameter = new ProcessFinanceDocumentParameter(
                documentTypeGuid, articleBag)
            {
                Customer = documentReference.EntityOid,
                //References = references,
                SourceMode = PersistFinanceDocumentSourceMode.CustomArticleBag
            };
            fin_documentfinancemaster resultDocument = FrameworkCalls.PersistFinanceDocument(SourceWindow, processFinanceDocumentParameter);
        }
Пример #7
0
        //Credit Notes
        public static FIN_DocumentFinanceMaster PersistFinanceDocumentCreditNote(Guid pDocumentFinanceType)
        {
            //SourceDocument for CreditNote
            Guid xpoOidParentDocument = new Guid("316528f6-bf9b-4a6d-aa5b-530379aaa6ef");
            FIN_DocumentFinanceMaster sourceDocument = (FIN_DocumentFinanceMaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_DocumentFinanceMaster), xpoOidParentDocument);

            ArticleBag articleBag = TestArticleBag.GetArticleBag(false);

            //Fill Required Reference and Reason
            foreach (var item in articleBag)
            {
                item.Value.Reference = sourceDocument;
                item.Value.Reason    = "Anulação";
                item.Value.Quantity -= 1;
            }

            ProcessFinanceDocumentParameter processFinanceDocumentParameter = new ProcessFinanceDocumentParameter(pDocumentFinanceType, articleBag)
            {
                SourceMode = PersistFinanceDocumentSourceMode.CustomArticleBag,
                //P1
                PaymentCondition = SettingsApp.XpoOidDocumentPaymentCondition,
                PaymentMethod    = SettingsApp.XpoOidDocumentPaymentMethod,
                Currency         = SettingsApp.XpoOidDocumentCurrency,
                //Used for Credit Notes
                DocumentParent = xpoOidParentDocument,
                //P2
                Customer = SettingsApp.XpoOidDocumentCustomer
            };

            return(PersistFinanceDocumentBase(pDocumentFinanceType, processFinanceDocumentParameter));
        }
Пример #8
0
        //OrderReferences
        void buttonOrderReferences_Clicked(object sender, EventArgs e)
        {
            Guid documentTypeGuid = SettingsApp.XpoOidDocumentFinanceTypeInvoice;
            Guid customerGuid     = new Guid("6223881a-4d2d-4de4-b254-f8529193da33");
            Guid orderReference   = new Guid("fbec0056-71a7-4d5b-8bfa-d5e887ec585f");

            //DC DC2015S0001/1
            fin_documentfinancemaster documentOrderReference = (fin_documentfinancemaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(fin_documentfinancemaster), orderReference);
            //Add Order References
            List <fin_documentfinancemaster> orderReferences = new List <fin_documentfinancemaster>();

            orderReferences.Add(documentOrderReference);

            //Get ArticleBag from documentFinanceMasterSource
            ArticleBag articleBag = ArticleBag.DocumentFinanceMasterToArticleBag(documentOrderReference);

            //Prepare ProcessFinanceDocumentParameter
            ProcessFinanceDocumentParameter processFinanceDocumentParameter = new ProcessFinanceDocumentParameter(
                documentTypeGuid, articleBag)
            {
                Customer        = customerGuid,
                OrderReferences = orderReferences,
                SourceMode      = PersistFinanceDocumentSourceMode.CustomArticleBag,
                SourceOrderMain = documentOrderReference.SourceOrderMain
            };

            fin_documentfinancemaster resultDocument = FrameworkCalls.PersistFinanceDocument(SourceWindow, processFinanceDocumentParameter);
        }
Пример #9
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //FinanceDocument

        //Used to trigger all Errors
        public static FIN_DocumentFinanceMaster PersistFinanceDocumentMinimal(Guid pDocumentFinanceType)
        {
            //Store current Logged Details
            SYS_UserDetail loggedUser = GlobalFramework.LoggedUser;
            POS_ConfigurationPlaceTerminal loggedTerminal = GlobalFramework.LoggedTerminal;

            //Reset Current Logged Details
            GlobalFramework.LoggedUser     = null;
            GlobalFramework.LoggedTerminal = null;
            FIN_DocumentFinanceMaster documentFinanceMaster = null;

            try
            {
                //Create Empty ArticleBag
                ArticleBag articleBag = new ArticleBag();
                //Create ProcessFinanceDocumentParameter
                ProcessFinanceDocumentParameter processFinanceDocumentParameter = new ProcessFinanceDocumentParameter(pDocumentFinanceType, articleBag);
                //Reset Defaults
                processFinanceDocumentParameter.Currency = Guid.Empty;
                documentFinanceMaster = ProcessFinanceDocument.PersistFinanceDocument(processFinanceDocumentParameter);
                Console.WriteLine(string.Format("documentFinanceMaster.DocumentNumber: [{0}]", documentFinanceMaster.DocumentNumber));
            }
            finally
            {
                //Restore Old Logged Details
                GlobalFramework.LoggedUser     = loggedUser;
                GlobalFramework.LoggedTerminal = loggedTerminal;
            }

            return(documentFinanceMaster);
        }
Пример #10
0
        void buttonPrintTransportationGuideWithTotals_Clicked(object sender, EventArgs e)
        {
            Guid documentTypeGuid = new Guid("96bcf534-0dab-48bb-a69e-166e81ae6f7b");
            Guid customerGuid     = new Guid("d64c5d26-b4f9-4220-bd3c-72ece5e3960a");

            //Article
            Guid        article1Guid = new Guid("55892c3f-de10-4076-afde-619c54100c9b");
            FIN_Article article1     = (FIN_Article)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_Article), article1Guid);
            //Place
            Guid placeGuid = new Guid("dd5a3869-db52-42d4-bbed-dec4adfaf62b");
            //Table
            Guid tableGuid = new Guid("64d417f6-ff97-4f4b-bded-4bc9bf9f18d9");

            //Get ArticleBag
            ArticleBag articleBag = new ArticleBag();

            articleBag.Add(article1, placeGuid, tableGuid, PriceType.Price1, 24.0m);

            //Prepare ProcessFinanceDocumentParameter
            ProcessFinanceDocumentParameter processFinanceDocumentParameter = new ProcessFinanceDocumentParameter(
                documentTypeGuid, articleBag)
            {
                Customer   = customerGuid,
                SourceMode = PersistFinanceDocumentSourceMode.CustomArticleBag
            };
            FIN_DocumentFinanceMaster resultDocument = FrameworkCalls.PersistFinanceDocument(SourceWindow, processFinanceDocumentParameter);
        }
Пример #11
0
        void buttonPrintTransportationGuideWithoutTotals_Clicked(object sender, EventArgs e)
        {
            Guid documentTypeGuid = new Guid("96bcf534-0dab-48bb-a69e-166e81ae6f7b");
            Guid customerGuid     = new Guid("6223881a-4d2d-4de4-b254-f8529193da33");

            //Article
            Guid        article1Guid = new Guid("55892c3f-de10-4076-afde-619c54100c9b");
            fin_article article1     = (fin_article)GlobalFramework.SessionXpo.GetObjectByKey(typeof(fin_article), article1Guid);
            //Place
            Guid placeGuid = new Guid("dd5a3869-db52-42d4-bbed-dec4adfaf62b");
            //Table
            Guid tableGuid = new Guid("64d417f6-ff97-4f4b-bded-4bc9bf9f18d9");

            //Get ArticleBag
            ArticleBag articleBag = new ArticleBag();

            articleBag.Add(article1, placeGuid, tableGuid, PriceType.Price1, 48.0m);

            //Prepare ProcessFinanceDocumentParameter
            ProcessFinanceDocumentParameter processFinanceDocumentParameter = new ProcessFinanceDocumentParameter(
                documentTypeGuid, articleBag)
            {
                Customer     = customerGuid,
                SourceMode   = PersistFinanceDocumentSourceMode.CustomArticleBag,
                ExchangeRate = 0.0m
            };
            fin_documentfinancemaster resultDocument = FrameworkCalls.PersistFinanceDocument(SourceWindow, processFinanceDocumentParameter);
        }
Пример #12
0
        private DataTable GetDataTable(List <GenericTreeViewColumnProperty> pColumnProperties)
        {
            //Init Local Vars
            DataTable              resultDataTable = new DataTable();
            Type                   dataTableColumnType;
            FIN_Article            article;
            OrderMain              orderMain  = GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid];
            ArticleBag             articleBag = ArticleBag.TicketOrderToArticleBag(orderMain);
            POS_ConfigurationPlace configurationPlace;

            //Add Columns with specific Types From Column Properties
            foreach (GenericTreeViewColumnProperty column in pColumnProperties)
            {
                dataTableColumnType = (column.Type != null) ? column.Type : typeof(String);
                resultDataTable.Columns.Add(column.Name, dataTableColumnType);
            }

            //Init DataRow
            System.Object[] dataRow = new System.Object[pColumnProperties.Count];

            //Start Loop
            foreach (var item in articleBag)
            {
                article = (FIN_Article)FrameworkUtils.GetXPGuidObject(typeof(FIN_Article), item.Key.ArticleOid);
                if (article.Type.HavePrice)
                {
                    configurationPlace = (POS_ConfigurationPlace)FrameworkUtils.GetXPGuidObject(typeof(POS_ConfigurationPlace), item.Value.PlaceOid);

                    for (int i = 0; i < item.Value.Quantity; i++)
                    {
                        //Column Fields
                        dataRow[0]  = item.Key.ArticleOid;
                        dataRow[1]  = item.Value.Code;
                        dataRow[2]  = item.Key.Designation;
                        dataRow[3]  = item.Value.PriceFinal;
                        dataRow[4]  = item.Key.Vat;
                        dataRow[5]  = item.Key.Discount;
                        dataRow[6]  = configurationPlace.Designation;
                        dataRow[7]  = item.Key.Price;
                        dataRow[8]  = 1;
                        dataRow[9]  = item.Value.UnitMeasure;
                        dataRow[10] = item.Value.PlaceOid;
                        dataRow[11] = item.Value.TableOid;
                        dataRow[12] = item.Value.PriceType;
                        dataRow[13] = item.Value.Token1;
                        dataRow[14] = item.Value.Token2;
                        dataRow[15] = string.Empty;

                        //Add Row
                        resultDataTable.Rows.Add(dataRow);
                    }
                }
            }
            return(resultDataTable);
        }
Пример #13
0
 private void treeViewArticlesRecordAfterChange()
 {
     //Recreate ArticleBag
     _articleBag = _posDocumentFinanceDialog.GetArticleBag();
     //Update Main Dialog Title
     _posDocumentFinanceDialog.WindowTitle = _posDocumentFinanceDialog.GetPageTitle(_pagePad.CurrentPageIndex);
     //Update Customer Edit Mode Fields
     _pagePad2.UpdateCustomerEditMode();
     //Validate this PagePad
     Validate();
 }
Пример #14
0
 private void treeViewArticlesRecordAfterChange()
 {
     //Recreate ArticleBag
     _articleBag = _posDocumentFinanceDialog.GetArticleBag();
     //Update Main Dialog Title
     _posDocumentFinanceDialog.WindowTitle = _posDocumentFinanceDialog.GetPageTitle(_pagePad.CurrentPageIndex);
     //Update Customer Edit Mode Fields
     _pagePad2.UpdateCustomerEditMode();
     //Validate this PagePad
     Validate();
     //TK016236 FrontOffice - Salvar sessão para novo documento
     //GlobalFramework.SessionApp.CurrentOrderMainOid = currentOrderMain.Table.OrderMainOid;
     //GlobalFramework.SessionApp.Write();
 }
Пример #15
0
        //Default
        public static FIN_DocumentFinanceMaster PersistFinanceDocument(Guid pDocumentFinanceType)
        {
            ArticleBag articleBag = TestArticleBag.GetArticleBag(false);

            ProcessFinanceDocumentParameter processFinanceDocumentParameter = new ProcessFinanceDocumentParameter(pDocumentFinanceType, articleBag)
            {
                SourceMode = PersistFinanceDocumentSourceMode.CustomArticleBag,
                //P1
                PaymentCondition = SettingsApp.XpoOidDocumentPaymentCondition,
                PaymentMethod    = SettingsApp.XpoOidDocumentPaymentMethod,
                Currency         = SettingsApp.XpoOidDocumentCurrency,
                //P2
                Customer = SettingsApp.XpoOidDocumentCustomer
            };

            return(PersistFinanceDocumentBase(pDocumentFinanceType, processFinanceDocumentParameter));
        }
Пример #16
0
        public static FIN_DocumentFinanceMaster PersistFinanceDocumentBase(Guid pDocumentFinanceType, ProcessFinanceDocumentParameter pProcessFinanceDocumentParameter)
        {
            ArticleBag articleBag = TestArticleBag.GetArticleBag(false);

            //Change default DocumentDateTime
            //processFinanceDocumentParameter.DocumentDateTime = FrameworkUtils.CurrentDateTimeAtomic().AddDays(-5);

            FIN_DocumentFinanceMaster documentFinanceMaster = ProcessFinanceDocument.PersistFinanceDocument(pProcessFinanceDocumentParameter);

            if (documentFinanceMaster != null)
            {
                Console.WriteLine(string.Format("documentFinanceMaster.DocumentNumber: [{0}]", documentFinanceMaster.DocumentNumber));
                PrintRouter.PrintFinanceDocument(documentFinanceMaster);
            }

            return(documentFinanceMaster);
        }
Пример #17
0
        public ProcessFinanceDocumentParameter(Guid pDocumentType, ArticleBag pArticleBag)
        {
            //Init Default Values
            _documentDateTime = FrameworkUtils.CurrentDateTimeAtomic();
            _sourceMode       = PersistFinanceDocumentSourceMode.CurrentOrderMain;
            _totalDelivery    = 0.0m;
            _totalChange      = 0.0m;
            _currency         = SettingsApp.ConfigurationSystemCurrency.Oid;
            //_discount = 0.0m;
            _exchangeRate = 1.0m;

            //Init Parameters
            _documentType = pDocumentType;
            _articleBag   = pArticleBag;

            //Validate();
        }
Пример #18
0
        //FT: Vats
        void buttonPrintInvoiceVat_Clicked(object sender, EventArgs e)
        {
            Guid documentTypeGuid       = SettingsApp.XpoOidDocumentFinanceTypeInvoice;
            Guid customerGuid           = new Guid("6223881a-4d2d-4de4-b254-f8529193da33");
            Guid vatExemptionReasonGuid = new Guid("8311ce58-50ee-4115-9cf9-dbca86538fdd");
            fin_configurationvatexemptionreason vatExemptionReason = (fin_configurationvatexemptionreason)GlobalFramework.SessionXpo.GetObjectByKey(typeof(fin_configurationvatexemptionreason), vatExemptionReasonGuid);

            //Article:Line1
            Guid        articleREDGuid = new Guid("72e8bde8-d03b-4637-90f1-fcb265658af0");
            fin_article articleRED     = (fin_article)GlobalFramework.SessionXpo.GetObjectByKey(typeof(fin_article), articleREDGuid);
            //Article:Line2
            Guid        articleISEGuid = new Guid("78638720-e728-4e96-8643-6d6267ff817b");
            fin_article articleISE     = (fin_article)GlobalFramework.SessionXpo.GetObjectByKey(typeof(fin_article), articleISEGuid);
            //Article:Line3
            Guid        articleINTGuid = new Guid("bf99351b-1556-43c4-a85c-90082fb02d05");
            fin_article articleINT     = (fin_article)GlobalFramework.SessionXpo.GetObjectByKey(typeof(fin_article), articleINTGuid);
            //Article:Line4
            Guid        articleNORGuid = new Guid("6b547918-769e-4f5b-bcd6-01af54846f73");
            fin_article articleNOR     = (fin_article)GlobalFramework.SessionXpo.GetObjectByKey(typeof(fin_article), articleNORGuid);
            //Place
            Guid placeGuid = new Guid("dd5a3869-db52-42d4-bbed-dec4adfaf62b");
            //Table
            Guid tableGuid = new Guid("64d417f6-ff97-4f4b-bded-4bc9bf9f18d9");

            //Get ArticleBag
            ArticleBag articleBag = new ArticleBag();

            articleBag.Add(articleRED, placeGuid, tableGuid, PriceType.Price1, 1.0m);
            articleBag.Add(articleISE, placeGuid, tableGuid, PriceType.Price1, 1.0m, vatExemptionReason);
            articleBag.Add(articleINT, placeGuid, tableGuid, PriceType.Price1, 1.0m);
            articleBag.Add(articleNOR, placeGuid, tableGuid, PriceType.Price1, 1.0m);

            //Prepare ProcessFinanceDocumentParameter
            ProcessFinanceDocumentParameter processFinanceDocumentParameter = new ProcessFinanceDocumentParameter(
                documentTypeGuid, articleBag)
            {
                Customer   = customerGuid,
                SourceMode = PersistFinanceDocumentSourceMode.CustomArticleBag
            };
            fin_documentfinancemaster resultDocument = FrameworkCalls.PersistFinanceDocument(SourceWindow, processFinanceDocumentParameter);
        }
Пример #19
0
        //OnResponse Ok Post Validation, Last Validations before Procced to PersistFinanceDocument
        private bool LastValidation()
        {
            //Defaylt is true
            bool       result     = true;
            ArticleBag articleBag = GetArticleBag();

            try
            {
                //Protection to prevent Exceed Customer CardCredit
                if (
                    //Can be null if not in a Payable DocumentType
                    _pagePad1.EntryBoxSelectConfigurationPaymentMethod.Value != null &&
                    _pagePad1.EntryBoxSelectConfigurationPaymentMethod.Value.Token == "CUSTOMER_CARD" &&
                    articleBag.TotalFinal > _pagePad2.EntryBoxSelectCustomerName.Value.CardCredit
                    )
                {
                    Utils.ShowMessageTouch(
                        this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, Resx.global_error,
                        string.Format(
                            Resx.dialog_message_value_exceed_customer_card_credit,
                            FrameworkUtils.DecimalToStringCurrency(_pagePad2.EntryBoxSelectCustomerName.Value.CardCredit),
                            FrameworkUtils.DecimalToStringCurrency(articleBag.TotalFinal)
                            )
                        );
                    result = false;
                }

                //Protection to Prevent Recharge Customer Card with Invalid User (User without Card or FinalConsumer...)
                if (result && !FrameworkUtils.IsCustomerCardValidForArticleBag(articleBag, _pagePad2.EntryBoxSelectCustomerName.Value))
                {
                    Utils.ShowMessageTouch(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, Resx.global_error, Resx.dialog_message_invalid_customer_card_detected);
                    result = false;
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }

            return(result);
        }
Пример #20
0
        public DocumentFinanceDialogPreview(Window pSourceWindow, DialogFlags pDialogFlags, DocumentFinanceDialogPreviewMode pMode, ArticleBag pArticleBag, cfg_configurationcurrency pConfigurationCurrency)
            : base(pSourceWindow, pDialogFlags)
        {
            //Init Local Vars
            String windowTitle           = string.Empty;
            Size   windowSize            = new Size(700, 360);
            String fileDefaultWindowIcon = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\Windows\icon_window_preview.png");

            //Parameters
            _articleBag            = pArticleBag;
            _configurationCurrency = pConfigurationCurrency;

            //ActionArea
            ActionAreaButtons actionAreaButtons = new ActionAreaButtons();

            if (pMode == DocumentFinanceDialogPreviewMode.Preview)
            {
                windowTitle = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_documentfinance_preview_totals_mode_preview");
                //ActionArea Buttons
                TouchButtonIconWithText buttonOk = new TouchButtonIconWithText("touchButtonOk_DialogActionArea", _colorBaseDialogActionAreaButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_button_label_ok"), _fontBaseDialogActionAreaButton, _colorBaseDialogActionAreaButtonFont, _fileActionOK, _sizeBaseDialogActionAreaButtonIcon, _sizeBaseDialogActionAreaButton.Width, _sizeBaseDialogActionAreaButton.Height);
                //ActionArea
                actionAreaButtons.Add(new ActionAreaButton(buttonOk, ResponseType.Ok));
            }
            else
            {
                windowTitle = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_documentfinance_preview_totals_mode_confirm");
                //ActionArea Buttons
                TouchButtonIconWithText buttonNo  = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.No);
                TouchButtonIconWithText buttonYes = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Yes);
                //ActionArea
                actionAreaButtons.Add(new ActionAreaButton(buttonYes, ResponseType.Yes));
                actionAreaButtons.Add(new ActionAreaButton(buttonNo, ResponseType.No));
            }
            windowTitle = string.Format("{0} [{1}]", windowTitle, _configurationCurrency.Acronym);

            InitUI();

            //Init Object
            this.InitObject(this, pDialogFlags, fileDefaultWindowIcon, windowTitle, windowSize, _alignmentWindow, actionAreaButtons);
        }
Пример #21
0
        public static void ShowArticleBag()
        {
            Guid articleClassProducts = new Guid("6924945d-f99e-476b-9c4d-78fb9e2b30a3");
            Guid articleClassServices = new Guid("7622e5d2-2d52-4be9-bb8b-e5efae5ec791");

            ArticleBag articleBag = TestArticleBag.GetArticleBag(false);

            foreach (var item in articleBag)
            {
                //_log.Debug(string.Format("{0} x {1}", item.Key.Designation, item.Value.Quantity));
                Console.WriteLine(string.Format("{0} x {1}", item.Key.Designation, item.Value.Quantity));
            }

            //Test GetClassTotals
            Dictionary <string, decimal> classTotals = articleBag.GetClassTotals();

            //Show Result
            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("TotalFinal P: [{0}]", classTotals["P"]);
            Console.WriteLine("TotalFinal S: [{0}]", classTotals["S"]);
            Console.WriteLine("ArticleBag TotalFinal: [{0}], TotalPAndS: [{1}]", articleBag.TotalFinal, classTotals["P"] + classTotals["S"]);
        }
Пример #22
0
        /// <summary>
        /// Method to check if Credit Note ArticleBag is Valid
        /// </summary>
        public static bool GetCreditNoteValidation(FIN_DocumentFinanceMaster pDocumentParent, ArticleBag pArticleBag)
        {
            bool debug  = false;
            bool result = false;

            try
            {
                if (pArticleBag != null)
                {
                    string  sql = string.Empty;
                    object  resultAlreadyCredited;
                    object  resultParentDocument;
                    decimal totalAlreadyCredited;
                    decimal totalParentDocument;

                    foreach (var item in pArticleBag)
                    {
                        //Get Total Already Credit Items in this Document
                        sql = string.Format("SELECT Quantity AS Total FROM fin_documentfinancedetail WHERE DocumentMaster = '{0}' AND Article = '{1}';", pDocumentParent.Oid, item.Key.ArticleOid);
                        resultParentDocument = GlobalFramework.SessionXpo.ExecuteScalar(sql);
                        totalParentDocument  = (resultParentDocument != null) ? Convert.ToDecimal(resultParentDocument) : 0.0m;

                        sql = string.Format("SELECT SUM(fdQuantity) AS Total FROM view_documentfinance WHERE ftOid = '{0}' AND fmDocumentParent = '{1}' AND fdArticle = '{2}';", SettingsApp.XpoOidDocumentFinanceTypeCreditNote, pDocumentParent.Oid, item.Key.ArticleOid);
                        resultAlreadyCredited = GlobalFramework.SessionXpo.ExecuteScalar(sql);
                        totalAlreadyCredited  = (resultAlreadyCredited != null) ? Convert.ToDecimal(resultAlreadyCredited) : 0.0m;

                        if (debug)
                        {
                            _log.Debug(String.Format(
                                           "[{0}], Parent: [{1}], CanBeCredited: [{2}], TryToCredit: [{3}], Diference: [{4}]",
                                           item.Key.Designation,
                                           totalParentDocument,                                               //Total in Parent/SourceDocument
                                           (totalParentDocument - totalAlreadyCredited),                      //Total that can be Credited
                                           item.Value.Quantity,                                               //Total Trying to Credit
                                           (totalParentDocument - totalAlreadyCredited) - item.Value.Quantity //Diference
                                           )
                                       );
                        }

                        //Check if try to Credit more than UnCredit Articles
                        if (item.Value.Quantity > (totalParentDocument - totalAlreadyCredited))
                        {
                            result = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }

            return(result);
        }
Пример #23
0
        public PosSplitPaymentsDialog(Window pSourceWindow, DialogFlags pDialogFlags, ArticleBag articleBag, TicketList ticketList)
            : base(pSourceWindow, pDialogFlags)
        {
            // Parameters
            _articleBag = articleBag;
            _ticketList = ticketList;

            // initSettingsValues
            initSettingsValues();

            //Init Local Vars
            // Title will be Overrided in CalculateTotalPerSplit
            string windowTitle           = Resx.window_title_dialog_split_payment;
            Size   windowSize            = new Size(600, 460);
            string fileDefaultWindowIcon = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\Windows\icon_window_split_payments.png");
            string fileAddSplitIcon      = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\icon_pos_nav_new.png");
            string fileRemoveSplitIcon   = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\icon_pos_nav_delete.png");

            //Init Content : ViewPort
            _vbox = new VBox(false, 2);
            Viewport viewport = new Viewport()
            {
                ShadowType = ShadowType.None
            };

            viewport.Add(_vbox);
            viewport.ResizeMode = ResizeMode.Parent;
            //ScrolledWindow
            ScrolledWindow _scrolledWindow = new ScrolledWindow();

            _scrolledWindow.ShadowType = ShadowType.EtchedIn;
            _scrolledWindow.SetPolicy(PolicyType.Automatic, PolicyType.Automatic);
            _scrolledWindow.Add(viewport);
            _scrolledWindow.ResizeMode = ResizeMode.Parent;

            //ActionArea Buttons
            _buttonOk           = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Ok);
            _buttonCancel       = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Cancel);
            _buttonOk.Sensitive = false;

            _buttonTableAddSplit = new TouchButtonIconWithText("touchButtonTableIncrementSplit_DialogActionArea", _colorBaseDialogActionAreaButtonBackground, Resx.global_add, _fontBaseDialogActionAreaButton, _colorBaseDialogActionAreaButtonFont, fileAddSplitIcon, _sizeBaseDialogActionAreaButtonIcon, _sizeBaseDialogActionAreaButton.Width, _sizeBaseDialogActionAreaButton.Height)
            {
                Sensitive = true
            };
            _buttonTableRemoveSplit = new TouchButtonIconWithText("touchButtonTableDecrementSplit_DialogActionArea", _colorBaseDialogActionAreaButtonBackground, Resx.global_remove, _fontBaseDialogActionAreaButton, _colorBaseDialogActionAreaButtonFont, fileRemoveSplitIcon, _sizeBaseDialogActionAreaButtonIcon, _sizeBaseDialogActionAreaButton.Width, _sizeBaseDialogActionAreaButton.Height)
            {
                Sensitive = true
            };

            //ActionArea
            ActionAreaButtons actionAreaButtons = new ActionAreaButtons();

            actionAreaButtons.Add(new ActionAreaButton(_buttonTableRemoveSplit, _responseTypeRemoveSplit));
            actionAreaButtons.Add(new ActionAreaButton(_buttonTableAddSplit, _responseTypeAddSplit));
            actionAreaButtons.Add(new ActionAreaButton(_buttonOk, ResponseType.Ok));
            actionAreaButtons.Add(new ActionAreaButton(_buttonCancel, ResponseType.Cancel));

            // Init Start SplitButtons : After Action Buttons
            for (int i = 0; i < _intSplitPaymentStartClients; i++)
            {
                AddSplitButton(false);
            }

            //Init Object
            this.InitObject(this, pDialogFlags, fileDefaultWindowIcon, windowTitle, windowSize, _scrolledWindow, actionAreaButtons);

            // CalculateSplit to Calc and Assign Title after Dialog Construction
            CalculateSplit();
            // UpdateActionButtons
            UpdateActionButtons();
        }
Пример #24
0
        private void CalculateTotalPerSplit(ArticleBag articleBag, int numberOfSplits)
        {
            bool debug = false;

            // Calculate final Total Pay per Split
            _totalPerSplit = articleBag.TotalFinal / numberOfSplits;

            try
            {
                // Always Init ArticleBags
                foreach (TouchButtonSplitPayment item in _splitPaymentButtons)
                {
                    item.ArticleBag = new ArticleBag();
                }

                // Init Object to Use priceTax on above Loop
                //Get Place Objects to extract TaxSellType Normal|TakeWay, Place, Tables etc
                OrderMain currentOrderMain = GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid];
                pos_configurationplace configurationPlace = (pos_configurationplace)GlobalFramework.SessionXpo.GetObjectByKey(typeof(pos_configurationplace), currentOrderMain.Table.PlaceId);

                // Loop articleBag, and Add the quantity for Each Split (Total Article Quantity / numberOfSplits)
                foreach (var article in articleBag)
                {
                    // Default quantity to add to all Splitters, last one gets the extra Remains ex 0,0000000000001
                    decimal articleQuantity = (article.Value.Quantity / numberOfSplits);
                    // Store Remain Quantity
                    decimal articleQuantityRemain = article.Value.Quantity;
                    // Check if Total is equal to Origin
                    decimal articleQuantityCheck       = 0.0m;
                    decimal articleQuantityCheckModulo = 0.0m;
                    // Reset t
                    int t = 0;
                    foreach (TouchButtonSplitPayment touchButtonSplitPayment in _splitPaymentButtons)
                    {
                        t++;
                        // Discount articleQuantityRemain
                        articleQuantityRemain = articleQuantityRemain - articleQuantity;
                        if (t.Equals(_splitPaymentButtons.Count))
                        {
                            // Override Default split Quantity, adding extra Remain
                            articleQuantity += articleQuantityRemain;
                        }

                        // Add to articleQuantityCheck
                        articleQuantityCheck += articleQuantity;
                        // Modulo
                        articleQuantityCheckModulo = article.Value.Quantity % articleQuantityCheck;

                        if (debug)
                        {
                            _log.Debug(string.Format("#{0} Designation: [{1}], PriceFinal: [{2}], Quantity: [{3}]:[{4}]:[{5}]:[{6}]:[{7}]",
                                                     t, article.Key.Designation, article.Value.PriceFinal, article.Value.Quantity, articleQuantity, articleQuantityRemain, articleQuantityCheck, articleQuantityCheckModulo)
                                       );
                        }

                        // ArticleBagKey
                        ArticleBagKey articleBagKey = new ArticleBagKey(
                            article.Key.ArticleOid,
                            article.Key.Designation,
                            article.Key.Price,
                            article.Key.Discount,
                            article.Key.Vat
                            );
                        //Detect and Assign VatExemptionReason to ArticleBak Key
                        if (article.Key.VatExemptionReasonOid != null && article.Key.VatExemptionReasonOid != Guid.Empty)
                        {
                            articleBagKey.VatExemptionReasonOid = article.Key.VatExemptionReasonOid;
                        }
                        // ArticleBagProperties
                        ArticleBagProperties articleBagProps = articleBagProps = new ArticleBagProperties(
                            configurationPlace.Oid,
                            currentOrderMain.Table.Oid,
                            (PriceType)configurationPlace.PriceType.EnumValue,
                            article.Value.Code,
                            articleQuantity,
                            article.Value.UnitMeasure
                            );

                        // Add to ArticleBag
                        touchButtonSplitPayment.ArticleBag.Add(articleBagKey, articleBagProps);
                    }
                }

                // After have all splitPaymentButtons ArticleBags (End of arraySplit.Count Loop)
                foreach (TouchButtonSplitPayment item in _splitPaymentButtons)
                {
                    // Require to Update ProcessFinanceDocumentParameter, like when we Close Payment Window, BEFORE UpdateTouchButtonSplitPaymentLabels
                    // This is to Update UI when we Add/Remove Splits, else Already filled Payments dont Update
                    // Only change ArticleBag
                    if (item.ProcessFinanceDocumentParameter != null)
                    {
                        fin_configurationpaymentmethod paymentMethod = (fin_configurationpaymentmethod)FrameworkUtils.GetXPGuidObject(typeof(fin_configurationpaymentmethod), item.ProcessFinanceDocumentParameter.PaymentMethod);
                        decimal totalDelivery = (paymentMethod.Token.Equals("MONEY"))
                            ? item.ProcessFinanceDocumentParameter.TotalDelivery
                            : item.ArticleBag.TotalFinal;

                        item.ProcessFinanceDocumentParameter = new ProcessFinanceDocumentParameter(
                            item.ProcessFinanceDocumentParameter.DocumentType, item.ArticleBag
                            )
                        {
                            PaymentMethod    = item.ProcessFinanceDocumentParameter.PaymentMethod,
                            PaymentCondition = item.ProcessFinanceDocumentParameter.PaymentCondition,
                            Customer         = item.ProcessFinanceDocumentParameter.Customer,
                            TotalDelivery    = totalDelivery,
                            // Require to Recalculate TotalChange
                            TotalChange = totalDelivery - item.ArticleBag.TotalFinal
                        };
                    }

                    // Always Update all Buttons, with and without ProcessFinanceDocumentParameter
                    UpdateTouchButtonSplitPaymentLabels(item);

                    // Update Window Title
                    //if (WindowTitle != null) WindowTitle = string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_split_payment, numberOfSplits, FrameworkUtils.DecimalToStringCurrency(totalFinal));
                    if (WindowTitle != null)
                    {
                        WindowTitle = string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_split_payment"), numberOfSplits, FrameworkUtils.DecimalToStringCurrency(_totalPerSplit));
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
        }
Пример #25
0
        /// <summary>
        /// Get Total of All Persistent Tickets (Without PartialPayments), Used to Update StatusBar, And Update OrderMain main Object
        /// </summary>
        public void UpdateTotals()
        {
            try
            {
                /* METHOD #2 : From Article Bag
                 * //OrderMain orderMain = GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid];
                 */
                ArticleBag articleBag = ArticleBag.TicketOrderToArticleBag(this);
                articleBag.UpdateTotals();
                //sqlTotalTickets
                string sqlTotalTickets = string.Format(@"
                    SELECT 
                        COUNT(*) AS TotalTickets    
                    FROM 
                        fin_documentorderticket
                    WHERE 
                        OrderMain = '{0}'
                ;"
                                                       , this.PersistentOid
                                                       );
                var totalTickets = GlobalFramework.SessionXpo.ExecuteScalar(sqlTotalTickets);

                //Assign Totals
                _globalTotalTickets  = (totalTickets != null) ? Convert.ToInt32(totalTickets) : 0;
                _globalTotalGross    = articleBag.TotalFinal;
                _globalTotalDiscount = articleBag.TotalDiscount;
                _globalTotalTax      = articleBag.TotalTax;
                _globalTotalFinal    = articleBag.TotalFinal;
                _globalTotalQuantity = articleBag.TotalQuantity;
                //Persist Final TotalOpen
                pos_configurationplacetable currentTable = (pos_configurationplacetable)FrameworkUtils.GetXPGuidObject(typeof(pos_configurationplacetable), _table.Oid);

                if (currentTable != null)
                {
                    //Required Reload, after ProcessFinanceDocument uowSession, else we get cached object, and apply changes to old object, ex we get a OpenedTable vs a ClosedTable by uowSession
                    currentTable.Reload();
                    currentTable.TotalOpen = _globalTotalFinal;
                    currentTable.Save();
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }

            /* METHOD 3 : When we Change table it dont Update GlobalDiscounts
             * //Get Total Order (Payed/Invoiced and NonPayed)
             * string sqlTotalViewOrders = string.Format(@"
             * SELECT
             *  SUM(ddTotalGross) AS TotalGross,
             *  SUM(ddTotalDiscount) AS TotalDiscount,
             *  SUM(ddTotalTax) AS TotalTax,
             *  SUM(ddTotalFinal) AS TotalFinal,
             *  SUM(ddQuantity) AS TotalQuantity
             * FROM
             *  view_orders
             * WHERE
             *  dmOid = '{0}'
             * ORDER BY
             *  dtTicketId,ddOrd;
             * ;"
             * , this.PersistentOid
             * );
             *
             * string sqlTotalViewDocumentFinance = string.Format(@"
             * SELECT
             *    SUM(fdTotalGross) AS TotalGross,
             *  SUM(fdTotalDiscount) AS TotalDiscount,
             *  SUM(fdTotalTax) AS TotalTax,
             *  SUM(fdTotalFinal) AS TotalFinal,
             *  SUM(fdQuantity) AS TotalQuantity
             * FROM
             *    view_documentfinance
             * WHERE
             *    fmSourceOrderMain = '{0}'
             * ;"
             * , this.PersistentOid
             * );
             *
             * string sqlTotalTickets = string.Format(@"
             * SELECT
             *  COUNT(*) AS TotalTickets
             * FROM
             *  fin_documentorderticket
             * WHERE
             *  OrderMain = '{0}'
             * ;"
             * , this.PersistentOid
             * );
             *
             * try
             * {
             * XPSelectData sdTotalViewOrders = FrameworkUtils.GetSelectedDataFromQuery(sqlTotalViewOrders);
             * XPSelectData sdTotalViewDocumentFinance = FrameworkUtils.GetSelectedDataFromQuery(sqlTotalViewDocumentFinance);
             *
             * if (sdTotalViewOrders.Data.Length > 0 && sdTotalViewDocumentFinance.Data.Length > 0)
             * {
             *  //TotalGross
             *  _globalTotalGross =
             *    Convert.ToDecimal(sdTotalViewOrders.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalGross")]) -
             *    Convert.ToDecimal(sdTotalViewDocumentFinance.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalGross")]);
             *  //TotalDiscount
             *  _globalTotalDiscount =
             *    Convert.ToDecimal(sdTotalViewOrders.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalDiscount")]) -
             *    Convert.ToDecimal(sdTotalViewDocumentFinance.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalDiscount")]);
             *  //TotalTax
             *  _globalTotalTax =
             *    Convert.ToDecimal(sdTotalViewOrders.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalTax")]) -
             *    Convert.ToDecimal(sdTotalViewDocumentFinance.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalTax")]);
             *  //TotalFinal
             *  _globalTotalFinal =
             *    Convert.ToDecimal(sdTotalViewOrders.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalFinal")]) -
             *    Convert.ToDecimal(sdTotalViewDocumentFinance.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalFinal")]);
             *  //TotalQuantity
             *  _globalTotalQuantity =
             *    Convert.ToDecimal(sdTotalViewOrders.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalQuantity")]) -
             *    Convert.ToDecimal(sdTotalViewDocumentFinance.Data[0].Values[sdTotalViewOrders.GetFieldIndex("TotalQuantity")]);
             * }
             *
             * //sqlTotalTickets
             * var totalTickets = GlobalFramework.SessionXpo.ExecuteScalar(sqlTotalTickets);
             * _globalTotalTickets = (totalTickets != null) ? Convert.ToInt32(totalTickets) : 0;
             *
             * //Persist Final TotalOpen
             * ConfigurationPlaceTable currentTable = (ConfigurationPlaceTable)FrameworkUtils.GetXPGuidObjectFromSession(typeof(ConfigurationPlaceTable), _table.Oid);
             * currentTable.TotalOpen = _globalTotalFinal;
             * currentTable.Save();
             * }
             * catch (Exception ex)
             * {
             * _log.Error(ex.Message, ex);
             * }
             */

            /* OLD DEPRECATED METHOD #1 : Bugged In Orders with PartialPayments
             * bool debug = false;
             *
             * //Settings
             *
             * //Always Reset Totals, With Persistent and Non Persistent Orders
             * _globalNumOfTickets = 0;
             * _globalTotalGross = 0;
             * _globalTotalDiscount = 0;
             * _globalTotalTax = 0;
             * _globalTotalFinal = 0;
             *
             * //Get Current _persistentOid and _orderStatus from Database
             * _persistentOid = GetOpenTableFieldValueGuid(_table.Oid, "Oid");
             * _orderStatus = (OrderStatus)GetOpenTableFieldValue(_table.Oid, "OrderStatus");
             *
             * if (_persistentOid != Guid.Empty)
             * {
             * CriteriaOperator binaryOperator = new BinaryOperator("OrderMain", _persistentOid, BinaryOperatorType.Equal);
             * XPCollection _xpcDocumentOrderTicket = new XPCollection(GlobalFramework.SessionXpo, typeof(DocumentOrderTicket), binaryOperator);
             *
             * //Required to ByPass Cache
             * _xpcDocumentOrderTicket.Reload();
             *
             * //Process DocumentOrderTickets Totals
             * if (_xpcDocumentOrderTicket.Count > 0)
             * {
             *  foreach (DocumentOrderTicket ticket in _xpcDocumentOrderTicket)
             *  {
             *    //Required to ByPass Cache
             *    ticket.OrderDetail.Reload();
             *
             *    //Increase Ticket
             *    _globalNumOfTickets++;
             *
             *    foreach (DocumentOrderDetail line in ticket.OrderDetail)
             *    {
             *      _globalTotalGross += line.TotalGross;
             *      _globalTotalDiscount += line.TotalDiscount;
             *      _globalTotalTax += line.TotalTax;
             *      _globalTotalFinal += line.TotalFinal;
             *      if (debug) _log.Debug(string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", line.Article.Oid, line.Designation, line.Price, line.Quantity, line.Discount, line.Vat));
             *    }
             *    _globalLastUser = ticket.UpdatedBy;
             *    _globalLastTerminal = ticket.UpdatedWhere;
             *  }
             * }
             *
             * //Process PartialPayed Items and Discount its Totals
             * CriteriaOperator binaryOperatorDocumentFinanceMaster = new BinaryOperator("SourceOrderMain", _persistentOid, BinaryOperatorType.Equal);
             * XPCollection _xpcDocumentFinanceMaster = new XPCollection(GlobalFramework.SessionXpo, typeof(DocumentFinanceMaster), binaryOperatorDocumentFinanceMaster);
             * if (_xpcDocumentFinanceMaster.Count > 0)
             * {
             *  foreach (DocumentFinanceMaster master in _xpcDocumentFinanceMaster)
             *  {
             *    //SEARCH#001 - Change here and in Other Search, to SYNC RESULTS
             *    //Only Discount items from ArticleBag if is NOT a TableConsult, in TableConsult keep Full ArticleBag From OrderMain
             *    if (master.DocumentType.Oid != new Guid(xpoOidDocumentFinanceTypeConferenceDocument))
             *    {
             *      foreach (DocumentFinanceDetail line in master.DocumentDetail)
             *      {
             *        _globalTotalGross -= line.TotalGross;
             *        _globalTotalDiscount -= line.TotalDiscount;
             *        _globalTotalTax -= line.TotalTax;
             *        _globalTotalFinal -= line.TotalFinal;
             *      }
             *    }
             *  }
             * }
             *
             * //Persist Final TotalOpen
             * ConfigurationPlaceTable currentTable = (ConfigurationPlaceTable)FrameworkUtils.GetXPGuidObjectFromSession(typeof(ConfigurationPlaceTable), _table.Oid);
             * currentTable.TotalOpen = _globalTotalFinal;
             * currentTable.Save();
             *
             * //Debug
             * //_log.Debug(string.Format("GetGlobalOrderSummary(): _table.Id:[{0}], _table.Name:[{1}]", _table.Id, _table.Name));
             * //_log.Debug(string.Format("GetGlobalOrderSummary(): _globalTotalGross [{0}]", _globalTotalGross));
             * //_log.Debug(string.Format("GetGlobalOrderSummary(): _globalTotalTax [{0}]", _globalTotalTax));
             * //_log.Debug(string.Format("GetGlobalOrderSummary(): _globalTotalDiscount [{0}]", _globalTotalDiscount));
             * //_log.Debug(string.Format("GetGlobalOrderSummary(): _globalTotalFinal [{0}]", _globalTotalFinal));
             * //_log.Debug(string.Format("GetGlobalOrderSummary(): _globalNumOfTickets [{0}]", _globalNumOfTickets));
             * //if (_globalLastUser != null) _log.Debug(string.Format("GetGlobalOrderSummary(): _globalLastUser.Name [{0}]", _globalLastUser.Name));
             * //if (_globalLastTerminal != null) _log.Debug(string.Format("GetGlobalOrderSummary(): _globalLastTerminal.Designation [{0}]", _globalLastTerminal.Designation));
             * }
             */
        }
Пример #26
0
        void buttonTableConsult_Clicked(object sender, EventArgs e)
        {
            try
            {
                //Get Current OrderMain
                OrderMain currentOrderMain = GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid];
                //Initialize ArticleBag to Send to ProcessFinanceDocuments or Compare
                ArticleBag articleBag = ArticleBag.TicketOrderToArticleBag(currentOrderMain);

                //Get Latest DocumentConference Document without Recreate it if Diference, compare it in Above Line
                FIN_DocumentFinanceMaster lastDocument = FrameworkUtils.GetOrderMainLastDocumentConference(false);

                //Reprint Existing Document After compare with current ArticleBag
                if (
                    lastDocument != null && articleBag != null &&
                    lastDocument.TotalFinal.Equals(articleBag.TotalFinal) && lastDocument.DocumentDetail.Count.Equals(articleBag.Count)
                    )
                {
                    FrameworkCalls.PrintFinanceDocument(this, lastDocument);
                }
                //Else Create new DocumentConference recalling FrameworkUtils.GetOrderMainLastDocumentConference with true to Create New One
                else
                {
                    try
                    {
                        //Call Recreate New Document
                        FIN_DocumentFinanceMaster newDocument = FrameworkUtils.GetOrderMainLastDocumentConference(true);

                        //Call Print New Document
                        FrameworkCalls.PrintFinanceDocument(this, newDocument);
                    }
                    catch (Exception ex)
                    {
                        string errorMessage = string.Empty;

                        switch (ex.Message)
                        {
                        case "ERROR_MISSING_SERIE":
                            errorMessage = string.Format(Resx.dialog_message_error_creating_financial_document, Resx.dialog_message_error_creating_financial_document_missing_series);
                            break;

                        case "ERROR_COMMIT_FINANCE_DOCUMENT_PAYMENT":
                        default:
                            errorMessage = string.Format(Resx.dialog_message_error_creating_financial_document, ex.Message);
                            break;
                        }
                        Utils.ShowMessageTouch(
                            _sourceWindow,
                            DialogFlags.Modal,
                            new Size(600, 400),
                            MessageType.Error,
                            ButtonsType.Close,
                            Resx.global_error,
                            errorMessage
                            );

                        this.Run();
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
            finally
            {
                this.Destroy();
            }
        }
Пример #27
0
        public ArticleBag GetArticleBag()
        {
            Decimal                             customerDiscount = FrameworkUtils.StringToDecimal(_pagePad2.EntryBoxCustomerDiscount.EntryValidation.Text);
            ArticleBag                          articleBag       = new ArticleBag(customerDiscount);
            ArticleBagKey                       articleBagKey;
            ArticleBagProperties                articleBagProps;
            FIN_Article                         article;
            FIN_ConfigurationVatRate            configurationVatRate;
            FIN_ConfigurationVatExemptionReason configurationVatExemptionReason;

            //DocumentParent/SourceDocument
            FIN_DocumentFinanceMaster sourceFinanceMaster = null;
            string referencesReason = string.Empty;

            if (
                _pagePad1.EntryBoxSelectDocumentFinanceType.Value.Oid == SettingsApp.XpoOidDocumentFinanceTypeCreditNote &&
                _pagePad1.EntryBoxSelectSourceDocumentFinance.Value != null &&
                _pagePad1.EntryBoxSelectSourceDocumentFinance.Value.Oid != new Guid()
                )
            {
                Guid guidDocumentParent = _pagePad1.EntryBoxSelectSourceDocumentFinance.Value.Oid;
                //Get Source Document
                sourceFinanceMaster = (FIN_DocumentFinanceMaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_DocumentFinanceMaster), guidDocumentParent);
                referencesReason    = _pagePad1.EntryBoxReason.EntryValidation.Text;
            }
            ;

            foreach (DataRow item in _pagePad3.TreeViewArticles.DataSource.Rows)
            {
                article = (item["Article.Code"] as FIN_Article);
                configurationVatRate            = (item["ConfigurationVatRate.Value"] as FIN_ConfigurationVatRate);
                configurationVatExemptionReason = (item["VatExemptionReason.Acronym"] as FIN_ConfigurationVatExemptionReason);

                //Prepare articleBag Key and Props
                articleBagKey = new ArticleBagKey(
                    new Guid(item["Oid"].ToString()),
                    article.Designation,
                    Convert.ToDecimal(item["Price"]),   //Always use Price in DefaultCurrency
                    Convert.ToDecimal(item["Discount"]),
                    configurationVatRate.Value,
                    //If has a Valid ConfigurationVatExemptionReason use it Else send New Guid
                    (configurationVatExemptionReason != null) ? configurationVatExemptionReason.Oid : new Guid()
                    );
                articleBagProps = new ArticleBagProperties(
                    new Guid(),       //pPlaceOid,
                    new Guid(),       //pTableOid,
                    PriceType.Price1, //pPriceType,
                    article.Code,
                    Convert.ToDecimal(item["Quantity"]),
                    article.UnitMeasure.Acronym
                    );

                // Notes
                if (!string.IsNullOrEmpty(item["Notes"].ToString()))
                {
                    articleBagProps.Notes = item["Notes"].ToString();
                }

                //Assign DocumentMaster Reference and Reason to ArticleBag item
                if (sourceFinanceMaster != null)
                {
                    articleBagProps.Reference = sourceFinanceMaster;
                    articleBagProps.Reason    = referencesReason;
                }

                articleBag.Add(articleBagKey, articleBagProps);
            }

            return(articleBag);
        }
Пример #28
0
        public static ArticleBag GetArticleBag(bool pForceErrors)
        {
            ArticleBag           articleBag = new ArticleBag(10);
            Guid                 xpoOidConfigurationPlaceDefault = new Guid(GlobalFramework.Settings["xpoOidConfigurationPlaceDefault"]);
            Guid                 xpoOidConfigurationPlaceTableDefaultOpenTable = new Guid(GlobalFramework.Settings["xpoOidConfigurationPlaceTableDefaultOpenTable"]);
            ArticleBagKey        articleBagKey;
            ArticleBagProperties articleBagProps;

            Dictionary <Guid, decimal> mockArticles = new Dictionary <Guid, decimal>();

            //P:Products
            mockArticles.Add(new Guid("133cc225-517d-4c24-88b0-cd7c08cf5727"), 2.0m);
            mockArticles.Add(new Guid("4c47be72-6174-4e63-a077-f3cdb6a15e97"), 3.0m);
            mockArticles.Add(new Guid("0f32da9c-e533-489d-8a46-d6da79fd63a0"), 3.0m);
            mockArticles.Add(new Guid("6b547918-769e-4f5b-bcd6-01af54846f73"), 4.0m);
            mockArticles.Add(new Guid("42cd7f86-97b2-44f4-b098-3c9f0ae9f4b5"), 5.0m);
            mockArticles.Add(new Guid("55892c3f-de10-4076-afde-619c54100c9b"), 6.0m);
            mockArticles.Add(new Guid("fc109711-edb0-41dc-87b6-0acb77abd341"), 7.0m);
            mockArticles.Add(new Guid("bf99351b-1556-43c4-a85c-90082fb02d05"), 8.0m);
            mockArticles.Add(new Guid("11062ec9-fed0-43eb-a23e-c6f7ed83ff72"), 9.0m);
            mockArticles.Add(new Guid("32deb30d-ffa2-45e4-bca6-03569b9e8b08"), 2.0m);
            mockArticles.Add(new Guid("78638720-e728-4e96-8643-6d6267ff817b"), 2.0m);
            mockArticles.Add(new Guid("42c327e2-4aad-41ea-b5b6-e2198c337f1c"), 3.0m);
            mockArticles.Add(new Guid("0d30bf31-ecc4-452e-9b43-ee9d5c1d7fb6"), 4.0m);
            mockArticles.Add(new Guid("7b45a01d-50ee-42d3-a4af-0dcde9397e93"), 5.0m);
            mockArticles.Add(new Guid("630ff869-e433-46bb-a53b-563c43535424"), 6.0m);
            mockArticles.Add(new Guid("f71b3648-bb41-4952-ac75-ee93ccf0ec66"), 7.0m);
            mockArticles.Add(new Guid("87ff6f3a-c858-4829-bbcb-c6ea395129da"), 8.0m);
            mockArticles.Add(new Guid("72e8bde8-d03b-4637-90f1-fcb265658af0"), 9.0m);
            //S:Services
            mockArticles.Add(new Guid("5a852060-43b9-4e71-a230-b733bb150427"), 3.0m);
            mockArticles.Add(new Guid("072db1bf-6182-43de-8065-d4bbd8c9f8c2"), 4.0m);

            foreach (var item in mockArticles)
            {
                fin_article article = (fin_article)FrameworkUtils.GetXPGuidObject(GlobalFramework.SessionXpo, typeof(fin_article), item.Key);

                articleBagKey = new ArticleBagKey(
                    article.Oid,
                    article.Designation,
                    article.Price1,
                    article.Discount,
                    article.VatOnTable.Value
                    );
                articleBagProps = new ArticleBagProperties(
                    xpoOidConfigurationPlaceDefault,
                    xpoOidConfigurationPlaceTableDefaultOpenTable,
                    PriceType.Price1,
                    article.Code,
                    item.Value,
                    article.UnitMeasure.Acronym
                    );

                if (!pForceErrors)
                {
                    //Detect and Add TaxExceptionReason if Miss to Prevent Errors
                    if (articleBagKey.Vat == 0.0m && articleBagKey.VatExemptionReasonOid == Guid.Empty)
                    {
                        articleBagKey.VatExemptionReasonOid = SettingsApp.XpoOidConfigurationVatExemptionReasonM99;
                    }

                    //Add Price to Services, else we have Error with Price 0
                    if (article.Class.Acronym == "S")
                    {
                        articleBagKey.Price = 10.28m;
                    }
                }

                //Send to Bag
                articleBag.Add(articleBagKey, articleBagProps);
            }

            if (pForceErrors)
            {
                //Add Error Article after Loop
                articleBagKey = new ArticleBagKey(
                    Guid.Empty, //Oid
                    "§",        //Designation
                    -1,         //Price
                    101,        //Discount
                    0           //VatOnTable
                    );
                articleBagProps = new ArticleBagProperties(
                    xpoOidConfigurationPlaceDefault,
                    xpoOidConfigurationPlaceTableDefaultOpenTable,
                    PriceType.Price1,
                    string.Empty,   //Code
                    -1,             //Quantity
                    "§"             //UnitMeasure.Acronym
                    );
                //Add Error Article
                articleBag.Add(articleBagKey, articleBagProps);
                //Assign Error after add To ArticleBag
                articleBagKey.Vat = -1;
            }

            return(articleBag);
        }
Пример #29
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //OrderMain/Document Conferences

        //Works in Dual Mode based on pGenerateNewIfDiferentFromArticleBag, sometimes passes 2 times, on for get last document and other to create new one
        //Mode1 : GenerateNewIfDiferentFromArticleBag = false : Returns Last Conference Document for Current Working Order Main
        //Mode2 : GenerateNewIfDiferentFromArticleBag = true : Returns Last or New Conference Document if Current Working Order Main is Diferent from working currente Working OrderMain ArticleBag
        //Returns Last|New DocumentConference, for table current OrderMain
        //GenerateNewIfDiferentFromArticleBag : Used to generate a new Document if latest Document has been changed (Compare it to current ArticleBag),
        //else if false use the latest on Database ignoring Diferences, Used to Get latest DocumentConference to use in Generate DocumentConference PosOrdersDialog.buttonTableConsult_Clicked
        public static FIN_DocumentFinanceMaster GetOrderMainLastDocumentConference(bool pGenerateNewIfDiferentFromArticleBag = false)
        {
            //Declare local Variables
            FIN_DocumentFinanceMaster lastDocument = null;
            FIN_DocumentFinanceMaster newDocument  = null;
            FIN_DocumentFinanceMaster result       = null;
            FIN_DocumentOrderMain     orderMain    = null;
            Guid      currentOrderMainOid          = GlobalFramework.SessionApp.CurrentOrderMainOid;
            OrderMain currentOrderMain             = GlobalFramework.SessionApp.OrdersMain[currentOrderMainOid];

            try
            {
                string sql = string.Format(@"
                    SELECT 
	                    Oid
                    FROM 
	                    FIN_documentfinancemaster 
                    WHERE 
	                    DocumentType = '{0}' AND 
	                    SourceOrderMain = '{1}'
                    ORDER BY 
	                    CreatedAt DESC;
                    "
                                           , SettingsApp.XpoOidDocumentFinanceTypeConferenceDocument
                                           , currentOrderMain.PersistentOid
                                           );

                var sqlResult = GlobalFramework.SessionXpo.ExecuteScalar(sql);

                //Get LastDocument Object
                if (sqlResult != null)
                {
                    lastDocument = (FIN_DocumentFinanceMaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_DocumentFinanceMaster), new Guid(Convert.ToString(sqlResult)));
                }

                //If GenerateNewIfDiferentFromArticleBag Enabled compare ArticleBag with Document and If is diferent Generate a New One
                if (pGenerateNewIfDiferentFromArticleBag)
                {
                    //Initialize ArticleBag to Compare with Order Detail and use in ProcessFinanceDocuments
                    ArticleBag articleBag = ArticleBag.TicketOrderToArticleBag(currentOrderMain);
                    //Check if Total is Not Equal and Generate New DocumentConference, This way it will be Equal to Invoice
                    if (
                        lastDocument == null ||
                        (!lastDocument.TotalFinal.Equals(articleBag.TotalFinal) || !lastDocument.DocumentDetail.Count.Equals(articleBag.Count))
                        )
                    {
                        //Prepare ProcessFinanceDocumentParameter
                        ProcessFinanceDocumentParameter processFinanceDocumentParameter = new ProcessFinanceDocumentParameter(SettingsApp.XpoOidDocumentFinanceTypeConferenceDocument, articleBag)
                        {
                            Customer = SettingsApp.XpoOidDocumentFinanceMasterFinalConsumerEntity
                        };

                        orderMain = (FIN_DocumentOrderMain)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_DocumentOrderMain), currentOrderMain.PersistentOid);
                        processFinanceDocumentParameter.SourceOrderMain = orderMain;
                        if (lastDocument != null)
                        {
                            processFinanceDocumentParameter.DocumentParent  = lastDocument.Oid;
                            processFinanceDocumentParameter.OrderReferences = new List <FIN_DocumentFinanceMaster>();
                            processFinanceDocumentParameter.OrderReferences.Add(lastDocument);
                        }

                        //Generate New Document
                        newDocument = ProcessFinanceDocument.PersistFinanceDocument(processFinanceDocumentParameter, false);

                        //Assign DocumentStatus and OrderReferences
                        if (newDocument != null)
                        {
                            //Assign Result Document to New Document
                            //Get Object outside UOW else we have a problem with "A first chance exception of type 'System.ObjectDisposedException'"
                            result = (FIN_DocumentFinanceMaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_DocumentFinanceMaster), newDocument.Oid);

                            ////Old Code that changes last Conference Document to Status "A", it is not Required, Confirmed with Carlos Bento, we must Leave it without status changes
                            //if (lastDocument != null)
                            //{
                            //    lastDocument.DocumentStatusStatus = "A";
                            //    lastDocument.DocumentStatusDate = newDocument.DocumentStatusDate;
                            //    lastDocument.DocumentStatusUser = newDocument.DocumentStatusUser;
                            //    lastDocument.SystemEntryDate = newDocument.SystemEntryDate;
                            //    lastDocument.Save();
                            //}
                        }
                    }
                }
                else
                {
                    result = lastDocument;
                }
            }
            catch (Exception ex)
            {
                // Send Exception to logicpos, must treat exception in ui, to Show Alert to User
                throw ex;
            }

            return(result);
        }
Пример #30
0
        //Payments and SplitAccount (Shared for Both Actions)
        void _buttonKeyPayments_Clicked(object sender, EventArgs e)
        {
            TouchButtonIconWithText button = (sender as TouchButtonIconWithText);

            try
            {
                //Used when we pay without FinishOrder, to Skip print Ticket
                bool printTicket = false;

                //Request Finish Open Ticket
                if (_listStoreModelTotalItemsTicketListMode > 0)
                {
                    ResponseType dialogResponse = Utils.ShowMessageTouch(_sourceWindow, DialogFlags.DestroyWithParent, MessageType.Question, ButtonsType.OkCancel, Resx.window_title_dialog_message_dialog, Resx.dialog_message_request_close_open_ticket);
                    if (dialogResponse != ResponseType.Ok)
                    {
                        return;
                    }
                    ;
                }
                ;

                //Get Reference to current OrderMain
                OrderMain orderMain = GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid];

                //Finish Order, if Has Ticket Details
                if (orderMain.OrderTickets[orderMain.CurrentTicketId].OrderDetails.Lines.Count > 0)
                {
                    //Before Use FrameworkCall
                    orderMain.FinishOrder(GlobalFramework.SessionXpo, printTicket);
                    //TODO: Continue to implement FrameworkCall here
                    //DocumentOrderTicket documentOrderTicket = orderMain.FinishOrder(GlobalFramework.SessionXpo, printTicket);
                    //if (printTicket) FrameworkCalls.PrintTableTicket(_sourceWindow, GlobalFramework.LoggedTerminal.Printer, GlobalFramework.LoggedTerminal.TemplateTicket, orderMain, documentOrderTicket.Oid);

                    //Reset TicketList TotalItems Counter
                    _listStoreModelTotalItemsTicketListMode = 0;
                }

                //Always Change to OrderMain ListMode before Update Model
                _listMode = TicketListMode.OrderMain;

                //Update Model and Gui
                UpdateModel();
                UpdateOrderStatusBar();
                UpdateTicketListOrderButtons();

                //Initialize ArticleBag to Send to Payment Dialog
                ArticleBag articleBag = ArticleBag.TicketOrderToArticleBag(orderMain);

                // Shared Referencesfor Dialog
                PosBaseDialog dialog = null;

                // Get Dialog Reference
                if (button.Name.Equals("touchButtonPosTicketPadPayments_Green"))
                {
                    dialog = new PosPaymentsDialog(_sourceWindow, DialogFlags.DestroyWithParent, articleBag);
                }
                else
                if (button.Name.Equals("touchButtonPosTicketPadSplitAccount_Green"))
                {
                    dialog = new PosSplitPaymentsDialog(_sourceWindow, DialogFlags.DestroyWithParent, _articleBag, this);
                }

                // Shared code to call Both Dialogs
                ResponseType response = (ResponseType)dialog.Run();

                if (response == ResponseType.Ok)
                {
                    //Update Cleaned TreeView Model
                    UpdateModel();
                    UpdateOrderStatusBar();
                    UpdateTicketListOrderButtons();
                    //IMPORTANT & REQUIRED: Assign Current Order Details from New CurrentTicketId, ELSE we cant add items to OrderMain
                    CurrentOrderDetails = orderMain.OrderTickets[orderMain.CurrentTicketId].OrderDetails;
                    //Valid Result Destroy Dialog
                    dialog.Destroy();
                }
                ;
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
        }