Beispiel #1
0
    public Vector3 diff(OLocation other)
    {
        Vector3 rp = Vector3.zero;

        rp.Set(this.lat - other.lat, this.lon - other.lon, this.alt - other.alt);
        return(rp);
    }
Beispiel #2
0
    void UpdateMessageObjects()
    {
        // add new icons and move all icons if user position has changed

        Dictionary <string, List <long> > updates = UpdateNearbyMessages(distThreshold);

        ClearMessageObjects(updates["remove"]);

        // add icons for new messages within range
        //this.transform.Find("helperText").GetComponent<TextMesh>().text = "" + messages.Count;
        //print("add: " + updates["add"].Count + " remove: " + updates["remove"].Count);
        foreach (long mid in updates["add"])
        {
            print("adding message ball with id " + mid);
            // set location of icon to be the difference between the user and the message's 3-d location
            messageBalls[mid] = Instantiate(metalBall, messages[mid].getLoc().diff(loc_origin), Quaternion.AngleAxis(180, Vector3.up));

            // attache the message info to the icon
            messageBalls[mid].AddComponent <Message>();
            messageBalls[mid].GetComponent <Message>().message = messages[mid].getMessage();
            messageBalls[mid].GetComponent <Message>().id      = mid;
        }

        // move all icons if user location changed since last update
        if (!last_loc.equals(loc_origin))
        {
            foreach (long mid in messageBalls.Keys)
            {
                messageBalls[mid].transform.position = messages[mid].getLoc().diff(loc_origin);
            }
            last_loc = loc_origin.copy();
        }

        updateLock = false;
    }
Beispiel #3
0
 private void DeleteDeco(Api api, OLocation deco)
 {
     if (deco.Id != "301/e0ec0d4f-12c3-4648-a465-36c63399796d")
     {
         var deleteDeco = api.ExecuteRequest(new DeleteLocation(api.Context, deco.Id));
     }
 }
Beispiel #4
0
    private OLocation loc_origin; // current user location

    // Use this for initialization
    void Start()
    {
        // load with initialized location
        // for demo purposes, use dummy locations
        loc_origin = new OLocation(1, 1, 10);
        last_loc   = loc_origin.copy();

        // initialize empty dicts of messages, icons
        messages     = new Dictionary <long, Message>();
        messageBalls = new Dictionary <long, GameObject>();

        // hide the UI overlay
        uiCanvasGroup.alpha          = 0f;
        uiCanvasGroup.blocksRaycasts = false;

        //InvokeRepeating("UpdateLocation", 0, LOC_UPDATE_DELAY);
    }
 public static OLocation FourwaysMall(string clientId)
 {
     var deco = new OLocation
     {
         Name = "Fourways Mall",
         Address = "Address of deco",
         Category = new OLocationCategory { Id = "1", Description = "Category" },
         ClientId = clientId,
         Id = $"{clientId}/6",
         Reference = "Internal Ref",
         Shape = EZoneShape.Radius,
         Coords = new SpecializedObservableCollection<OCoord>
                 {
                     new OCoord {Latitude = -26.020116, Longitude = 28.007320, Radius = 100}
                 }
     };
     return deco;
 }
 public static OLocation AnotherDeco(string clientId)
 {
     var deco = new OLocation
     {
         Name = "Trackmatic Solutions",
         Address = "Address of deco",
         Category = new OLocationCategory { Id = "1", Description = "Category" },
         ClientId = clientId,
         Id = $"{clientId}/5",
         Reference = "Internal Ref",
         Shape = EZoneShape.Radius,
         Coords = new SpecializedObservableCollection<OCoord>
                 {
                     new OCoord {Latitude = -26.130565, Longitude = 28.086042, Radius = 100}
                 }
     };
     return deco;
 }
 public static OLocation Adhoc(string clientId, string name, string reference)
 {
     var deco = new OLocation
         {
             Name = name,
             Address = "Address of deco",
             Category = new OLocationCategory {Id = "1", Description = "Category"},
             ClientId = clientId,
             Id = $"{clientId}/$tmp/" + reference,
             Reference = reference,
             Shape = EZoneShape.Radius,
             Coords = new SpecializedObservableCollection<OCoord>
                 {
                     new OCoord {Latitude = -26.041245, Longitude = 28.020495, Radius = 100}
                 }
         };
     return deco;
 }
 public static OLocation Empty(string clientId, Guid id, string name)
 {
     var deco = new OLocation
     {
         Name = name,
         Category = new OLocationCategory { Id = "1", Description = "Category" },
         ClientId = clientId,
         Id = $"{clientId}/{id}",
         Shape = EZoneShape.Radius,
         Coords = new SpecializedObservableCollection<OCoord> { new OCoord {Latitude = 0, Longitude = 0, Radius = 100} },
         DefaultStopTime = TimeSpan.FromMinutes(22),
         StructuredAddress = new StructuredAddress
         {
             StreetNo = "10",
             Street = "Knowle Place",
             Suburb = "Gresswold"
         }
     };
     return deco;
 }
        private OLocation CreateRouteDeco(SiteData _site, ActionItem action)
        {
            var deco = new OLocation
            {
                Id         = string.Join("/", _site.Id, action.GetCustomerName(), action.GetCustomerReference()),
                Reference  = action.GetCustomerReference(),
                Name       = action.GetCustomerName(),
                ClientId   = _site.Id,
                ReceivedOn = DateTime.Now,
                Coords     = new Trackmatic.Rest.SpecializedObservableCollection <OCoord>()
                {
                    new OCoord()
                    {
                        Latitude  = action.GetLatitude(),
                        Longitude = action.GetLongitude(),
                        Radius    = 100
                    }
                },
                Entrance = new OCoord()
                {
                    Latitude  = action.GetLatitude(),
                    Longitude = action.GetLongitude(),
                },
                StructuredAddress = new StructuredAddress()
                {
                    UnitNo            = action.GetUnitNo(),
                    BuildingName      = action.GetBuildingName(),
                    SubDivisionNumber = action.GetSubDivisionNumber(),
                    StreetNo          = action.GetStreetNo(),
                    Street            = action.GetStreet(),
                    Suburb            = action.GetSuburb(),
                    City       = action.GetCity(),
                    Province   = action.GetProvince(),
                    PostalCode = action.GetPostalCode()
                }
            };

            return(deco);
        }
        public OLocation CreateGroupDeco(IGrouping <string, Consignment> group, RttSiteDefault site)
        {
            var lat = group.Select(x => x.Address.GpsLat).FirstOrDefault();
            var lon = group.Select(x => x.Address.GpsLong).FirstOrDefault();

            var deco = new OLocation
            {
                Name            = group.Select(x => x.Address.Name).FirstOrDefault(),
                Id              = CreateDecoId(group, site),// $"{site.Id}/{consignment.Address.Addr_Id}",
                ClientId        = site.Id,
                Reference       = group.Select(x => x.Address.Addr_id).FirstOrDefault().ToString(),
                DefaultStopTime = TimeSpan.FromMinutes(20),
                Shape           = EZoneShape.Radius,
                Coords          = new SpecializedObservableCollection <OCoord>
                {
                    new OCoord
                    {
                        Latitude  = Convert.ToDouble(string.IsNullOrWhiteSpace(lat) ? "0" : lat),
                        Longitude = Convert.ToDouble(string.IsNullOrWhiteSpace(lon) ? "0" : lon),
                        Radius    = 200
                    }
                },
                StructuredAddress = new StructuredAddress
                {
                    Street     = group.Select(x => x.Address.Address1).FirstOrDefault(),
                    Suburb     = group.Select(x => x.Address.Suburb).FirstOrDefault(),
                    City       = group.Select(x => x.Address.Town).FirstOrDefault(),
                    PostalCode = group.Select(x => x.Address.Postal).FirstOrDefault()
                },
                Entrance = new OCoord
                {
                    Latitude  = Convert.ToDouble(string.IsNullOrWhiteSpace(lat) ? "0" : lat),
                    Longitude = Convert.ToDouble(string.IsNullOrWhiteSpace(lon) ? "0" : lon),
                    Radius    = 200
                }
            };

            return(deco);
        }
 public static Action Delivery(string clientId,
     OLocation location, string reference)
 {
     var action = new Action
                      {
                          Id = $"{clientId}/{reference}",
                          Reference = reference,
                          ClientId = clientId,
                          ExpectedDelivery = DateTime.UtcNow,
                          Instructions = "Action instructions",
                          Pallets = 1,
                          Weight = 120,
                          VolumetricMass = 3,
                          Value = 400,
                          Name = reference,
                          AmountEx = 12,
                          AmountIncl = 13,
                          ActionTypeId = $"{clientId}/delivery",
                          ActionTypeName = "Delivery"
                      };
     return action;
 }
