Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public PosSendMessageDialog(Window pSourceWindow, DialogFlags pDialogFlags, string pWindowIcon)
        //public PosInputTextDialog(Window pSourceWindow, DialogFlags pDialogFlags, string pWindowTitle, string pEntryLabel, string pDefaultValue, string pRule, bool pRequired)
            : base(pSourceWindow, pDialogFlags, Resx.window_title_dialog_send_message, pWindowIcon, "Label", "Default", SettingsApp.RegexAlfaNumericExtended, true)
        {
            this.HeightRequest = 320;

            //UserDetail
            CriteriaOperator criteriaOperatorUser = CriteriaOperator.Parse("(Disabled IS NULL OR Disabled  <> 1)");

            _entryBoxSelectUser = new XPOEntryBoxSelectRecordValidation <SYS_UserDetail, TreeViewUser>(_sourceWindow, Resx.global_user, "Designation", "Oid", _valueUser, criteriaOperatorUser, SettingsApp.RegexGuid, false);
            _entryBoxSelectUser.EntryValidation.IsEditable = false;
            //Public Reference
            _valueUser = _entryBoxSelectUser.Value;

            //Terminal
            CriteriaOperator criteriaOperatorTerminal = CriteriaOperator.Parse("(Disabled IS NULL OR Disabled  <> 1)");

            _entryBoxSelectTerminal = new XPOEntryBoxSelectRecordValidation <POS_ConfigurationPlaceTerminal, TreeViewConfigurationPlaceTerminal>(_sourceWindow, Resx.global_user, "Designation", "Oid", _valueTerminal, criteriaOperatorTerminal, SettingsApp.RegexGuid, false);
            _entryBoxSelectTerminal.EntryValidation.IsEditable = false;
            //Public Reference
            _valueTerminal = _entryBoxSelectTerminal.Value;

            _vbox.PackStart(_entryBoxSelectTerminal, true, true, 0);
            _vbox.PackStart(_entryBoxSelectUser, true, true, 0);
            _vbox.ShowAll();

            //dialog.VBoxContent.PackStart(textViewTouch, true, true, 0);
            //dialog.VBoxContent.ShowAll();

            /*
             * //Init Local Vars
             * String windowTitle = Resx.window_title_dialog_send_message;
             * Size windowSize = new Size(600, 500);
             * String fileDefaultWindowIcon = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\Windows\icon_window_send_message.png");
             *
             * //Init Content
             * Fixed fixedContent = new Fixed();
             * fixedContent.Put(new Label("Place content here"), 0, 0);
             *
             * //ActionArea Buttons
             * TouchButtonIconWithText buttonOk = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Ok);
             * TouchButtonIconWithText buttonCancel = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Cancel);
             *
             * //ActionArea
             * ActionAreaButtons actionAreaButtons = new ActionAreaButtons();
             * actionAreaButtons.Add(new ActionAreaButton(buttonOk, ResponseType.Ok));
             * actionAreaButtons.Add(new ActionAreaButton(buttonCancel, ResponseType.Cancel));
             * //Init Object
             * this.InitObject(this, pDialogFlags, fileDefaultWindowIcon, windowTitle, windowSize, fixedContent, actionAreaButtons);
             */
        }
Ejemplo n.º 3
0
        public static bool PersistWorkSessionMovement(Session pSession, POS_WorkSessionPeriod pWorkSessionPeriod, POS_WorkSessionMovementType pWorkSessionMovementType, FIN_DocumentFinanceMaster pDocumentFinanceMaster, FIN_DocumentFinancePayment pDocumentFinancePayment, SYS_UserDetail pUserDetail, POS_ConfigurationPlaceTerminal pTerminal, DateTime pDate, decimal pMovementAmount, string pDescription, uint pOrd = 1)
        {
            //Prevent Deleted Objects, Get Fresh Objects
            SYS_UserDetail userDetail = pSession.GetObjectByKey <SYS_UserDetail>(GlobalFramework.LoggedUser.Oid);
            POS_ConfigurationPlaceTerminal terminal = pSession.GetObjectByKey <POS_ConfigurationPlaceTerminal>(GlobalFramework.LoggedTerminal.Oid);
            POS_WorkSessionMovementType    workSessionMovementType = pSession.GetObjectByKey <POS_WorkSessionMovementType>(pWorkSessionMovementType.Oid);

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

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

                return(true);
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
                return(false);
            }
        }
