Пример #1
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);
        }
Пример #2
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //FinanceDocumentPayments

        public static fin_documentfinancepayment PersistFinanceDocumentPayment()
        {
            //All Documents, usefull to Split into Invoices and CreditNotes
            List <Guid> listDocuments = new List <Guid>();
            List <fin_documentfinancemaster> listInvoices    = new List <fin_documentfinancemaster>();
            List <fin_documentfinancemaster> listCreditNotes = new List <fin_documentfinancemaster>();

            //listDocuments.Add(new Guid("a067b55b-09b5-4a48-a386-e9d04777540b"));//NC NCCKOQ5R5012016S001/1
            //listDocuments.Add(new Guid("92c5c809-0387-4d1f-93c6-afeb6f291149"));//FT FTCKOQ5R5012016S001/1
            //Used
            listDocuments.Add(new Guid("e00cde4c-2218-4c03-ac4b-161b2b89032b")); //NC NCCKOQ5R5012016S001/2
            listDocuments.Add(new Guid("ed8e5198-f253-4198-be18-fff188a7d3b4")); //NC NCCKOQ5R5012016S001/3
            listDocuments.Add(new Guid("dc4b8170-2b61-4ed4-ad8b-77aaf8a4c695")); //FT FTCKOQ5R5012016S001/3
            listDocuments.Add(new Guid("36e49eb1-5e94-47e4-9467-8365ec71e099")); //FT FTCKOQ5R5012016S001/4
            listDocuments.Add(new Guid("529f5d2d-4202-4207-b15f-2d58d56c4ebe")); //FT FTCKOQ5R5012016S001/6

            //Force Errors : Invalid Documents
            listDocuments.Add(new Guid("41ba3dfa-8afa-48bd-aa56-1b51015e7c0c")); //GT GTCKOQ5R5012016S001/1 Mário Fernandes invalid document + diferent customer
            listDocuments.Add(new Guid("a067b55b-09b5-4a48-a386-e9d04777540b")); //NC NCCKOQ5R5012016S001/1 Carlos Fernandes Payed
            listDocuments.Add(new Guid("92c5c809-0387-4d1f-93c6-afeb6f291149")); //FT FTCKOQ5R5012016S001/1 Carlos Fernandes Payed
            listDocuments.Add(new Guid("2813d769-3065-44fb-b48f-a8f7a42a0456")); //FT FTCKOQ5R5012016S001/5 Carlos DocumentStatusStatus = A

            //Other Parameters
            //decimal paymentAmount = 28.17m;//Euro
            decimal paymentAmount = 517.06m;//Kwanza
            string  paymentNotes  = "$#%#$&%»»'@£§€";

            //Prepare listInvoices and listCreditNotes
            foreach (Guid item in listDocuments)
            {
                fin_documentfinancemaster documentFinanceMaster = (fin_documentfinancemaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(fin_documentfinancemaster), item);

                if (documentFinanceMaster.DocumentType.Credit)
                {
                    listInvoices.Add(documentFinanceMaster);
                }
                else
                {
                    listCreditNotes.Add(documentFinanceMaster);
                }
            }

            fin_documentfinancepayment documentFinancePayment = ProcessFinanceDocument.PersistFinanceDocumentPayment(listInvoices, listCreditNotes, SettingsApp.XpoOidDocumentCustomer, SettingsApp.XpoOidDocumentPaymentMethod, SettingsApp.XpoOidDocumentCurrency, paymentAmount, paymentNotes);

            if (documentFinancePayment != null)
            {
                Console.WriteLine(string.Format("documentFinancePayment.PaymentRefNo: [{0}]", documentFinancePayment.PaymentRefNo));
                sys_configurationprinterstemplates template = ProcessFinanceDocumentSeries.GetDocumentFinanceYearSerieTerminal(GlobalFramework.SessionXpo, documentFinancePayment.DocumentType.Oid).Template;
                //TK016249 - Impressoras - Diferenciação entre Tipos
                PrintRouter.PrintFinanceDocumentPayment(GlobalFramework.LoggedTerminal.ThermalPrinter, documentFinancePayment);
            }

            return(documentFinancePayment);
        }