Beispiel #12
0
        private OLocation CreateDeco(Consignment consignment, RttSiteDefault site, RTTTripDetails trip)
        {
            var deco = new OLocation
            {
                Name            = consignment.Address.Name?.Trim(),
                Id              = utils.ResolveDecoId(consignment, site),
                ClientId        = site.Id,
                Reference       = consignment.Address.Addr_id.ToString(),
                DefaultStopTime = DetermineStopTime(consignment.PlannedStopOffloadDuration),
                Shape           = EZoneShape.Radius,
                Coords          = new SpecializedObservableCollection <OCoord>
                {
                    new OCoord
                    {
                        Latitude  = Convert.ToDouble(string.IsNullOrEmpty(consignment.Address.GpsLat) ? "0" : consignment.Address.GpsLat),
                        Longitude = Convert.ToDouble(string.IsNullOrEmpty(consignment.Address.GpsLong) ? "0" : consignment.Address.GpsLong),
                        Radius    = 100
                    }
                },
                StructuredAddress = new StructuredAddress
                {
                    Street     = consignment.Address.Address1?.Trim(),
                    Suburb     = consignment.Address.Suburb?.Trim(),
                    City       = consignment.Address.Town?.Trim(),
                    PostalCode = consignment.Address.Postal?.Trim()
                },
                Entrance = new OCoord
                {
                    Latitude  = Convert.ToDouble(string.IsNullOrEmpty(consignment.Address.GpsLat) ? "0" : consignment.Address.GpsLat),
                    Longitude = Convert.ToDouble(string.IsNullOrEmpty(consignment.Address.GpsLong) ? "0" : consignment.Address.GpsLong),
                    Radius    = 100
                },
                Extensions = CreateStopExtensions(trip, consignment)
            };

            return(deco);
        }
        private OLocation CreateDeco(Consignment consignment, RttSiteDefault site)
        {
            var deco = new OLocation
            {
                Name            = consignment.Address.Name?.Trim(),
                Id              = utils.ResolveDecoId(consignment, site),// $"{site.Id}/{consignment.Address.Addr_Id}",
                ClientId        = site.Id,
                Reference       = consignment.Address.Addr_id.ToString(),
                DefaultStopTime = TimeSpan.FromMinutes(20),
                Shape           = EZoneShape.Radius,
                Coords          = new SpecializedObservableCollection <OCoord>
                {
                    new OCoord
                    {
                        Latitude  = Convert.ToDouble(string.IsNullOrEmpty(consignment.Address.GpsLat) ? "0" : consignment.Address.GpsLat),
                        Longitude = Convert.ToDouble(string.IsNullOrEmpty(consignment.Address.GpsLong) ? "0" : consignment.Address.GpsLong),
                        Radius    = 200
                    }
                },
                StructuredAddress = new StructuredAddress
                {
                    Street     = consignment.Address.Address1?.Trim(),
                    Suburb     = consignment.Address.Suburb?.Trim(),
                    City       = consignment.Address.Town?.Trim(),
                    PostalCode = consignment.Address.Postal?.Trim()
                },
                Entrance = new OCoord
                {
                    Latitude  = Convert.ToDouble(string.IsNullOrEmpty(consignment.Address.GpsLat) ? "0" : consignment.Address.GpsLat),
                    Longitude = Convert.ToDouble(string.IsNullOrEmpty(consignment.Address.GpsLong) ? "0" : consignment.Address.GpsLong),
                    Radius    = 200
                }
            };

            return(deco);
        }