Ejemplo n.º 4
0
        //XpoMode
        public TreeViewConfigurationPlaceTerminal(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default)
        {
            //Init Vars
            Type xpoGuidObjectType = typeof(POS_ConfigurationPlaceTerminal);
            //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView
            POS_ConfigurationPlaceTerminal defaultValue = (pDefaultValue != null) ? pDefaultValue as POS_ConfigurationPlaceTerminal : null;
            //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView
            Type typeDialogClass = (pDialogType != null) ? pDialogType : typeof(DialogConfigurationPlaceTerminal);

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

            columnProperties.Add(new GenericTreeViewColumnProperty("Code")
            {
                Title = Resx.global_record_code, MinWidth = 100
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("Designation")
            {
                Title = Resx.global_designation, Expand = true
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("HardwareId")
            {
                Title = Resx.global_hardware_id
            });
            columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt")
            {
                Title = Resx.global_record_date_updated, MinWidth = 150, MaxWidth = 150
            });

            //Configure Criteria/XPCollection/Model
            //CriteriaOperator.Parse("Code >= 100 and Code <= 9999");
            CriteriaOperator criteria      = pXpoCriteria;
            XPCollection     xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria);

            //Events
            //this.RecordAfterUpdate += TreeViewConfigurationPlaceTerminal_RecordAfterUpdate;

            //Call Base Initializer
            base.InitObject(
                pSourceWindow,                 //Pass parameter
                defaultValue,                  //Pass parameter
                pGenericTreeViewMode,          //Pass parameter
                pGenericTreeViewNavigatorMode, //Pass parameter
                columnProperties,              //Created Here
                xpoCollection,                 //Created Here
                typeDialogClass                //Created Here
                );
        }
Ejemplo n.º 5
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //Terminals

        //Duplicate method from logicpos.Utils

        public static POS_ConfigurationPlaceTerminal GetTerminal()
        {
            POS_ConfigurationPlaceTerminal configurationPlaceTerminal = null;

            //Debug Directive disabled by Mario, if enabled we cant force Hardware id in Release, if we want to ignore appHardwareId from config we just delete it
            //If assigned in Config use it, else does nothing and use default ####-####-####-####-####-####
            if (SettingsApp.AppHardwareId != null && SettingsApp.AppHardwareId != String.Empty)
            {
                GlobalFramework.LicenceHardwareId = SettingsApp.AppHardwareId;
            }

            try
            {
                //Try TerminalID from Database
                configurationPlaceTerminal = (POS_ConfigurationPlaceTerminal)FrameworkUtils.GetXPGuidObjectFromField(typeof(POS_ConfigurationPlaceTerminal), "HardwareId", GlobalFramework.LicenceHardwareId);
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }

            //Create a new db terminal
            if (configurationPlaceTerminal == null)
            {
                try
                {
                    //Persist Terminal in DB
                    configurationPlaceTerminal = new POS_ConfigurationPlaceTerminal(GlobalFramework.SessionXpo)
                    {
                        Ord         = FrameworkUtils.GetNextTableFieldID("POS_ConfigurationPlaceterminal", "Ord"),
                        Code        = FrameworkUtils.GetNextTableFieldID("POS_ConfigurationPlaceterminal", "Code"),
                        Designation = "Terminal #" + FrameworkUtils.GetNextTableFieldID("POS_ConfigurationPlaceterminal", "Code"),
                        HardwareId  = GlobalFramework.LicenceHardwareId
                                      //Fqdn = GetFQDN()
                    };
                    configurationPlaceTerminal.Save();
                }
                catch (Exception ex)
                {
                    _log.Error(string.Format("Error! Cant Register a new TerminalId [{0}] with HardwareId: [{1}], Error: [2]", configurationPlaceTerminal.Oid, configurationPlaceTerminal.HardwareId, ex.Message), ex);
                    Environment.Exit(0);
                }
            }
            return(configurationPlaceTerminal);
        }