Пример #3
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

        public static bool PrintFinanceDocument(SYS_ConfigurationPrinters pPrinter, FIN_DocumentFinanceMaster pDocumentFinanceMaster, List <int> pCopyNames, bool pSecondCopy, string pMotive)
        {
            bool result = false;

            if (pPrinter != null)
            {
                //Init Helper Vars
                bool resultSystemPrint = false;
                int  printCopies       = pCopyNames.Count;
                //Get Hash4Chars from Hash
                string hash4Chars = ProcessFinanceDocument.GenDocumentHash4Chars(pDocumentFinanceMaster.Hash);

                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":
                    //Impressora SINOCAN em ambiente WindowsLinux/USB
                    case "THERMAL_PRINTER_USB":
                        ThermalPrinterFinanceDocumentMaster thermalPrinterFinanceDocument = new ThermalPrinterFinanceDocumentMaster(pPrinter, pDocumentFinanceMaster, pCopyNames, pSecondCopy, pMotive);
                        thermalPrinterFinanceDocument.Print();
                        //Add to SystemPrint Audit
                        resultSystemPrint = SystemPrintInsert(pDocumentFinanceMaster, pPrinter.Designation, printCopies, pCopyNames, pSecondCopy, pMotive);
                        break;

                    case "GENERIC_PRINTER_WINDOWS":
                        CustomReport.ProcessReportFinanceDocument(CustomReportDisplayMode.Print, pDocumentFinanceMaster.Oid, hash4Chars, pCopyNames, pSecondCopy, pMotive);
                        //Add to SystemPrint Audit
                        resultSystemPrint = SystemPrintInsert(pDocumentFinanceMaster, pPrinter.Designation, printCopies, pCopyNames, pSecondCopy, pMotive);
                        break;

                    case "REPORT_EXPORT_PDF":
                        CustomReport.ProcessReportFinanceDocument(CustomReportDisplayMode.ExportPDF, pDocumentFinanceMaster.Oid, hash4Chars, pCopyNames, pSecondCopy, pMotive);
                        //Add to SystemPrint Audit : Developer : Use here Only to Test SystemPrintInsert
                        resultSystemPrint = SystemPrintInsert(pDocumentFinanceMaster, pPrinter.Designation, printCopies, pCopyNames, pSecondCopy, pMotive);
                        break;
                    }
                    result = true;
                }
                catch (Exception ex)
                {
                    _log.Warn(ex.Message, ex);
                    throw new Exception(ex.Message);
                }
            }

            return(result);
        }