Beispiel #14
0
 public Message(OLocation loc, string msg, long ID)
 {
     this.location = loc;
     this.message  = msg;
     this.id       = ID;
 }
Beispiel #15
0
 public bool equals(OLocation other)
 {
     return(this.lat == other.lat && this.lon == other.lon && this.alt == other.alt);
 }
Beispiel #16
0
 public float flatDist(OLocation other)
 {
     return(Mathf.Sqrt(Mathf.Pow(this.lat - other.lat, 2) + Mathf.Pow(this.lon - other.lon, 2) + Mathf.Pow(this.alt - other.alt, 2)));
 }
        public static OLocation SandtonCity(string clientId)
        {
            var deco = new OLocation
            {
                Name = "Sandton City",
                Address = "Address of deco",
                Category = new OLocationCategory {Id = "1", Description = "Category"},
                ClientId = clientId,
                Id = $"{clientId}/sandton/1",
                Reference = "Internal Ref",
                Shape = EZoneShape.Radius,
                Coords = new SpecializedObservableCollection<OCoord>
                {
                    new OCoord {Latitude = -26.110514, Longitude = 28.052889, Radius = 100}
                },
                DefaultStopTime = TimeSpan.FromMinutes(22),
                StructuredAddress = new StructuredAddress
                {
                    StreetNo = "61",

                    Street = "Katherine Street",

                    Suburb = "Sandown",

                    City = "Sandton",

                    Province = "Gauteng"
                }
            };
            return deco;
        }
 /// <summary>
 /// to check whether the passed in location is in the location list that the contract covers.
 /// </summary>
 /// <param name="location"></param>
 /// <param name="contract"></param>
 /// <returns></returns>
 private bool CheckContractLocation(OLocation location, OContract contract)
 {
     foreach (OLocation loc in contract.Locations)
     {
         if (location.ObjectID == location.ObjectID)
             return true;
     }
     return false;
 }