Ejemplo n.º 6
0
        public static bool SessionPeriodOpen(WorkSessionPeriodType pWorkSessionPeriodType, string pDescription = "")
        {
            try
            {
                string periodType  = (pWorkSessionPeriodType == WorkSessionPeriodType.Day) ? "Day" : "Terminal";
                string description = (pDescription != String.Empty) ? string.Format(" - {0}", pDescription) : String.Empty;
                POS_ConfigurationPlaceTerminal terminal = GlobalFramework.SessionXpo.GetObjectByKey <POS_ConfigurationPlaceTerminal>(GlobalFramework.LoggedTerminal.Oid);
                DateTime dateTime = FrameworkUtils.CurrentDateTimeAtomic();

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

                if (pWorkSessionPeriodType == WorkSessionPeriodType.Day)
                {
                    GlobalFramework.WorkSessionPeriodDay = workSessionPeriod;
                }
                else
                {
                    GlobalFramework.WorkSessionPeriodTerminal = workSessionPeriod;
                }
                return(true);
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
                return(false);
            }
        }
Ejemplo n.º 7
0
        private static bool SystemPrintInsert(FIN_DocumentFinanceMaster pDocumentFinanceMaster, FIN_DocumentFinancePayment pDocumentFinancePayment, string pPrinterDesignation, int pPrintCopies, List <int> pCopyNames, bool pSecondPrint, string pPrintMotive, SYS_UserDetail pUserDetail, POS_ConfigurationPlaceTerminal pConfigurationPlaceTerminal)
        {
            bool result = false;

            try
            {
                //Start UnitOfWork
                using (UnitOfWork uowSession = new UnitOfWork())
                {
                    string designation = String.Empty;
                    //Get Objects into Current UOW Session
                    SYS_UserDetail userDetail = (SYS_UserDetail)FrameworkUtils.GetXPGuidObject(uowSession, typeof(SYS_UserDetail), pUserDetail.Oid);
                    POS_ConfigurationPlaceTerminal configurationPlaceTerminal = (POS_ConfigurationPlaceTerminal)FrameworkUtils.GetXPGuidObject(uowSession, typeof(POS_ConfigurationPlaceTerminal), pConfigurationPlaceTerminal.Oid);

                    //Convert CopyNames List to Comma Delimited String
                    string copyNamesCommaDelimited = CustomReport.CopyNamesCommaDelimited(pCopyNames);

                    //SystemPrint
                    SYS_SystemPrint systemPrint = new SYS_SystemPrint(uowSession)
                    {
                        Date        = FrameworkUtils.CurrentDateTimeAtomic(),
                        Designation = designation,
                        PrintCopies = pPrintCopies,
                        CopyNames   = copyNamesCommaDelimited,
                        SecondPrint = pSecondPrint,
                        UserDetail  = userDetail,
                        Terminal    = configurationPlaceTerminal
                    };
                    if (pPrintMotive != String.Empty)
                    {
                        systemPrint.PrintMotive = pPrintMotive;
                    }

                    //Mode: DocumentFinanceMaster
                    if (pDocumentFinanceMaster != null)
                    {
                        FIN_DocumentFinanceMaster documentFinanceMaster = (FIN_DocumentFinanceMaster)FrameworkUtils.GetXPGuidObject(uowSession, typeof(FIN_DocumentFinanceMaster), pDocumentFinanceMaster.Oid);
                        systemPrint.DocumentMaster = documentFinanceMaster;
                        designation = string.Format("{0} {1} : {2}", Resx.global_printed, documentFinanceMaster.DocumentType.Designation, documentFinanceMaster.DocumentNumber);
                        //Update DocumentFinanceMaster
                        if (!documentFinanceMaster.Printed)
                        {
                            documentFinanceMaster.Printed = true;
                        }
                    }
                    //Mode: DocumentFinancePayment
                    if (pDocumentFinancePayment != null)
                    {
                        FIN_DocumentFinancePayment documentFinancePayment = (FIN_DocumentFinancePayment)FrameworkUtils.GetXPGuidObject(uowSession, typeof(FIN_DocumentFinancePayment), pDocumentFinancePayment.Oid);
                        systemPrint.DocumentPayment = documentFinancePayment;
                        designation = string.Format("{0} {1} : {2}", Resx.global_printed, documentFinancePayment.DocumentType.Designation, documentFinancePayment.PaymentRefNo);
                    }
                    systemPrint.Designation = designation;

                    try
                    {
                        //Commit UOW Changes : Before get current OrderMain
                        uowSession.CommitChanges();
                        //Audit
                        FrameworkUtils.Audit("SYSTEM_PRINT_FINANCE_DOCUMENT", designation);
                        result = true;
                    }
                    catch (Exception ex)
                    {
                        _log.Error(ex.Message, ex);
                        uowSession.RollbackTransaction();
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
            return(result);
        }
Ejemplo n.º 8
0
        public static bool Add(Session pSession, ProcessArticleStockMode pMode, FIN_DocumentFinanceDetail pDocumentDetail, ERP_Customer pCustomer, int pOrd, DateTime pDocumentDate, string pDocumentNumber, FIN_Article pArticle, decimal pQuantity, string pNotes)
        {
            //Log4Net
            log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            bool    result   = false;
            decimal quantity = 0.0m;

            try
            {
                switch (pMode)
                {
                case ProcessArticleStockMode.Out:
                    quantity = -(pQuantity);
                    break;

                case ProcessArticleStockMode.In:
                    quantity = pQuantity;
                    break;
                }

                //Get Objects in same Session
                ERP_Customer customer = (ERP_Customer)pSession.GetObjectByKey(typeof(ERP_Customer), pCustomer.Oid);
                FIN_Article  article  = (FIN_Article)pSession.GetObjectByKey(typeof(FIN_Article), pArticle.Oid);
                POS_ConfigurationPlaceTerminal terminal = (POS_ConfigurationPlaceTerminal)pSession.GetObjectByKey(typeof(POS_ConfigurationPlaceTerminal), GlobalFramework.LoggedTerminal.Oid);
                SYS_UserDetail userDetail = (SYS_UserDetail)pSession.GetObjectByKey(typeof(SYS_UserDetail), GlobalFramework.LoggedUser.Oid);

                FIN_ArticleStock articleStock = new FIN_ArticleStock(pSession)
                {
                    Customer     = customer,
                    Date         = pDocumentDate,
                    Article      = article,
                    Quantity     = quantity,
                    Notes        = pNotes,
                    CreatedWhere = terminal,
                    CreatedBy    = userDetail
                };
                if (pDocumentNumber != string.Empty)
                {
                    articleStock.DocumentNumber = pDocumentNumber;
                }
                if (pDocumentDetail != null)
                {
                    articleStock.DocumentNumber = pDocumentDetail.DocumentMaster.DocumentNumber;
                    articleStock.DocumentMaster = pDocumentDetail.DocumentMaster;
                    articleStock.DocumentDetail = pDocumentDetail;
                }

                //Only saves if not Working on a Unit Of Work Transaction
                if (pSession.GetType() != typeof(UnitOfWork))
                {
                    articleStock.Save();
                }

                //Audit
                switch (pMode)
                {
                case ProcessArticleStockMode.Out:
                    FrameworkUtils.Audit("STOCK_MOVEMENT_OUT", string.Format(Resx.audit_message_stock_movement_out, article.Designation, FrameworkUtils.DecimalToString(quantity, SettingsApp.DecimalFormatStockQuantity)));
                    break;

                case ProcessArticleStockMode.In:
                    FrameworkUtils.Audit("STOCK_MOVEMENT_IN", string.Format(Resx.audit_message_stock_movement_in, article.Designation, FrameworkUtils.DecimalToString(quantity, SettingsApp.DecimalFormatStockQuantity)));
                    break;
                }

                result = true;
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
            }

            return(result);
        }
Ejemplo n.º 9
0
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //Helper for Create DocumentFinanceSeries & DocumentFinanceYearSerieTerminal
        //Used to generate Series Preview, or to Process Series in Database

        public static FrameworkCallsResult CreateDocumentFinanceYearSeriesTerminal(FIN_DocumentFinanceYears pDocumentFinanceYears, DataTable pTerminals, string pAcronym, bool pPreviewMode)
        {
            FrameworkCallsResult result = new FrameworkCallsResult();
            uint   ordAndCode = 10;
            uint   ordAndCodeInc = 10;
            int    terminalInc = 1;
            string acronymPrefix = String.Empty, acronym, designation, output = String.Empty, acronymAudit;
            Dictionary <string, string> acronymPrefixCreatedSeries = new Dictionary <string, string>();
            FIN_DocumentFinanceSeries   documentFinanceSeries = null;
            //Used to add DocumentFinanceYearSerieTerminal to list to delete outside of Loop
            List <FIN_DocumentFinanceYearSerieTerminal> listDeleteSerieTerminal = new List <FIN_DocumentFinanceYearSerieTerminal>();

            //Start UnitOfWork
            using (UnitOfWork uowSession = new UnitOfWork())
            {
                try
                {
                    //Get Object in UOW Session
                    FIN_DocumentFinanceYears documentFinanceYears = (FIN_DocumentFinanceYears)FrameworkUtils.GetXPGuidObject(uowSession, typeof(FIN_DocumentFinanceYears), pDocumentFinanceYears.Oid);

                    //Initialize DocumentFinanceType Collection : Criteria/XPCollection/Model : Use Default Filter
                    CriteriaOperator criteria = CriteriaOperator.Parse("(Disabled = 0 OR Disabled IS NULL)");
                    //Configure SortProperty
                    SortProperty sortProperty = new SortProperty("Ord", DevExpress.Xpo.DB.SortingDirection.Ascending);
                    //Init Collection
                    XPCollection xpDocumentFinanceType = new XPCollection(uowSession, typeof(FIN_DocumentFinanceType), criteria, sortProperty);

                    //Loop Terminals
                    foreach (DataRow terminal in pTerminals.Rows)
                    {
                        //Disable Series and Delete SerieTerminal for selected Terminal
                        if (!pPreviewMode)
                        {
                            //Initialize DocumentFinanceYearSerieTerminal Collection : Criteria/XPCollection/Model : Use Default Filter + Terminal
                            criteria = CriteriaOperator.Parse(string.Format("(Disabled = 0 OR Disabled IS NULL) AND (Terminal = '{0}')", terminal["Oid"]));
                            //Init Collection
                            XPCollection xpDocumentFinanceYearSerieTerminal = new XPCollection(uowSession, typeof(FIN_DocumentFinanceYearSerieTerminal), criteria);

                            //Loop DocumentFinanceYearSerieTerminal and Parent DocumentFinanceYearSerie and Delete
                            foreach (FIN_DocumentFinanceYearSerieTerminal documentFinanceYearSerieTerminal in xpDocumentFinanceYearSerieTerminal)
                            {
                                if (_debug)
                                {
                                    _log.Debug(string.Format("Disabled documentFinanceYearSerie: [{0}]", documentFinanceYearSerieTerminal.Serie.Designation));
                                }
                                documentFinanceYearSerieTerminal.Serie.Disabled = true;
                                //documentFinanceYearSerieTerminal.Disabled = true;
                                //Add to Post Loop Deletion
                                listDeleteSerieTerminal.Add(documentFinanceYearSerieTerminal);
                            }

                            //Now we can delete, Outside of Loop
                            foreach (FIN_DocumentFinanceYearSerieTerminal deleteSerieTerminal in listDeleteSerieTerminal)
                            {
                                if (_debug)
                                {
                                    _log.Debug(string.Format("Deleted documentFinanceYearSerieTerminal: [{0}]", deleteSerieTerminal.Designation));
                                }
                                deleteSerieTerminal.Delete();
                            }
                        }

                        //Add to Output
                        if (pPreviewMode)
                        {
                            output += string.Format("{0}{1}", terminal["Designation"], Environment.NewLine);
                        }

                        //Get Current Terminal Object
                        POS_ConfigurationPlaceTerminal configurationPlaceTerminal = (POS_ConfigurationPlaceTerminal)uowSession.GetObjectByKey(typeof(POS_ConfigurationPlaceTerminal), new Guid(terminal["Oid"].ToString()));

                        //Create DocumentFinanceSeries Acronym From Date
                        DateTime now = FrameworkUtils.CurrentDateTimeAtomic();

                        //AcronymPrefix ex FT[QN3T1U401]2016S001, works with Random and AcronymLastSerie modes
                        if (SettingsApp.DocumentFinanceSeriesGenerationFactoryUseRandomAcronymPrefix)
                        {
                            acronymPrefix = DateToAcronymPrefix(new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second));
                        }
                        //AcronymPrefix ex Fatura FT[0001]2016S001
                        else
                        {
                            //Get acronymPrefix in first DocumentFinanceType, not in every Document, this way we have uniform series
                            acronymPrefix = (xpDocumentFinanceType[0] as FIN_DocumentFinanceType).AcronymLastSerie.ToString(SettingsApp.DocumentFinanceSeriesGenerationFactoryAcronymLastSerieFormat);
                        }

                        //Add to Created List
                        acronymPrefixCreatedSeries.Add(acronymPrefix, configurationPlaceTerminal.Designation);

                        foreach (FIN_DocumentFinanceType documentFinanceType in xpDocumentFinanceType)
                        {
                            //Ignored DocumentTypes (DocumentFinanceTypeInvoiceWayBill, this DocumentType use DocumentFinanceTypeInvoice Serie)
                            if (documentFinanceType.Oid != SettingsApp.XpoOidDocumentFinanceTypeInvoiceWayBill)
                            {
                                //2018-05-08 : Old Format : [FT005012018S1] : Search GenDocumentNumber in ProcessFinanceDocument
                                //acronym = string.Format("{0}{1}{2}{3}", documentFinanceType.Acronym, acronymPrefix, terminalInc.ToString("00"), pAcronym);
                                //2018-05-08 : New Format
                                //acronym = string.Format("{0} {1}{2}{3}", documentFinanceType.Acronym, pAcronym, acronymPrefix, terminalInc);
                                acronym     = string.Format("{0} {1}{2}", documentFinanceType.Acronym, pAcronym, acronymPrefix);
                                designation = string.Format("{0} {1}", documentFinanceType.Designation, acronym);
                                if (!pPreviewMode)
                                {
                                    documentFinanceSeries = new FIN_DocumentFinanceSeries(uowSession)
                                    {
                                        Ord                      = ordAndCode,
                                        Code                     = ordAndCode,
                                        FiscalYear               = documentFinanceYears,
                                        DocumentType             = documentFinanceType,
                                        NextDocumentNumber       = 1,
                                        DocumentNumberRangeBegin = 1,
                                        DocumentNumberRangeEnd   = int.MaxValue,
                                        Acronym                  = acronym,
                                        Designation              = designation
                                    };
                                }
                                //Add to Output
                                if (pPreviewMode)
                                {
                                    output += string.Format("  {0} {1} - {2}{3}", documentFinanceType.Acronym, acronym, documentFinanceType.Designation, Environment.NewLine);
                                }
                                if (_debug)
                                {
                                    _log.Debug(string.Format("DocumentFinanceSeries: [{0}], Designation: [{1}], Acronym: [{2}]", ordAndCode, designation, acronym));
                                }

                                //Create DocumentFinanceYearSerieTerminal
                                designation = string.Format("{0} {1}", designation, configurationPlaceTerminal.Designation);
                                if (!pPreviewMode)
                                {
                                    FIN_DocumentFinanceYearSerieTerminal documentFinanceYearSerieTerminal = new FIN_DocumentFinanceYearSerieTerminal(uowSession)
                                    {
                                        Ord          = ordAndCode,
                                        Code         = ordAndCode,
                                        FiscalYear   = documentFinanceYears,
                                        DocumentType = documentFinanceSeries.DocumentType,
                                        Serie        = documentFinanceSeries,
                                        Terminal     = configurationPlaceTerminal,
                                        Printer      = configurationPlaceTerminal.Printer,
                                        Template     = documentFinanceSeries.DocumentType.Template,
                                        Designation  = string.Format("{0} {1}", documentFinanceSeries.Designation, configurationPlaceTerminal.Designation)
                                    };
                                }
                                if (_debug)
                                {
                                    _log.Debug(string.Format("DocumentFinanceYearSerieTerminal: [{0}], Terminal: [{1}], Serie: [{2}]", ordAndCode, terminal["Designation"], designation));
                                }

                                //Increment AcronymLastSerie and ordAndCodeInc
                                documentFinanceType.AcronymLastSerie++;
                                ordAndCode = ordAndCode + ordAndCodeInc;
                            }
                        }
                        //Add Blank Line to Split Series/Terminal
                        if (pPreviewMode && pTerminals.Rows.Count > terminalInc)
                        {
                            output += Environment.NewLine;
                        }
                        //Increment Terminal
                        terminalInc++;
                    }

                    //Finnaly Commit Changes
                    if (!pPreviewMode)
                    {
                        uowSession.CommitChanges();
                    }

                    result.Result = true;

                    if (pPreviewMode)
                    {
                        result.Output = output;
                    }
                    else
                    {
                        foreach (var item in acronymPrefixCreatedSeries)
                        {
                            //Audit FINANCE_SERIES_CREATED
                            acronymAudit = string.Format("{0}{1}{2}{3}", "xx", item.Key, 0.ToString("00"), pAcronym);
                            FrameworkUtils.Audit("FINANCE_SERIES_CREATED", string.Format(Resx.audit_message_finance_series_created, acronymAudit, item.Value, GlobalFramework.LoggedUser.Name));
                        }
                    }
                }
                catch (Exception ex)
                {
                    uowSession.RollbackTransaction();
                    result.Exception = ex;
                    _log.Error(ex.Message, ex);
                }
            }
            return(result);
        }
Ejemplo n.º 10
0
 //Main Method  - With and Without Session
 public static bool PersistWorkSessionMovement(POS_WorkSessionPeriod pWorkSessionPeriod, POS_WorkSessionMovementType pWorkSessionMovementType, FIN_DocumentFinanceMaster pDocumentFinanceMaster, FIN_DocumentFinancePayment pDocumentFinancePayment, SYS_UserDetail pUserDetail, POS_ConfigurationPlaceTerminal pTerminal, DateTime pDate, decimal pMovementAmount, string pDescription, uint pOrd = 1)
 {
     return(PersistWorkSessionMovement(GlobalFramework.SessionXpo, pWorkSessionPeriod, pWorkSessionMovementType, pDocumentFinanceMaster, pDocumentFinancePayment, pUserDetail, pTerminal, pDate, pMovementAmount, pDescription));
 }