Пример #4
0
        //Override Parent Template
        public override void PrintContent()
        {
            try
            {
                //Call base PrintDocumentMaster();
                base.PrintDocumentMaster(_documentFinanceMasterList[0].DocumentTypeResourceString, _documentFinanceMasterList[0].DocumentNumber, _documentFinanceMasterList[0].DocumentDate);

                //Call
                PrintDocumentMasterDocumentType();

                //Call base PrintCustomer();
                base.PrintCustomer(
                    _documentFinanceMasterList[0].EntityName,
                    _documentFinanceMasterList[0].EntityAddress,
                    _documentFinanceMasterList[0].EntityZipCode,
                    _documentFinanceMasterList[0].EntityCity,
                    _documentFinanceMasterList[0].EntityCountry,
                    _documentFinanceMasterList[0].EntityFiscalNumber
                    );

                PrintDocumentDetails();
                PrintMasterTotals();
                PrintMasterTotalTax();
                PrintDocumenWayBillDetails();

                //Call base PrintDocumentPaymentDetails();
                base.PrintDocumentPaymentDetails(string.Empty, _documentFinanceMasterList[0].PaymentMethodDesignation, _documentFinanceMasterList[0].CurrencyAcronym); /* IN009055 */

                //Call base PrintNotes();
                //IN009279 Wont print notes on ticket mode
                if (_documentFinanceMasterList[0].Notes != null && !GlobalFramework.AppUseParkingTicketModule)
                {
                    base.PrintNotes(_documentFinanceMasterList[0].Notes.ToString());
                }

                //Only Print if is in Portugal ex "Os artigos faturados...."
                //Call base PrintDocumentTypeFooterString();
                if (SettingsApp.ConfigurationSystemCountry.Oid == SettingsApp.XpoOidConfigurationCountryPortugal || SettingsApp.ConfigurationSystemCountry.Oid == SettingsApp.XpoOidConfigurationCountryAngola)
                {
                    base.PrintDocumentTypeFooterString(_documentFinanceMasterList[0].DocumentTypeResourceStringReport);
                }

                //Get Hash4Chars from Hash
                string hash4Chars = ProcessFinanceDocument.GenDocumentHash4Chars(_documentMaster.Hash);
                //Call Base CertificationText
                base.PrintCertificationText(hash4Chars);
            }
            catch (Exception ex)
            {
                _log.Debug("override void PrintContent() :: Thermal Printer: " + ex.Message, ex);
                throw ex;
            }
        }
        //Override Parent Template
        public override void PrintContent()
        {
            try
            {
                //Call base PrintDocumentMaster();
                base.PrintDocumentMaster(_documentFinanceMasterList[0].DocumentTypeResourceString, _documentFinanceMasterList[0].DocumentNumber, _documentFinanceMasterList[0].DocumentDate);

                //Call
                PrintDocumentMasterDocumentType();

                //Call base PrintCustomer();
                base.PrintCustomer(
                    _documentFinanceMasterList[0].EntityName,
                    _documentFinanceMasterList[0].EntityAddress,
                    _documentFinanceMasterList[0].EntityZipCode,
                    _documentFinanceMasterList[0].EntityCity,
                    _documentFinanceMasterList[0].EntityCountry,
                    _documentFinanceMasterList[0].EntityFiscalNumber
                    );

                PrintDocumentDetails();
                PrintMasterTotals();
                PrintMasterTotalTax();
                PrintDocumenWayBillDetails();

                //Call base PrintDocumentPaymentDetails();
                base.PrintDocumentPaymentDetails(_documentFinanceMasterList[0].PaymentConditionDesignation, _documentFinanceMasterList[0].PaymentMethodDesignation, _documentFinanceMasterList[0].CurrencyAcronym);

                //Call base PrintNotes();
                if (_documentFinanceMasterList[0].Notes != null)
                {
                    base.PrintNotes(_documentFinanceMasterList[0].Notes.ToString());
                }

                //Only Print if is in Portugal ex "Os artigos faturados...."
                //Call base PrintDocumentTypeFooterString();
                if (SettingsApp.ConfigurationSystemCountry.Oid == SettingsApp.XpoOidConfigurationCountryPortugal)
                {
                    base.PrintDocumentTypeFooterString(_documentFinanceMasterList[0].DocumentTypeResourceStringReport);
                }

                //Get Hash4Chars from Hash
                string hash4Chars = ProcessFinanceDocument.GenDocumentHash4Chars(_documentMaster.Hash);
                //Call Base CertificationText
                base.PrintCertificationText(hash4Chars);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #6
0
        //public static string DocumentMasterCreatePDF(DocumentFinanceMaster pDocumentFinanceMaster, string pDestinationFileName, CustomReportDisplayMode pCustomReportDisplayMode)
        public static string DocumentMasterCreatePDF(CustomReportDisplayMode pViewMode, FIN_DocumentFinanceMaster pDocumentFinanceMaster, string pDestinationFileName)
        {
            string result = String.Empty;

            try
            {
                //Generate Default CopyNames from DocumentType
                List <int> copyNames  = CopyNames(pDocumentFinanceMaster.DocumentType.PrintCopies);
                string     hash4Chars = ProcessFinanceDocument.GenDocumentHash4Chars(pDocumentFinanceMaster.Hash);
                result = ProcessReportFinanceDocument(pViewMode, pDocumentFinanceMaster.Oid, hash4Chars, copyNames, pDestinationFileName);
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
            return(result);
        }
Пример #7
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);
        }
Пример #8
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //ProcessFinanceDocument
        //Use: DocumentFinanceMaster resultDocument = FrameworkCalls.ProcessFinanceDocument(SourceWindow, Invoices, CreditNotes, Customer, PaymentMethod, pPaymentAmount, pPaymentNotes);

        public static fin_documentfinancepayment PersistFinanceDocumentPayment(Window pSourceWindow, List <fin_documentfinancemaster> pInvoices, List <fin_documentfinancemaster> pCreditNotes, Guid pCustomer, Guid pPaymentMethod, Guid pConfigurationCurrency, decimal pPaymentAmount, string pPaymentNotes = "")
        {
            fin_documentfinancepayment result = null;

            try
            {
                fin_documentfinancepayment documentFinancePayment = ProcessFinanceDocument.PersistFinanceDocumentPayment(pInvoices, pCreditNotes, pCustomer, pPaymentMethod, pConfigurationCurrency, pPaymentAmount, pPaymentNotes);
                if (documentFinancePayment != null)
                {
                    //Always send back the Valid Document
                    result = documentFinancePayment;

                    //Print Document
                    PrintFinanceDocumentPayment(pSourceWindow, documentFinancePayment);
                }
            }
            catch (ProcessFinanceDocumentValidationException ex)
            {
                string errorMessage = string.Empty;

                switch (ex.Message)
                {
                case "ERROR_MISSING_SERIE":
                    errorMessage = string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_error_creating_financial_document"), resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_error_creating_financial_document_missing_series"));
                    break;

                case "ERROR_COMMIT_FINANCE_DOCUMENT_PAYMENT":
                default:
                    errorMessage = string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_error_creating_financial_document"), ex.Exception.Message);
                    break;
                }
                Utils.ShowMessageTouch(
                    pSourceWindow,
                    DialogFlags.Modal,
                    _sizeDefaultWindowSize,
                    MessageType.Error,
                    ButtonsType.Close,
                    resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_error"),
                    errorMessage
                    );
            }
            return(result);
        }