Beispiel #19
0
        /// <summary>
        /// Return a Data Table representing the Budget Detail Summary Report table structure.
        /// </summary>
        /// <param name="location"></param>
        /// <param name="YTD"></param>
        /// <returns>DataTable</returns>
        public static DataTable BudgetDetailSummaryReport(OLocation location, DateTime YTD, string accountName, Boolean reverse, int parentLevel)
        {
            // Validate User Access Right
            // TO DO

            // Create Account Condition
            ExpressionCondition cond = Query.True;
            //List<OAccount> lst = new List<OAccount>();
            //if (!String.IsNullOrEmpty(accountName))
            //{
            //    ExpressionCondition cond2 = Query.False;
            //    foreach (OAccount acc in account)
            //        cond2 = cond2 | TablesLogic.tAccount.HierarchyPath.Like(acc.HierarchyPath + "%");
            //    lst.AddRange(TablesLogic.tAccount.LoadList(cond2));
            //}

            DateTime formattedYTD = new DateTime(YTD.Year, YTD.Month, 1);
            DataTable result = new DataTable("BudgetDetailSummary");
            // Table structure: Expenses | Y____ Budget (a) | Current Month Actual | 
            // YTD Actual (b) | YTD Budget (c) | Variance (=(e)/(a)) | Budget Balance ((a)-(b))
            result.Columns.Add("ParentAccount");
            result.Columns.Add("Expenses");
            result.Columns.Add("YearBudget", typeof(decimal));
            result.Columns.Add("CurrentMonthActual", typeof(decimal));
            result.Columns.Add("YTDActual", typeof(decimal));
            result.Columns.Add("YTDBudget", typeof(decimal));
            result.Columns.Add("Variance", typeof(decimal));
            result.Columns.Add("BudgetBalance", typeof(decimal));

            OBudgetPeriod budgetPeriod = TablesLogic.tBudgetPeriod.Load(
                TablesLogic.tBudgetPeriod.Budget.ApplicableLocations.ObjectID == location.ObjectID
                &
                TablesLogic.tBudgetPeriod.StartDate <= formattedYTD
                &
                TablesLogic.tBudgetPeriod.EndDate >= formattedYTD
                );

            if (budgetPeriod == null) return result;

            OBudget budget = budgetPeriod.Budget;

            DataList<OBudgetPeriodOpeningBalance> openingBalances = budgetPeriod.BudgetPeriodOpeningBalances;
            List<OBudgetPeriodOpeningBalance> finalOpeningBalances = new List<OBudgetPeriodOpeningBalance>();
            //foreach (OAccount a in lst)
            //{
            //    finalOpeningBalances.AddRange(openingBalances.FindAll(lf => lf.AccountID == a.ObjectID));
            //}

            foreach (OBudgetPeriodOpeningBalance balance in openingBalances)
            {
                if (balance.Account.Path.Contains(accountName))
                    finalOpeningBalances.Add(balance);
            }

            int count = 1;

            foreach (OBudgetPeriodOpeningBalance balance in finalOpeningBalances)
            {
                DataRow row = result.NewRow();
                if (reverse)
                {
                    OAccount acc;
                    if (balance.Account.ObjectName == accountName)
                        acc = findParentLevel(balance.Account, parentLevel);
                    else
                        acc = findParentLevel(balance.Account, parentLevel + 1);
                    row["Expenses"] = acc.Parent != null ? acc.Parent.ObjectName : "n/a";
                    row["ParentAccount"] = acc.ObjectName;
                }
                else
                {
                    row["Expenses"] = balance.Account.ObjectName;
                    row["ParentAccount"] = balance.Account.Parent.ObjectName;
                }


                row["YearBudget"] = balance.TotalOpeningBalance;

                decimal currentMonthActual = TablesLogic.tBudgetTransactionLog
                    .Select(TablesLogic.tBudgetTransactionLog.TransactionAmount.Sum())
                    .Where(TablesLogic.tBudgetTransactionLog.IsDeleted == 0
                           &
                           TablesLogic.tBudgetTransactionLog.BudgetID == budget.ObjectID
                           &
                           TablesLogic.tBudgetTransactionLog.AccountID == balance.AccountID
                           &
                           TablesLogic.tBudgetTransactionLog.TransactionType.In(1, 2, 12, 13, 14)
                           &
                           TablesLogic.tBudgetTransactionLog.DateOfExpenditure >= formattedYTD
                           &
                           TablesLogic.tBudgetTransactionLog.DateOfExpenditure <= formattedYTD.AddMonths(1)
                           &
                           cond);
                row["CurrentMonthActual"] = currentMonthActual;

                decimal YTDActual = TablesLogic.tBudgetTransactionLog
                    .Select(TablesLogic.tBudgetTransactionLog.TransactionAmount.Sum())
                    .Where(TablesLogic.tBudgetTransactionLog.IsDeleted == 0
                           &
                           TablesLogic.tBudgetTransactionLog.BudgetID == budget.ObjectID
                           &
                           TablesLogic.tBudgetTransactionLog.AccountID == balance.AccountID
                           &
                           TablesLogic.tBudgetTransactionLog.TransactionType.In(1, 2, 12, 13, 14)
                           &
                           TablesLogic.tBudgetTransactionLog.DateOfExpenditure >= budgetPeriod.StartDate
                           &
                           TablesLogic.tBudgetTransactionLog.DateOfExpenditure <= formattedYTD.AddMonths(1)
                           &
                           cond);
                row["YTDActual"] = YTDActual;

                decimal YTDBudget = 0;
                switch (formattedYTD.Month)
                {
                    case 12: YTDBudget += balance.OpeningBalance12.Value;
                        goto case 11;
                    case 11: YTDBudget += balance.OpeningBalance11.Value;
                        goto case 10;
                    case 10: YTDBudget += balance.OpeningBalance10.Value;
                        goto case 9;
                    case 9: YTDBudget += balance.OpeningBalance09.Value;
                        goto case 8;
                    case 8: YTDBudget += balance.OpeningBalance08.Value;
                        goto case 7;
                    case 7: YTDBudget += balance.OpeningBalance07.Value;
                        goto case 6;
                    case 6: YTDBudget += balance.OpeningBalance06.Value;
                        goto case 5;
                    case 5: YTDBudget += balance.OpeningBalance05.Value;
                        goto case 4;
                    case 4: YTDBudget += balance.OpeningBalance04.Value;
                        goto case 3;
                    case 3: YTDBudget += balance.OpeningBalance03.Value;
                        goto case 2;
                    case 2: YTDBudget += balance.OpeningBalance02.Value;
                        goto case 1;
                    case 1: YTDBudget += balance.OpeningBalance01.Value;
                        break;
                }

                row["YTDBudget"] = YTDBudget;

                decimal budgetBalance = balance.TotalOpeningBalance.Value - Convert.ToDecimal(row["YTDActual"]);

                row["BudgetBalance"] = budgetBalance;

                row["Variance"] = (balance.TotalOpeningBalance.Value != 0)
                                    ? budgetBalance / balance.TotalOpeningBalance.Value
                                    : 0;

                result.Rows.Add(row);
            }

            return result;
        }
