Exemplo n.º 1
0
        public static DB.GLX_Header CreateReversalEntry(DB.GLX_Header glx_header, DataContext dataContext)
        {
            DB.GLX_Header glx_header_reversal = GLX.GLX_Header.New;
            glx_header_reversal.JournalTypeId = (byte)GLX.GLX_JournalType.Reversal;
            glx_header_reversal.Reference     = glx_header.Reference;
            glx_header_reversal.Description   = String.Format("Reverse {0}", glx_header.Description);
            glx_header_reversal.TrackId       = glx_header.TrackId;
            glx_header_reversal.Date          = DateTime.Now;
            //TODO: Fix this
            //glx_header_reversal.InternalReference = (glx_header.InternalReference ?? "") + ".REV";

            // Check if entry period is still open
            DB.SYS_Period period = SYS.SYS_Period.Load(glx_header.PeriodId, dataContext);
            if (period.StatusId == (byte)SYS.SYS_Status.Open)
            {
                glx_header_reversal.Date     = glx_header.Date;
                glx_header_reversal.PeriodId = period.Id;
            }

            // Add reversal lines - they currently default to aging 00 though
            foreach (DB.GLX_Line line in glx_header.GLX_Line)
            {
                DB.GLX_Line glx_line_reversal = GLX.GLX_Line.New;
                glx_line_reversal.EntityId  = line.EntityId;
                glx_line_reversal.Amount    = -line.Amount;
                glx_line_reversal.CenterId  = line.CenterId;
                glx_line_reversal.CreatedBy = ApplicationDataContext.Instance.LoggedInUser.PersonId;
                glx_line_reversal.CreatedOn = DateTime.Now;
                glx_line_reversal.AgingId   = line.AgingId;

                glx_header_reversal.GLX_Line.Add(glx_line_reversal);
            }

            return(glx_header_reversal);
        }
        public static DB.ITM_History GetItemCurrentHistory(DB.ITM_Inventory entry, DataContext dataContext)
        {
            DB.SYS_Period currentPeriod = SYS.SYS_Period.GetCurrentPeriod(dataContext);

            DB.ITM_History history = dataContext.EntityInventoryContext.ITM_History.FirstOrDefault(n => n.InventoryId ==
                                                                                                   entry.InventoryId && n.PeriodId == currentPeriod.Id && n.SiteId == ApplicationDataContext.Instance.LoggedInUser.DefaultSiteId);

            return(history);
        }
Exemplo n.º 3
0
        public static System.Data.DataTable GetPayable(DB.SYS_Period period, string filter, DataContext dataContext)
        {
            String query = "";

            if (BL.ApplicationDataContext.Instance.AccessGranted(BL.SEC.AccessCodes.FIAARE))
            {
                query = "SELECT Type, AccountId, Title, Reference, Description, Date, Balance, Period, Aging, TrackNumber, LineId FROM CDS_GLX.VW_PayableItems WHERE ((Type='OI') OR (Type='BBF' AND PeriodId=" + period.Id + ")) AND " + filter + " ORDER BY Date";
            }
            else
            {
                query = "SELECT Type, AccountId, Title, Reference, Description, Date, Balance, Period, Aging, TrackNumber, LineId FROM CDS_GLX.VW_PayableItems WHERE ((Type='OI') OR (Type='BBF' AND PeriodId=" + period.Id + ")) AND " + filter + ") AND SiteId=" + BL.ApplicationDataContext.Instance.LoggedInUser.DefaultSiteId + " ORDER BY Date";
            }
            System.Data.SqlClient.SqlDataAdapter adapter = ApplicationDataContext.Instance.GetAdapter("SELECT Type, AccountId, Title, Reference, Description, Date, Balance, Period, Aging, TrackNumber, LineId FROM CDS_GLX.VW_PayableItems WHERE ((Type='OI') OR (Type='BBF' AND PeriodId=" + period.Id + ")) AND " + filter + " ORDER BY Date");
            System.Data.DataTable tblResult = new System.Data.DataTable();
            adapter.Fill(tblResult);
            return(tblResult);
        }
        internal static String Save(DB.SYS_Period entry, DataContext dataContext)
        {
            try
            {
                if (dataContext.EntitySystemContext.GetEntityState(entry) == EntityState.Detached)
                {
                    Save(new List <DB.SYS_Period>()
                    {
                        entry
                    }, dataContext);
                }

                Validation.ValidateEntity(dataContext.EntitySystemContext, entry);
            }
            catch (Validation.EntityValidationException ex)
            {
                return(dataContext.PackageValidationException());
            }

            return("Success");
        }
 public static DB.SYS_Period GetPreviousItem(DB.SYS_Period period, DataContext dataContext)
 {
     return(dataContext.EntitySystemContext.SYS_Period.OrderByDescending(o => o.EndDate).FirstOrDefault(n => n.EndDate < period.EndDate && n.EndDate != period.EndDate));
 }
 public static DB.SYS_Period GetNextItem(DB.SYS_Period period, DataContext dataContext)
 {
     return(dataContext.EntitySystemContext.SYS_Period.OrderBy(o => o.EndDate).FirstOrDefault(n => n.EndDate > period.EndDate && n.EndDate != period.EndDate));
 }