Пример #9
0
        // Test Document Report
        void TestDocumentReport()
        {
            Guid docOid = new Guid("6d44b0a8-6450-4245-b4ee-a6e971f4bcec");
            FIN_DocumentFinanceMaster documentFinanceMaster = (FIN_DocumentFinanceMaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(FIN_DocumentFinanceMaster), docOid);

            if (documentFinanceMaster != null)
            {
                //Generate Default CopyNames from DocumentType
                List <int> copyNames           = CustomReport.CopyNames(documentFinanceMaster.DocumentType.PrintCopies);
                string     hash4Chars          = ProcessFinanceDocument.GenDocumentHash4Chars(documentFinanceMaster.Hash);
                string     destinationFileName = "";
                string     result = CustomReport.ProcessReportFinanceDocument(CustomReportDisplayMode.Design, documentFinanceMaster.Oid, hash4Chars, copyNames, destinationFileName);
                _log.Debug(String.Format("Result: [{0}]", result));
            }
            else
            {
                _log.Debug(String.Format("Null Document Found for documentType: [{0}]", nameof(FIN_DocumentFinanceMaster), docOid.ToString()));
            }
        }
Пример #10
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);
        }
Пример #11
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //ProcessFinanceDocument
        //Use: DocumentFinanceMaster resultDocument = FrameworkCalls.ProcessFinanceDocument(SourceWindow, processFinanceDocumentParameter);

        public static fin_documentfinancemaster PersistFinanceDocument(Window pSourceWindow, ProcessFinanceDocumentParameter pProcessFinanceDocumentParameter)
        {
            bool printDocument = true;
            fin_documentfinancemaster result = null;

            try
            {
                //Protection to Check if SystemDate is < Last DocumentDate
                ResponseType responseType = Utils.ShowMessageTouchCheckIfFinanceDocumentHasValidDocumentDate(pSourceWindow, pProcessFinanceDocumentParameter);
                if (responseType != ResponseType.Yes)
                {
                    return(result);
                }

                fin_documentfinancemaster documentFinanceMaster = ProcessFinanceDocument.PersistFinanceDocument(pProcessFinanceDocumentParameter, true);
                fin_documentfinancedetailorderreference fin_documentfinancedetailorderreference = new fin_documentfinancedetailorderreference();
                if (documentFinanceMaster != null)
                {
                    //ATWS : SendDocumentToATWSDialog
                    if (SendDocumentToATWSEnabled(documentFinanceMaster))
                    {
                        SendDocumentToATWSDialog(pSourceWindow, documentFinanceMaster);
                    }
                    /* TK013134 - Parking Ticket Module */
                    foreach (var item in GlobalFramework.PendentPayedParkingTickets)
                    {
                        _log.Debug("[PARKING TICKET] Informing Access.Track that the parking ticket has been payed...");
                        AccessTrackParkingTicketService.TimeService accessTrackParkingTicketService = new AccessTrackParkingTicketService.TimeService();

                        bool isTicketPayedInformed = accessTrackParkingTicketService.payTicket(item.Key);


                        _log.Debug($"[PARKING TICKET] Barcode '{item.Key}' sent to Access.Track: Guid '{item.Value}'");

                        if (!isTicketPayedInformed)
                        {
                            _log.Debug($"[PARKING TICKET] Barcode '{item.Key}' not identified by Access.Track: Guid '{item.Value}'");
                        }
                        else if (accessTrackParkingTicketService.isTicketValid(item.Key))
                        {
                            _log.Debug($"[PARKING TICKET] Barcode '{item.Key}' payed successfully");
                        }
                        else
                        {
                            _log.Error($"[PARKING TICKET] Barcode '{item.Key}' payment has not been recognized by Access.Track!");
                        }
                    }
                    //IN009279 Parking ticket Service - implementar Cartão cliente
                    int i = 0;
                    foreach (var item in GlobalFramework.PendentPayedParkingCards)
                    {
                        _log.Debug("[PARKING TICKET] Informing Access.Track that the parking card has been payed...");
                        AccessTrackParkingTicketService.TimeService accessTrackParkingTicketService = new AccessTrackParkingTicketService.TimeService();

                        //Number of months paid is passed by document notes
                        string sql               = string.Format("SELECT Notes FROM fin_documentfinancemaster where SourceOrderMain = '{0}'", item.Value);
                        var    sqlResult         = GlobalFramework.SessionXpo.ExecuteScalar(sql);
                        string sqlResultquantity = sqlResult.ToString();

                        string[] quantity   = sqlResultquantity.Trim().Split(' ');
                        int      splitCount = quantity.Length;

                        int[] number = new int[splitCount];
                        if (quantity[i].Contains(","))
                        {
                            number[i] = int.Parse(quantity[i].Substring(0, quantity[i].IndexOf(','))); //Contains decimal separator
                        }
                        else
                        {
                            number[i] = int.Parse(quantity[i]); //Contains only numbers, no decimal separator.
                        }
                        DateTime localDate = DateTime.Now;
                        DateTime endDate   = localDate.AddMonths(Convert.ToInt32(number[i]));
                        string   dateNow   = localDate.ToString();
                        string   dateEnd   = endDate.ToString();
                        accessTrackParkingTicketService.payCard(item.Key, dateNow, dateEnd);
                        i++;
                    }//IN009279 ENDS

                    //Always Send back the Valid Document
                    result = documentFinanceMaster;


                    if (documentFinanceMaster.DocumentType.PrintRequestConfirmation)
                    {
                        responseType = Utils.ShowMessageTouch(
                            pSourceWindow,
                            DialogFlags.Modal,
                            MessageType.Question,
                            ButtonsType.YesNo,
                            resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_document_finance"),
                            resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_request_print_document_confirmation")
                            );

                        if (responseType == ResponseType.No)
                        {
                            printDocument = false;
                        }
                    }

                    //Print Document
                    if (printDocument)
                    {
                        PrintFinanceDocument(pSourceWindow, documentFinanceMaster);
                    }
                }
            }
            catch (Exception ex)
            {
                string errorMessage = string.Empty;

                switch (ex.Message)
                {
                case "ERROR_MISSING_SERIE":
                    errorMessage = string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_error_creating_financial_document"), resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_error_creating_financial_document_missing_series"));
                    break;

                case "ERROR_INVALID_DOCUMENT_NUMBER":
                    errorMessage = string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_error_creating_financial_document"), resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_error_creating_financial_document_invalid_documentnumber"));
                    break;

                case "ERROR_COMMIT_FINANCE_DOCUMENT":
                    errorMessage = string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_error_creating_financial_document"), resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_error_creating_financial_document_commit_session"));
                    break;

                //TODO: NEW CLASS FinanceDocumentValidate : IMPLEMENT HERE THE RESULT EXCEPTION FOR VALIDATE_SIMPLIFIED_INVOICE
                default:
                    errorMessage = string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_error_creating_financial_document"), ex.Message);
                    break;
                }
                Utils.ShowMessageTouch(
                    pSourceWindow,
                    DialogFlags.Modal,
                    _sizeDefaultWindowSize,
                    MessageType.Error,
                    ButtonsType.Close,
                    resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_error"),
                    errorMessage
                    );
            }

            return(result);
        }