Beispiel #20
0
        /// <summary>
        /// Return a Data Table representing the Budget Detail Summary Report table structure.
        /// </summary>
        /// <param name="location"></param>
        /// <param name="YTD"></param>
        /// <returns>DataTable</returns>
        public static DataTable BudgetDetailSummaryReport(OLocation location, DateTime YTD, OAccount account)
        {
            // Validate User Access Right
            // TO DO

            // Create Account Condition
            ExpressionCondition cond = Query.True;
            if (null != account)
                cond = cond & TablesLogic.tBudgetTransactionLog.Account.HierarchyPath.Like(account.HierarchyPath + "%");

            DateTime formattedYTD = new DateTime(YTD.Year, YTD.Month, 1);
            DataTable result = new DataTable("BudgetDetailSummary");
            // Table structure: Expenses | Y____ Budget (a) | Current Month Actual | 
            // YTD Actual (b) | YTD Budget (c) | Variance (=(e)/(a)) | Budget Balance ((a)-(b))
            result.Columns.Add("ParentAccount");
            result.Columns.Add("Expenses");
            result.Columns.Add("YearBudget", typeof(decimal));
            result.Columns.Add("CurrentMonthActual", typeof(decimal));
            result.Columns.Add("YTDActual", typeof(decimal));
            result.Columns.Add("YTDBudget", typeof(decimal));
            result.Columns.Add("Variance", typeof(decimal));
            result.Columns.Add("BudgetBalance", typeof(decimal));

            OBudgetPeriod budgetPeriod = TablesLogic.tBudgetPeriod.Load(
                TablesLogic.tBudgetPeriod.Budget.ApplicableLocations.ObjectID == location.ObjectID
                &
                TablesLogic.tBudgetPeriod.StartDate <= formattedYTD
                &
                TablesLogic.tBudgetPeriod.EndDate >= formattedYTD
                );

            if (budgetPeriod == null) return result;

            OBudget budget = budgetPeriod.Budget;

            DataList<OBudgetPeriodOpeningBalance> openingBalances = budgetPeriod.BudgetPeriodOpeningBalances;

            int count = 1;

            foreach (OBudgetPeriodOpeningBalance balance in openingBalances)
            {
                DataRow row = result.NewRow();

                row["Expenses"] = balance.Account.Parent.ObjectName;
                row["ParentAccount"] = balance.Account.ObjectName;
                row["YearBudget"] = balance.TotalOpeningBalance;

                decimal currentMonthActual = TablesLogic.tBudgetTransactionLog
                    .Select(TablesLogic.tBudgetTransactionLog.TransactionAmount.Sum())
                    .Where(TablesLogic.tBudgetTransactionLog.IsDeleted == 0
                           &
                           TablesLogic.tBudgetTransactionLog.BudgetID == budget.ObjectID
                           &
                           TablesLogic.tBudgetTransactionLog.AccountID == balance.AccountID
                           &
                           TablesLogic.tBudgetTransactionLog.TransactionType.In(1, 2, 12, 13, 14)
                           &
                           TablesLogic.tBudgetTransactionLog.DateOfExpenditure >= formattedYTD
                           &
                           TablesLogic.tBudgetTransactionLog.DateOfExpenditure <= formattedYTD.AddMonths(1)
                           &
                           cond);
                row["CurrentMonthActual"] = currentMonthActual;

                decimal YTDActual = TablesLogic.tBudgetTransactionLog
                    .Select(TablesLogic.tBudgetTransactionLog.TransactionAmount.Sum())
                    .Where(TablesLogic.tBudgetTransactionLog.IsDeleted == 0
                           &
                           TablesLogic.tBudgetTransactionLog.BudgetID == budget.ObjectID
                           &
                           TablesLogic.tBudgetTransactionLog.AccountID == balance.AccountID
                           &
                           TablesLogic.tBudgetTransactionLog.TransactionType.In(1, 2, 12, 13, 14)
                           &
                           TablesLogic.tBudgetTransactionLog.DateOfExpenditure >= budgetPeriod.StartDate
                           &
                           TablesLogic.tBudgetTransactionLog.DateOfExpenditure <= formattedYTD.AddMonths(1)
                           &
                           cond);
                row["YTDActual"] = YTDActual;

                decimal YTDBudget = 0;
                switch (formattedYTD.Month)
                {
                    case 12: YTDBudget += balance.OpeningBalance12.Value;
                        goto case 11;
                    case 11: YTDBudget += balance.OpeningBalance11.Value;
                        goto case 10;
                    case 10: YTDBudget += balance.OpeningBalance10.Value;
                        goto case 9;
                    case 9: YTDBudget += balance.OpeningBalance09.Value;
                        goto case 8;
                    case 8: YTDBudget += balance.OpeningBalance08.Value;
                        goto case 7;
                    case 7: YTDBudget += balance.OpeningBalance07.Value;
                        goto case 6;
                    case 6: YTDBudget += balance.OpeningBalance06.Value;
                        goto case 5;
                    case 5: YTDBudget += balance.OpeningBalance05.Value;
                        goto case 4;
                    case 4: YTDBudget += balance.OpeningBalance04.Value;
                        goto case 3;
                    case 3: YTDBudget += balance.OpeningBalance03.Value;
                        goto case 2;
                    case 2: YTDBudget += balance.OpeningBalance02.Value;
                        goto case 1;
                    case 1: YTDBudget += balance.OpeningBalance01.Value;
                        break;
                }

                row["YTDBudget"] = YTDBudget;

                decimal budgetBalance = balance.TotalOpeningBalance.Value - Convert.ToDecimal(row["YTDActual"]);

                row["BudgetBalance"] = budgetBalance;

                row["Variance"] = (balance.TotalOpeningBalance.Value != 0)
                                    ? budgetBalance / balance.TotalOpeningBalance.Value
                                    : 0;

                result.Rows.Add(row);
            }

            return result;
        }
