public GroupBalance GetGroupBalance(UUID groupID) { GroupBalance gb = new GroupBalance() { GroupFee = 0, LandFee = 0, ObjectFee = 0, ParcelDirectoryFee = 0, TotalTierCredits = 0, TotalTierDebit = 0, StartingDate = DateTime.UtcNow }; Dictionary <string, object> where = new Dictionary <string, object>(1); where["PrincipalID"] = groupID; List <string> queryResults = m_gd.Query(new string[] { "*" }, "stardust_currency", new QueryFilter() { andFilters = where }, null, null, null); if (queryResults.Count == 0) { GroupCurrencyCreate(groupID); return(gb); } int.TryParse(queryResults[1], out gb.TotalTierCredits); return(gb); }
/// <summary> /// Sends the details about what /// </summary> /// <param name="client"></param> /// <param name="agentID"></param> /// <param name="groupID"></param> /// <param name="transactionID"></param> /// <param name="sessionID"></param> /// <param name="currentInterval"></param> /// <param name="intervalDays"></param> private void client_OnGroupAccountDetailsRequest(IClientAPI client, UUID agentID, UUID groupID, UUID transactionID, UUID sessionID, int currentInterval, int intervalDays) { IGroupsModule groupsModule = client.Scene.RequestModuleInterface <IGroupsModule>(); if (groupsModule != null && groupsModule.GroupPermissionCheck(agentID, groupID, GroupPowers.Accountable)) { IMoneyModule moneyModule = client.Scene.RequestModuleInterface <IMoneyModule>(); if (moneyModule != null) { int amt = moneyModule.Balance(groupID); List <GroupAccountHistory> history = moneyModule.GetTransactions(groupID, agentID, currentInterval, intervalDays); history = (from h in history where h.Stipend select h).ToList(); //We don't want payments, we only want stipends which we sent to users GroupBalance balance = moneyModule.GetGroupBalance(groupID); client.SendGroupAccountingDetails(client, groupID, transactionID, sessionID, amt, currentInterval, intervalDays, Util.BuildYMDDateString( balance.StartingDate.AddDays(-currentInterval * intervalDays)), history.ToArray()); } else { client.SendGroupAccountingDetails(client, groupID, transactionID, sessionID, 0, currentInterval, intervalDays, "Never", new GroupAccountHistory[0]); } } }
static GroupBalance ParseGroupBalance(List <string> queryResults) { GroupBalance gb = new GroupBalance(); /* ColDef("GroupID", ColumnTypes.String36), * ColDef("Balance", ColumnTypes.Integer30), * ColDef("GroupFee", ColumnTypes.Integer30), * ColDef("LandFee", ColumnTypes.Integer30), * ColDef("ObjectFee", ColumnTypes.Integer30), * ColDef("ParcelDirectoryFee", ColumnTypes.Integer30), * ColDef("TierCredits", ColumnTypes.Integer30), * ColDef("TierDebits", ColumnTypes.Integer30), */ int.TryParse(queryResults [1], out gb.Balance); int.TryParse(queryResults [2], out gb.GroupFee); int.TryParse(queryResults [3], out gb.LandFee); int.TryParse(queryResults [4], out gb.ObjectFee); int.TryParse(queryResults [5], out gb.ParcelDirectoryFee); int.TryParse(queryResults [6], out gb.TotalTierCredits); int.TryParse(queryResults [7], out gb.TotalTierDebit); gb.StartingDate = DateTime.UtcNow; return(gb); }
private void client_OnGroupAccountSummaryRequest(IClientAPI client, UUID agentID, UUID groupID, UUID requestID, int currentInterval, int intervalDays) { IGroupsModule groupsModule = client.Scene.RequestModuleInterface <IGroupsModule>(); if (groupsModule != null && groupsModule.GroupPermissionCheck(agentID, groupID, GroupPowers.Accountable)) { IMoneyModule moneyModule = client.Scene.RequestModuleInterface <IMoneyModule>(); if (moneyModule != null) { int amt = moneyModule.Balance(groupID); GroupBalance balance = moneyModule.GetGroupBalance(groupID); client.SendGroupAccountingSummary(client, groupID, requestID, amt, balance.TotalTierDebit, balance.TotalTierCredits, Util.BuildYMDDateString( balance.StartingDate.AddDays(-currentInterval * intervalDays)), currentInterval, intervalDays, Util.BuildYMDDateString(balance.StartingDate.AddDays(intervalDays)), Util.BuildYMDDateString( balance.StartingDate.AddDays(-(currentInterval + 1) * intervalDays)), balance.ParcelDirectoryFee, balance.LandFee, balance.GroupFee, balance.ObjectFee); } else { client.SendGroupAccountingSummary(client, groupID, requestID, 0, 0, 0, "Never", currentInterval, intervalDays, "Never", "Never", 0, 0, 0, 0); } } }
public GroupBalance GetGroupBalance(UUID groupID) { if (m_doRemoteOnly) { object remoteValue = DoRemoteByURL("CurrencyServerURI", groupID); return((remoteValue != null) ? (GroupBalance)remoteValue : new GroupBalance()); } GroupBalance gb = new GroupBalance { GroupFee = 0, LandFee = 0, ObjectFee = 0, ParcelDirectoryFee = 0, TotalTierCredits = 0, TotalTierDebits = 0, Balance = 0, StartingDate = DateTime.UtcNow }; Dictionary <string, object> where = new Dictionary <string, object> (1); where ["GroupID"] = groupID; List <string> queryResults = GD.Query(new [] { "*" }, _GROUPREALM, new QueryFilter { andFilters = where }, null, null, null); if (queryResults.Count == 0) { GroupCurrencyCreate(groupID); return(gb); } return(ParseGroupBalance(queryResults)); }
void GroupCurrencyUpdate(UUID groupID, GroupBalance gb, bool full) { if (full) { GD.Update(_GROUPREALM, new Dictionary <string, object> { { "GroupFee", gb.GroupFee }, { "LandFee", gb.LandFee }, { "ObjectFee", gb.ObjectFee }, { "ParcelDirectoryFee", gb.ParcelDirectoryFee }, { "TotalTierCredits", gb.TotalTierCredits }, { "TotalTierDebit", gb.TotalTierDebit }, { "Balance", gb.Balance } }, null, new QueryFilter { andFilters = new Dictionary <string, object> { { "GroupID", groupID } } }, null, null ); } else { GD.Update(_GROUPREALM, new Dictionary <string, object> { { "TotalTierCredits", gb.TotalTierCredits }, { "TotalTierDebit", gb.TotalTierDebit } }, null, new QueryFilter { andFilters = new Dictionary <string, object> { { "GroupID", groupID } } }, null, null); } }
public GroupBalance GetGroupBalance(UUID groupID) { object remoteValue = DoRemoteByURL("CurrencyServerURI", groupID); if (remoteValue != null || m_doRemoteOnly) { return((GroupBalance)remoteValue); } GroupBalance gb = new GroupBalance() { GroupFee = 0, LandFee = 0, ObjectFee = 0, ParcelDirectoryFee = 0, TotalTierCredits = 0, TotalTierDebit = 0, StartingDate = DateTime.UtcNow }; Dictionary <string, object> where = new Dictionary <string, object>(1); where["PrincipalID"] = groupID; List <string> queryResults = m_gd.Query(new string[] { "*" }, _REALM, new QueryFilter() { andFilters = where }, null, null, null); if (queryResults.Count == 0) { GroupCurrencyCreate(groupID); return(gb); } int.TryParse(queryResults[1], out gb.TotalTierCredits); return(gb); }
public GroupBalance GetGroupBalance(UUID groupID) { object remoteValue = DoRemoteByURL("CurrencyServerURI", groupID); if (remoteValue != null || m_doRemoteOnly) return (GroupBalance) remoteValue; GroupBalance gb = new GroupBalance() { GroupFee = 0, LandFee = 0, ObjectFee = 0, ParcelDirectoryFee = 0, TotalTierCredits = 0, TotalTierDebit = 0, StartingDate = DateTime.UtcNow }; Dictionary<string, object> where = new Dictionary<string, object>(1); where["PrincipalID"] = groupID; List<string> queryResults = m_gd.Query(new string[] {"*"}, _REALM, new QueryFilter() { andFilters = where }, null, null, null); if (queryResults.Count == 0) { GroupCurrencyCreate(groupID); return gb; } int.TryParse(queryResults[1], out gb.TotalTierCredits); return gb; }
public bool GroupCurrencyTransfer(UUID groupID, UUID userId, bool payUser, string toObjectName, UUID fromObjectID, string fromObjectName, int amount, string description, TransactionType type, UUID transactionID) { GroupBalance gb = new GroupBalance { StartingDate = DateTime.UtcNow }; // Not sure if a group will receive a system payment but.. UserCurrency fromCurrency = userId == UUID.Zero ? null : GetUserCurrency(userId); // Groups (legacy) should not receive stipends if (type == TransactionType.StipendPayment) { return(false); } if (fromCurrency != null) { // Normal users cannot have a credit balance.. check to see whether they have enough money if ((int)fromCurrency.Amount - amount < 0) { return(false); // Not enough money } } // is thiis a payment to the group or to the user? if (payUser) { amount = -1 * amount; } uint fromBalance = 0; if (fromCurrency != null) { // user payment fromCurrency.Amount -= (uint)amount; UserCurrencyUpdate(fromCurrency, true); fromBalance = fromCurrency.Amount; } // track specific group fees switch (type) { case TransactionType.GroupJoin: gb.GroupFee += amount; break; case TransactionType.LandAuction: gb.LandFee += amount; break; case TransactionType.ParcelDirFee: gb.ParcelDirectoryFee += amount; break; } if (payUser) { gb.TotalTierDebit -= amount; // not sure if this the correct place yet? Are these currency or land credits? } else { gb.TotalTierCredits += amount; // .. or this? } // update the group balance gb.Balance += amount; GroupCurrencyUpdate(groupID, gb, true); //Must send out notifications to the users involved so that they get the updates if (m_userInfoService == null) { m_userInfoService = m_registry.RequestModuleInterface <IAgentInfoService>(); m_userAccountService = m_registry.RequestModuleInterface <IUserAccountService> (); } if (m_userInfoService != null) { UserInfo agentInfo = userId == UUID.Zero ? null : m_userInfoService.GetUserInfo(userId.ToString()); UserAccount agentAccount = m_userAccountService.GetUserAccount(null, userId); var groupService = Framework.Utilities.DataManager.RequestPlugin <IGroupsServiceConnector> (); var groupInfo = groupService.GetGroupRecord(userId, groupID, null); var groupName = "Unknown"; if (groupInfo != null) { groupName = groupInfo.GroupName; } if (m_config.SaveTransactionLogs) { AddGroupTransactionRecord( (transactionID == UUID.Zero ? UUID.Random() : transactionID), description, groupID, groupName, userId, (agentAccount == null ? "System" : agentAccount.Name), amount, type, gb.TotalTierCredits, // assume this it the 'total credit for the group but it may be land tier credit?? (int)fromBalance, // this will be zero if this isa system <> group transaction toObjectName, fromObjectName, (agentInfo == null ? UUID.Zero : agentInfo.CurrentRegionID) ); } if (agentInfo != null && agentInfo.IsOnline) { SendUpdateMoneyBalanceToClient(userId, transactionID, agentInfo.CurrentRegionURI, fromBalance, "You paid " + groupName + " " + InWorldCurrency + amount); } } return(true); }
public bool GroupCurrencyTransfer(UUID groupID, UUID userId, bool payUser, string toObjectName, UUID fromObjectID, string fromObjectName, int amount, string description, TransactionType transType, UUID transactionID) { // Groups (legacy) should not receive stipends if (transType == TransactionType.StipendPayment) { return(false); } GroupBalance gb = new GroupBalance { StartingDate = DateTime.UtcNow }; // Not sure if a group will receive a system payment (UUID = Zero) but.. UserCurrency fromuserCurrency = userId == UUID.Zero ? null : GetUserCurrency(userId); if (fromuserCurrency != null) { // Normal users cannot have a credit balance.. check to see whether they have enough money if ((int)fromuserCurrency.Amount - amount < 0) { return(false); // Not enough money } } // is this a payment from a user to the group or from the group to the user? if (payUser) { gb.TotalTierDebits += amount; // not sure if this the correct place yet? Total of group payments amount = -1 * amount; } else { gb.TotalTierCredits += amount; // .. total of group receipts } uint userBalance = 0; if (fromuserCurrency != null) { // user payment fromuserCurrency.Amount -= (uint)amount; UserCurrencyUpdate(fromuserCurrency, true); userBalance = fromuserCurrency.Amount; } // track specific group fees switch (transType) { case TransactionType.GroupJoin: gb.GroupFee += amount; break; case TransactionType.LandAuction: gb.LandFee += amount; break; case TransactionType.ParcelDirFee: gb.ParcelDirectoryFee += amount; break; } // update the group balance gb.Balance += amount; GroupCurrencyUpdate(groupID, gb, true); // Must send out notifications to the users involved so that they get the updates if (m_userInfoService != null) { UserInfo agentInfo = userId == UUID.Zero ? null : m_userInfoService.GetUserInfo(userId.ToString()); UserAccount agentAccount = m_userAccountService.GetUserAccount(null, userId); var groupService = Framework.Utilities.DataManager.RequestPlugin <IGroupsServiceConnector> (); var groupInfo = groupService.GetGroupRecord(userId, groupID, null); var groupName = "Unknown"; if (groupInfo != null) { groupName = groupInfo.GroupName; } // record the group transaction if (m_config.SaveTransactionLogs) { AddGroupTransactionRecord( (transactionID == UUID.Zero ? UUID.Random() : transactionID), description, groupID, groupName, userId, (agentAccount.Valid ? agentAccount.Name : "System"), amount, transType, gb.TotalTierCredits, // assume this it the 'total credit for the group but it may be land tier credit?? (int)userBalance, // this will be zero if this isa system <> group transaction toObjectName, fromObjectName, (agentInfo == null ? UUID.Zero : agentInfo.CurrentRegionID) ); } var paidToMsg = ""; var paidFromMsg = ""; var paidDesc = (description == "" ? "" : " for " + description); if (amount > 0) { paidToMsg = (groupInfo == null ? " received " : groupName + " paid you ") + InWorldCurrency + amount + paidDesc; paidFromMsg = "You paid " + (groupInfo == null ? "" : groupName + " ") + InWorldCurrency + amount + paidDesc; } if (agentInfo != null) { if (payUser) { if (agentInfo.IsOnline) { SendUpdateMoneyBalanceToClient(userId, transactionID, agentInfo.CurrentRegionURI, userBalance, paidToMsg); } } else { if (fromObjectID != UUID.Zero) { SendUpdateMoneyBalanceToClient(fromObjectID, transactionID, agentInfo.CurrentRegionURI, (uint)amount, paidFromMsg); } } } } return(true); }