Пример #12
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //ProcessFinanceDocument
        //Use: DocumentFinanceMaster resultDocument = FrameworkCalls.ProcessFinanceDocument(SourceWindow, processFinanceDocumentParameter);

        public static FIN_DocumentFinanceMaster PersistFinanceDocument(Window pSourceWindow, ProcessFinanceDocumentParameter pProcessFinanceDocumentParameter)
        {
            bool printDocument = true;
            FIN_DocumentFinanceMaster result = null;

            try
            {
                //Protection to Check if SystemDate is < Last DocumentDate
                ResponseType responseType = Utils.ShowMessageTouchCheckIfFinanceDocumentHasValidDocumentDate(pSourceWindow, pProcessFinanceDocumentParameter);
                if (responseType != ResponseType.Yes)
                {
                    return(result);
                }

                FIN_DocumentFinanceMaster documentFinanceMaster = ProcessFinanceDocument.PersistFinanceDocument(pProcessFinanceDocumentParameter, true);

                if (documentFinanceMaster != null)
                {
                    //ATWS : SendDocumentToATWSDialog
                    if (SendDocumentToATWSEnabled(documentFinanceMaster))
                    {
                        SendDocumentToATWSDialog(pSourceWindow, documentFinanceMaster);
                    }

                    //Always Send back the Valid Document
                    result = documentFinanceMaster;

                    if (documentFinanceMaster.DocumentType.PrintRequestConfirmation)
                    {
                        responseType = Utils.ShowMessageTouch(
                            pSourceWindow,
                            DialogFlags.Modal,
                            MessageType.Question,
                            ButtonsType.YesNo,
                            Resx.window_title_dialog_document_finance,
                            Resx.dialog_message_request_print_document_confirmation
                            );

                        if (responseType == ResponseType.No)
                        {
                            printDocument = false;
                        }
                    }

                    //Print Document
                    if (printDocument)
                    {
                        PrintFinanceDocument(pSourceWindow, documentFinanceMaster);
                    }
                }
            }
            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_INVALID_DOCUMENT_NUMBER":
                    errorMessage = string.Format(Resx.dialog_message_error_creating_financial_document, Resx.dialog_message_error_creating_financial_document_invalid_documentnumber);
                    break;

                case "ERROR_COMMIT_FINANCE_DOCUMENT":
                    errorMessage = string.Format(Resx.dialog_message_error_creating_financial_document, Resx.dialog_message_error_creating_financial_document_commit_session);
                    break;

                //TODO: NEW CLASS FinanceDocumentValidate : IMPLEMENT HERE THE RESULT EXCEPTION FOR VALIDATE_SIMPLIFIED_INVOICE
                default:
                    errorMessage = string.Format(Resx.dialog_message_error_creating_financial_document, ex.Message);
                    break;
                }
                Utils.ShowMessageTouch(
                    pSourceWindow,
                    DialogFlags.Modal,
                    _sizeDefaultWindowSize,
                    MessageType.Error,
                    ButtonsType.Close,
                    Resx.global_error,
                    errorMessage
                    );
            }

            return(result);
        }