Beispiel #21
0
        /// <summary>
        /// Returns a Data Table representing the Capex Report table structure.
        /// </summary>
        /// <param name="location"></param>
        /// <param name="YTD"></param>
        /// <returns>DataTable</returns>
        public static DataTable CapexReport(OLocation location, DateTime YTD)
        {
            DateTime formattedYTD = new DateTime(YTD.Year, YTD.Month, 1);
            DataTable result = new DataTable("Capex");
            // Table structure: Description | Year Budget | Current Month Actual
            result.Columns.Add("Description");
            result.Columns.Add("YearBudget", typeof(decimal));
            result.Columns.Add("CurrentMonthActual", typeof(decimal));
            result.Columns.Add("YTDActual", typeof(decimal));
            result.Columns.Add("YTDBudget", typeof(decimal));
            //if (location.ParentPath.StartsWith(EnumCCLGroup.Admin.ToString()))
            //{
            //    OAccount acc = TablesLogic.tAccount.Load(
            //        TablesLogic.tAccount.ObjectName == EnumCCLGroup.Admin.ToString()
            //        & TablesLogic.tAccount.Type == 0);
            //}

            // From Location & year get the Budget Period 
            //OBudgetPeriod BP = TablesLogic.tBudgetPeriod.Load(
            //    TablesLogic.tBudgetPeriod.Budget.ApplicableLocations.ObjectID == location.ObjectID
            //    & TablesLogic.tBudgetPeriod.ObjectName.Like("%" + year + "%"));
            OBudgetPeriod budgetPeriod = TablesLogic.tBudgetPeriod.Load(
                TablesLogic.tBudgetPeriod.Budget.ApplicableLocations.ObjectID == location.ObjectID
                &
                TablesLogic.tBudgetPeriod.StartDate <= formattedYTD
                &
                TablesLogic.tBudgetPeriod.EndDate >= formattedYTD
                );

            //From BP get List BPOB
            if (budgetPeriod != null)
            {
                DataList<OBudgetPeriodOpeningBalance> BPOB = budgetPeriod.BudgetPeriodOpeningBalances;
                //From BPOB get All Accounts then for loop and only get Account under Capex
                List<OBudgetPeriodOpeningBalance> FinalBPOB = new List<OBudgetPeriodOpeningBalance>();
                foreach (OBudgetPeriodOpeningBalance OB in BPOB)
                {
                    if (OB.Account.Path.Contains("Capex"))
                        FinalBPOB.Add(OB);
                }

                foreach (OBudgetPeriodOpeningBalance fOB in FinalBPOB)
                {
                    DataRow row = result.NewRow();
                    if (string.IsNullOrEmpty(fOB.Account.Description))
                        row["Description"] = fOB.Account.ObjectName;
                    else
                        row["Description"] = fOB.Account.Description;
                    row["YearBudget"] = fOB.TotalOpeningBalance;

                    decimal currentMonthActual = TablesLogic.tBudgetTransactionLog
                        .Select(TablesLogic.tBudgetTransactionLog.TransactionAmount.Sum())
                        .Where(TablesLogic.tBudgetTransactionLog.IsDeleted == 0
                               &
                               TablesLogic.tBudgetTransactionLog.BudgetID == fOB.BudgetPeriod.Budget.ObjectID
                               &
                               TablesLogic.tBudgetTransactionLog.AccountID == fOB.AccountID
                               &
                               TablesLogic.tBudgetTransactionLog.TransactionType.In(1, 2, 12, 13, 14)
                               &
                               TablesLogic.tBudgetTransactionLog.DateOfExpenditure >= formattedYTD
                               &
                               TablesLogic.tBudgetTransactionLog.DateOfExpenditure < formattedYTD.AddMonths(1));

                    row["CurrentMonthActual"] = currentMonthActual;

                    decimal YTDActual = TablesLogic.tBudgetTransactionLog
                    .Select(TablesLogic.tBudgetTransactionLog.TransactionAmount.Sum())
                    .Where(TablesLogic.tBudgetTransactionLog.IsDeleted == 0
                           &
                           TablesLogic.tBudgetTransactionLog.BudgetID == fOB.BudgetPeriod.Budget.ObjectID
                           &
                           TablesLogic.tBudgetTransactionLog.AccountID == fOB.AccountID
                           &
                           TablesLogic.tBudgetTransactionLog.TransactionType.In(1, 2, 12, 13, 14)
                           &
                           TablesLogic.tBudgetTransactionLog.DateOfExpenditure >= budgetPeriod.StartDate
                           &
                           TablesLogic.tBudgetTransactionLog.DateOfExpenditure < formattedYTD.AddMonths(1));
                    row["YTDActual"] = YTDActual;

                    decimal YTDBudget = 0;
                    switch (formattedYTD.Month)
                    {
                        case 12: YTDBudget += fOB.OpeningBalance12.Value;
                            goto case 11;
                        case 11: YTDBudget += fOB.OpeningBalance11.Value;
                            goto case 10;
                        case 10: YTDBudget += fOB.OpeningBalance10.Value;
                            goto case 9;
                        case 9: YTDBudget += fOB.OpeningBalance09.Value;
                            goto case 8;
                        case 8: YTDBudget += fOB.OpeningBalance08.Value;
                            goto case 7;
                        case 7: YTDBudget += fOB.OpeningBalance07.Value;
                            goto case 6;
                        case 6: YTDBudget += fOB.OpeningBalance06.Value;
                            goto case 5;
                        case 5: YTDBudget += fOB.OpeningBalance05.Value;
                            goto case 4;
                        case 4: YTDBudget += fOB.OpeningBalance04.Value;
                            goto case 3;
                        case 3: YTDBudget += fOB.OpeningBalance03.Value;
                            goto case 2;
                        case 2: YTDBudget += fOB.OpeningBalance02.Value;
                            goto case 1;
                        case 1: YTDBudget += fOB.OpeningBalance01.Value;
                            break;
                    }

                    row["YTDBudget"] = YTDBudget;

                    result.Rows.Add(row);
                }
            }

            return result;
        }
Beispiel #22
0
        /// <summary>
        /// Return a Data Table representing the Service to Tenants Report table structure.
        /// </summary>
        /// <param name="location"></param>
        /// <param name="YTD"></param>
        /// <returns>DataTable</returns>
        public static DataTable ServiceToTenantsReport(OLocation location, DateTime YTD)
        {
            // Validate User Access Right
            // TO DO

            DateTime formattedYTD = new DateTime(YTD.Year, 1, 1);
            DataTable result = new DataTable("ServiceToTenants");
            // Table structure: TypeOfService | YearBudget | 
            // Jan | Feb | Mar | Apr | May | Jun |
            // Jul | Aug | Sep | Oct | Nov | Dec | 
            // YTDActual | YTDBudget | BudgetBalance
            result.Columns.Add("TypeOfService");
            result.Columns.Add("YearBudget", typeof(decimal));
            result.Columns.Add("Jan", typeof(decimal));
            result.Columns.Add("Feb", typeof(decimal));
            result.Columns.Add("Mar", typeof(decimal));
            result.Columns.Add("Apr", typeof(decimal));
            result.Columns.Add("May", typeof(decimal));
            result.Columns.Add("Jun", typeof(decimal));
            result.Columns.Add("Jul", typeof(decimal));
            result.Columns.Add("Aug", typeof(decimal));
            result.Columns.Add("Sep", typeof(decimal));
            result.Columns.Add("Oct", typeof(decimal));
            result.Columns.Add("Nov", typeof(decimal));
            result.Columns.Add("Dec", typeof(decimal));
            result.Columns.Add("YTDActual", typeof(decimal));
            result.Columns.Add("YTDBudget", typeof(decimal));
            result.Columns.Add("BudgetBalance", typeof(decimal));

            OCode handymanServiceTypeOfWork = TablesLogic.tCode.Load(
                TablesLogic.tCode.ObjectName == "Handyman Services"
                &
                TablesLogic.tCode.CodeType.ObjectName == "TypeOfWork"
                );

            DateTime YTDStartOfYear = new DateTime(YTD.Year, 1, 1);
            DateTime YTDEndOfYear = new DateTime(YTD.Year, 12, 31);

            List<OWork> workList = TablesLogic.tWork.LoadList(
                TablesLogic.tWork.ActualTypeOfWorkID == handymanServiceTypeOfWork.ObjectID
                &
                TablesLogic.tWork.IsChargedToCaller == 1
                &
                TablesLogic.tWork.ActualStartDateTime >= YTDStartOfYear
                &
                TablesLogic.tWork.ActualEndDateTime <= YTDEndOfYear
                );

            string[] monthIndices = { "", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };

            foreach (OWork work in workList)
            {
                DataRow row = result.NewRow();

                row["TypeOfService"] = work.TypeOfService.ObjectName;

                row["YearBudget"] = 0;

                row["YTDBudget"] = 0;

                row["BudgetBalance"] = 0;

                row["Jan"] = row["Feb"] = row["Mar"] = row["Apr"] = row["May"] = row["Jun"] =
                    row["Jul"] = row["Aug"] = row["Sep"] = row["Oct"] = row["Nov"] = row["Dec"] = 0;

                DataList<OWorkCost> workCostList = work.WorkCost;

                decimal totalWorkCost = 0;

                foreach (OWorkCost workCost in workCostList)
                {
                    totalWorkCost += workCost.ActualCostTotal.Value;
                }

                // Assuming Work only last within a day
                if (work.ActualStartDateTime != null)
                    row[monthIndices[work.ActualStartDateTime.Value.Month]] = totalWorkCost;

                if (YTD.Month >= work.ActualStartDateTime.Value.Month)
                    row["YTDActual"] = totalWorkCost;
                else
                    row["YTDActual"] = 0;

                result.Rows.Add(row);
            }

            return result;
        }
Beispiel #23
0
        /// <summary>
        /// Return a Data Table representing the Service Contract Report table structure.
        /// </summary>
        /// <param name="location"></param>
        /// <param name="YTD"></param>
        /// <returns>DataTable</returns>
        public static DataTable ServiceContractsReport(OLocation location, DateTime YTD)
        {
            // Validate User Access Right
            // TO DO

            DateTime formattedYTD = new DateTime(YTD.Year, YTD.Month, 1);
            DataTable result = new DataTable("ServiceContracts");
            // Table structure: BudgetSubHead | Contractor | 
            // ContractStart | ContractEnd | Contract_noofmth |
            // ContractSum_permth | ContractSum_perannum | TotalContractSum |
            // RemarksStatusofRenewal
            result.Columns.Add("BudgetSubHead");
            result.Columns.Add("Contractor");
            result.Columns.Add("ContractStart", typeof(DateTime));
            result.Columns.Add("ContractEnd", typeof(DateTime));
            result.Columns.Add("Contract_noofmth", typeof(int));
            result.Columns.Add("ContractSum_permth", typeof(decimal));
            result.Columns.Add("ContractSum_perannum", typeof(decimal));
            result.Columns.Add("TotalContractSum", typeof(decimal));
            result.Columns.Add("RemarksStatusofRenewal");

            List<OContract> contractList = TablesLogic.tContract.LoadList(
                TablesLogic.tContract.Locations.ObjectID == location.ObjectID
                &
                TablesLogic.tContract.ContractStartDate <= formattedYTD
                &
                TablesLogic.tContract.ContractEndDate >= formattedYTD
                );

            if (contractList == null || contractList.Count == 0) return result;

            int count = 1;

            foreach (OContract contract in contractList)
            {
                if (contract.PurchaseOrderID != null)
                {
                    DataRow row = result.NewRow();

                    OAccount account = null;

                    if (contract.Vendor != null)
                        row["Contractor"] = contract.Vendor.ObjectName;
                    else
                        row["Contractor"] = "";
                    row["ContractStart"] = contract.ContractStartDate;
                    row["ContractEnd"] = contract.ContractEndDate;

                    int contractDurationInMonths = 0;
                    DateTime timeCursor = contract.ContractStartDate.Value;
                    while (true)
                    {
                        if (timeCursor >= contract.ContractEndDate.Value)
                            break;
                        timeCursor = timeCursor.AddMonths(1);
                        contractDurationInMonths++;
                    }

                    int contractDurationInYears = contract.ContractEndDate.Value.Year - contract.ContractStartDate.Value.Year + 1;
                    row["Contract_noofmth"] = contractDurationInMonths;

                    decimal? contractSum = 0;

                    DataList<OPurchaseBudget> purchaseBudgetList = contract.PurchaseOrder.PurchaseBudgets;

                    foreach (OPurchaseBudget purchaseBudget in purchaseBudgetList)
                    {
                        account = purchaseBudget.Account;

                        contractSum += purchaseBudget.Amount;
                    }

                    if (account != null)
                    {
                        row["BudgetSubHead"] = account.ParentID == null ? account.ObjectName : account.Parent.ObjectName;

                        row["ContractSum_permth"] = (contractDurationInMonths != 0)
                                                             ? contractSum / contractDurationInMonths
                                                             : 0;
                        row["ContractSum_perannum"] = (contractDurationInYears != 0)
                                                           ? contractSum / contractDurationInYears
                                                           : 0;
                        row["TotalContractSum"] = contractSum;// contract.ContractSum;

                        row["RemarksStatusofRenewal"] = "";

                        result.Rows.Add(row);
                    }
                }
            }

            return result;
        }
 public static OLocation WitsTheatre(string clientId)
 {
     var deco = new OLocation
         {
             Name = "Wits Theatre",
             Address = "Address of deco",
             Category = new OLocationCategory {Id = "1", Description = "Category"},
             ClientId = clientId,
             Id = $"{clientId}/2",
             Reference = "Internal Ref",
             Shape = EZoneShape.Radius,
             Coords = new SpecializedObservableCollection<OCoord>
                 {
                     new OCoord {Latitude = -26.190217, Longitude = 28.030218, Radius = 100}
                 }
         };
     return deco;
 }
 public static OLocation Home(string clientId)
 {
     var deco = new OLocation
     {
         Name = "158 Epsom Terrace",
         Address = "Address of deco",
         ClientId = clientId,
         Id = $"{clientId}/44f44cb9-5fed-4623-862a-e3d998e6160b",
         Reference = "Internal Ref",
         Shape = EZoneShape.Radius,
         Coords = new SpecializedObservableCollection<OCoord>
                 {
                     new OCoord {Latitude = -26.041245, Longitude = 28.020495, Radius = 100}
                 }
     };
     return deco;
 }
Beispiel #26
0
 private static void DecoLookup(Api api, OLocation location)
 {
     location.DefaultStopTime = TimeSpan.FromMinutes(10);
     api.ExecuteRequest(new UpdateLocation(api.Context, location));
     Console.WriteLine($"Updated Location {location.Id}");
 }
Beispiel #27
0
        public static decimal GetLocationTotalGFA(OLocation loc)
        {
            decimal totalGFA = 0;
            if (loc.IsPhysicalLocation == 1)
            {
                if (loc.GrossFloorArea != null)
                    totalGFA = loc.GrossFloorArea.Value;
            }
            else
            {
                List<OLocation> locationList = TablesLogic.tLocation[TablesLogic.tLocation.ParentID == loc.ObjectID];
                foreach (OLocation location in locationList)
                    totalGFA += GetLocationTotalGFA(location);
            }
            return totalGFA;

            TWork w1 = new TWork();
            TWork w2 = new TWork();

            w1.Select(
                w1.ObjectID)
            .Where(
                w2.Select(w2.ObjectID.Count()).Where(w2.ParentID==w1.ObjectID) == 0
            );

        }