Checkpoint: removing all hardcoded orgs, not done yet
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
using Swarmops.Basic.Enums;
|
||||
@@ -203,6 +204,10 @@ namespace Swarmops.Logic.Communications
|
||||
|
||||
public override bool Handle (PhoneMessage msg)
|
||||
{
|
||||
Trace.WriteLine(msg); // use parameter to suppress warning
|
||||
|
||||
/* -- all of the phone message handling need to move to app or plugin
|
||||
|
||||
// register new activist
|
||||
// check for words: activist <postal code> <e-mail>
|
||||
msg.ErrorMessage = "\r\nRequest to register as activist.";
|
||||
@@ -241,10 +246,10 @@ namespace Swarmops.Logic.Communications
|
||||
// Handle further info in the message
|
||||
// check for words: activist <postal code> <e-mail>
|
||||
|
||||
}
|
||||
}-- */
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class RenewMembershipHandler : PhoneMessageHandler
|
||||
@@ -261,8 +266,11 @@ namespace Swarmops.Logic.Communications
|
||||
}
|
||||
|
||||
|
||||
public override bool Handle (PhoneMessage msg)
|
||||
public override bool Handle(PhoneMessage msg)
|
||||
{
|
||||
/* This needs to move to a plugin. */
|
||||
|
||||
/*
|
||||
// renew memberships
|
||||
// if there is a third parameter it is the person#
|
||||
string[] smsParts = msg.Message.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
@@ -328,8 +336,13 @@ namespace Swarmops.Logic.Communications
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
return false; */
|
||||
|
||||
|
||||
|
||||
// use parameters to suppress warnings
|
||||
Trace.WriteLine(msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,23 +10,23 @@ namespace Swarmops.Logic.DashboardTasks
|
||||
{
|
||||
public class Tasks: List<TaskGroup>
|
||||
{
|
||||
static public Tasks ForPerson (Person person)
|
||||
static public Tasks ForPersonOrganization (Person person, Organization organization)
|
||||
{
|
||||
Tasks tasks = new Tasks();
|
||||
|
||||
tasks.AddVolunteers(person);
|
||||
tasks.AddExpenseClaims(person);
|
||||
tasks.AddSalaries(person);
|
||||
tasks.AddInboundInvoices(person);
|
||||
tasks.AddReceiptValidation(person);
|
||||
tasks.AddAdvanceDebts(person);
|
||||
tasks.AddPayouts(person);
|
||||
tasks.AddAttestationWarnings(person);
|
||||
tasks.AddVolunteers(person, organization);
|
||||
tasks.AddExpenseClaims(person, organization);
|
||||
tasks.AddSalaries(person, organization);
|
||||
tasks.AddInboundInvoices(person, organization);
|
||||
tasks.AddReceiptValidation(person, organization);
|
||||
tasks.AddAdvanceDebts(person, organization);
|
||||
tasks.AddPayouts(person, organization);
|
||||
tasks.AddAttestationWarnings(person, organization);
|
||||
|
||||
return tasks;
|
||||
}
|
||||
|
||||
private void AddVolunteers (Person person)
|
||||
private void AddVolunteers (Person person, Organization organization)
|
||||
{
|
||||
TaskGroup group = new TaskGroup(TaskGroupType.Volunteers);
|
||||
|
||||
@@ -46,13 +46,13 @@ namespace Swarmops.Logic.DashboardTasks
|
||||
}
|
||||
}
|
||||
|
||||
private void AddExpenseClaims (Person person)
|
||||
private void AddExpenseClaims (Person person, Organization organization)
|
||||
{
|
||||
TaskGroup group = new TaskGroup(TaskGroupType.AttestExpenseClaims);
|
||||
|
||||
// TODO: Loop over roles, get all open claims for roles where person can attest
|
||||
|
||||
ExpenseClaims claims = ExpenseClaims.ForOrganization(Organization.PPSE);
|
||||
ExpenseClaims claims = ExpenseClaims.ForOrganization(organization);
|
||||
|
||||
foreach (ExpenseClaim claim in claims)
|
||||
{
|
||||
@@ -75,13 +75,13 @@ namespace Swarmops.Logic.DashboardTasks
|
||||
}
|
||||
}
|
||||
|
||||
private void AddSalaries (Person person)
|
||||
private void AddSalaries (Person person, Organization organization)
|
||||
{
|
||||
TaskGroup group = new TaskGroup(TaskGroupType.AttestSalaries);
|
||||
|
||||
// TODO: Loop over roles, get all open claims for roles where person can attest
|
||||
|
||||
Salaries salaries = Salaries.ForOrganization(Organization.PPSE);
|
||||
Salaries salaries = Salaries.ForOrganization(organization);
|
||||
|
||||
foreach (Salary salary in salaries)
|
||||
{
|
||||
@@ -97,13 +97,13 @@ namespace Swarmops.Logic.DashboardTasks
|
||||
}
|
||||
}
|
||||
|
||||
private void AddInboundInvoices(Person person)
|
||||
private void AddInboundInvoices(Person person, Organization organization)
|
||||
{
|
||||
TaskGroup group = new TaskGroup(TaskGroupType.AttestInvoices);
|
||||
|
||||
// TODO: Loop over roles, get all open claims for roles where person can attest
|
||||
|
||||
InboundInvoices invoices = InboundInvoices.ForOrganization(Organization.PPSE);
|
||||
InboundInvoices invoices = InboundInvoices.ForOrganization(organization);
|
||||
|
||||
foreach (InboundInvoice invoice in invoices)
|
||||
{
|
||||
@@ -119,19 +119,19 @@ namespace Swarmops.Logic.DashboardTasks
|
||||
}
|
||||
}
|
||||
|
||||
private void AddReceiptValidation(Person person)
|
||||
private void AddReceiptValidation(Person person, Organization organization)
|
||||
{
|
||||
TaskGroup group = new TaskGroup(TaskGroupType.ValidateExpenseClaims);
|
||||
|
||||
// TODO: Loop over roles, get all open claims for roles where person can attest
|
||||
|
||||
if (!person.GetAuthority().HasPermission(Permission.CanDoEconomyTransactions, Organization.PPSEid, Geography.RootIdentity, Authorization.Flag.AnyGeographyExactOrganization))
|
||||
if (!person.GetAuthority().HasPermission(Permission.CanDoEconomyTransactions, organization.Identity, Geography.RootIdentity, Authorization.Flag.AnyGeographyExactOrganization))
|
||||
{
|
||||
// no permission, no tasks
|
||||
return;
|
||||
}
|
||||
|
||||
ExpenseClaims claims = ExpenseClaims.ForOrganization(Organization.PPSE);
|
||||
ExpenseClaims claims = ExpenseClaims.ForOrganization(organization);
|
||||
|
||||
foreach (ExpenseClaim claim in claims)
|
||||
{
|
||||
@@ -148,13 +148,13 @@ namespace Swarmops.Logic.DashboardTasks
|
||||
}
|
||||
|
||||
|
||||
private void AddAdvanceDebts (Person person)
|
||||
private void AddAdvanceDebts (Person person, Organization organization)
|
||||
{
|
||||
TaskGroup group = new TaskGroup(TaskGroupType.DeclareAdvanceDebts);
|
||||
|
||||
// TODO: One task group for each organization, actually
|
||||
|
||||
ExpenseClaims claims = ExpenseClaims.FromClaimingPersonAndOrganization(person, Organization.PPSE);
|
||||
ExpenseClaims claims = ExpenseClaims.FromClaimingPersonAndOrganization(person, organization);
|
||||
|
||||
decimal debt = 0.0m;
|
||||
|
||||
@@ -174,18 +174,18 @@ namespace Swarmops.Logic.DashboardTasks
|
||||
}
|
||||
|
||||
|
||||
private void AddPayouts (Person person)
|
||||
private void AddPayouts (Person person, Organization organization)
|
||||
{
|
||||
TaskGroup group = new TaskGroup(TaskGroupType.Payout);
|
||||
TaskGroup groupUrgent = new TaskGroup(TaskGroupType.PayoutUrgently);
|
||||
TaskGroup groupOverdue = new TaskGroup(TaskGroupType.PayoutOverdue);
|
||||
|
||||
if (!person.GetAuthority().HasPermission(Permission.CanPayOutMoney, Organization.PPSEid, 1, Authorization.Flag.AnyGeographyExactOrganization))
|
||||
if (!person.GetAuthority().HasPermission(Permission.CanPayOutMoney, organization.Identity, 1, Authorization.Flag.AnyGeographyExactOrganization))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Payouts payouts = Payouts.Construct(Organization.PPSE);
|
||||
Payouts payouts = Payouts.Construct(organization);
|
||||
|
||||
foreach (Payout payout in payouts)
|
||||
{
|
||||
@@ -221,16 +221,16 @@ namespace Swarmops.Logic.DashboardTasks
|
||||
}
|
||||
|
||||
|
||||
private void AddAttestationWarnings (Person person)
|
||||
private void AddAttestationWarnings (Person person, Organization organization)
|
||||
{
|
||||
TaskGroup group = new TaskGroup(TaskGroupType.AttestationWarning);
|
||||
|
||||
if (!person.GetAuthority().HasPermission(Permission.CanSeeEconomyTransactions, Organization.PPSEid, 1, Authorization.Flag.AnyGeographyExactOrganization))
|
||||
if (!person.GetAuthority().HasPermission(Permission.CanSeeEconomyTransactions, organization.Identity, 1, Authorization.Flag.AnyGeographyExactOrganization))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
InboundInvoices invoices = InboundInvoices.ForOrganization(Organization.PPSE);
|
||||
InboundInvoices invoices = InboundInvoices.ForOrganization(organization);
|
||||
|
||||
DateTime threshold = DateTime.Today.AddDays(10);
|
||||
|
||||
|
||||
+18
-23
@@ -29,28 +29,23 @@ namespace Swarmops.Logic.Financial
|
||||
}
|
||||
|
||||
public static Payouts Construct (Organization organization)
|
||||
{
|
||||
return Construct(organization.Identity);
|
||||
}
|
||||
|
||||
public static Payouts Construct (int organizationId)
|
||||
{
|
||||
// Construct a list of not-yet-created payouts. Basically, these are the things that
|
||||
// Economy hasn't yet filed with the bank.
|
||||
|
||||
Payouts result = new Payouts();
|
||||
|
||||
AddUnpaidExpenseClaims(result, organizationId);
|
||||
AddUnpaidInboundInvoices(result, organizationId);
|
||||
AddUnpaidSalaries(result, organizationId);
|
||||
AddUnpaidCashAdvances(result, organizationId);
|
||||
AddUnpaidExpenseClaims(result, organization);
|
||||
AddUnpaidInboundInvoices(result, organization);
|
||||
AddUnpaidSalaries(result, organization);
|
||||
AddUnpaidCashAdvances(result, organization);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void AddUnpaidExpenseClaims(Payouts payoutList, int organizationId)
|
||||
private static void AddUnpaidExpenseClaims(Payouts payoutList, Organization organization)
|
||||
{
|
||||
ExpenseClaims claims = ExpenseClaims.FromOrganization(Organization.FromIdentity(organizationId));
|
||||
ExpenseClaims claims = ExpenseClaims.FromOrganization(organization);
|
||||
|
||||
Dictionary<int, Payout> payoutLookup = new Dictionary<int, Payout>();
|
||||
|
||||
@@ -75,7 +70,7 @@ namespace Swarmops.Logic.Financial
|
||||
{
|
||||
// No. Create a new payout for this person.
|
||||
|
||||
BasicPayout basicPayout = new BasicPayout(0, organizationId, claim.Claimer.BankName,
|
||||
BasicPayout basicPayout = new BasicPayout(0, organization.Identity, claim.Claimer.BankName,
|
||||
claim.Claimer.BankClearing + " / " + claim.Claimer.BankAccount, string.Empty, 0,
|
||||
DateTime.MinValue, false, DateTime.Now, 0);
|
||||
Payout payout = Payout.FromBasic(basicPayout);
|
||||
@@ -91,7 +86,7 @@ namespace Swarmops.Logic.Financial
|
||||
// At this point, all the expense claims have been added - but we need to add the open
|
||||
// cash advances and deduct them.
|
||||
|
||||
CashAdvances cashAdvances = CashAdvances.ForOrganization(Organization.FromIdentity(organizationId));
|
||||
CashAdvances cashAdvances = CashAdvances.ForOrganization(organization);
|
||||
cashAdvances = cashAdvances.WherePaid;
|
||||
|
||||
// At this point, only open and paid cash advances are in the list: they're debts to the org
|
||||
@@ -151,9 +146,9 @@ namespace Swarmops.Logic.Financial
|
||||
|
||||
|
||||
|
||||
private static void AddUnpaidCashAdvances(Payouts payoutList, int organizationId)
|
||||
private static void AddUnpaidCashAdvances(Payouts payoutList, Organization organization)
|
||||
{
|
||||
CashAdvances advances = CashAdvances.ForOrganization(Organization.FromIdentity(organizationId));
|
||||
CashAdvances advances = CashAdvances.ForOrganization(organization);
|
||||
advances = advances.WhereAttested;
|
||||
advances = advances.WhereUnpaid;
|
||||
|
||||
@@ -178,7 +173,7 @@ namespace Swarmops.Logic.Financial
|
||||
{
|
||||
// No. Create a new payout for this person.
|
||||
|
||||
BasicPayout basicPayout = new BasicPayout(0, organizationId, advance.Person.BankName,
|
||||
BasicPayout basicPayout = new BasicPayout(0, organization.Identity, advance.Person.BankName,
|
||||
advance.Person.BankClearing + " / " + advance.Person.BankAccount, string.Empty, 0,
|
||||
DateTime.MinValue, false, DateTime.Now, 0);
|
||||
Payout payout = Payout.FromBasic(basicPayout);
|
||||
@@ -224,15 +219,15 @@ namespace Swarmops.Logic.Financial
|
||||
|
||||
|
||||
|
||||
private static void AddUnpaidInboundInvoices(Payouts payoutList, int organizationId)
|
||||
private static void AddUnpaidInboundInvoices(Payouts payoutList, Organization organization)
|
||||
{
|
||||
InboundInvoices invoices = InboundInvoices.ForOrganization(Organization.PPSE);
|
||||
InboundInvoices invoices = InboundInvoices.ForOrganization(organization);
|
||||
|
||||
foreach (InboundInvoice invoice in invoices)
|
||||
{
|
||||
if (invoice.Attested)
|
||||
{
|
||||
BasicPayout basicPayout = new BasicPayout(0, organizationId, string.Empty,
|
||||
BasicPayout basicPayout = new BasicPayout(0, organization.Identity, string.Empty,
|
||||
invoice.PayToAccount, invoice.Ocr.Length > 0? "OCR " + invoice.Ocr : "Ref# " + invoice.InvoiceReference, (Int64) (invoice.Amount * 100),
|
||||
invoice.DueDate, false, DateTime.Now, 0);
|
||||
Payout payout = Payout.FromBasic(basicPayout);
|
||||
@@ -244,11 +239,11 @@ namespace Swarmops.Logic.Financial
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddUnpaidSalaries (Payouts payoutList, int organizationId)
|
||||
private static void AddUnpaidSalaries (Payouts payoutList, Organization organization)
|
||||
{
|
||||
Int64 taxTotalCents = 0;
|
||||
|
||||
Salaries salaries = Salaries.ForOrganization(Organization.FromIdentity(organizationId));
|
||||
Salaries salaries = Salaries.ForOrganization(organization);
|
||||
List<int> identityList = new List<int>();
|
||||
DateTime payDay = DateTime.MaxValue;
|
||||
|
||||
@@ -264,7 +259,7 @@ namespace Swarmops.Logic.Financial
|
||||
PayrollItem payrollItem = salary.PayrollItem;
|
||||
Person employee = payrollItem.Person;
|
||||
|
||||
BasicPayout basicPayout = new BasicPayout(0, organizationId, employee.BankName,
|
||||
BasicPayout basicPayout = new BasicPayout(0, organization.Identity, employee.BankName,
|
||||
employee.BankClearing+" / "+employee.BankAccount, "[Loc]Financial_SalarySpecification|[Date]" + salary.PayoutDate.ToString(CultureInfo.InvariantCulture),
|
||||
salary.NetSalaryCents, salary.PayoutDate, false, DateTime.Now, 0);
|
||||
Payout payout = Payout.FromBasic(basicPayout);
|
||||
@@ -308,7 +303,7 @@ namespace Swarmops.Logic.Financial
|
||||
}
|
||||
|
||||
|
||||
BasicPayout basicPayout = new BasicPayout(0, organizationId, "[Loc]Financial_TheTaxMan",
|
||||
BasicPayout basicPayout = new BasicPayout(0, organization.Identity, "[Loc]Financial_TheTaxMan",
|
||||
string.Empty, referenceString,
|
||||
taxTotalCents, payDay, false, DateTime.Now, 0);
|
||||
Payout payout = Payout.FromBasic(basicPayout);
|
||||
|
||||
@@ -11,9 +11,10 @@ namespace Swarmops.Logic.Governance
|
||||
{
|
||||
// nothing much here
|
||||
|
||||
public static Ballots ForElection (Election election)
|
||||
|
||||
public static Ballots ForElection (Election election, Organization organization)
|
||||
{
|
||||
return FromArray(SwarmDb.GetDatabaseForReading().GetBallots(election, Organization.PPSE)); // HACK HACK HACK -- PPSE hardcoded
|
||||
return FromArray(SwarmDb.GetDatabaseForReading().GetBallots(election, organization));
|
||||
}
|
||||
|
||||
public static Dictionary<int,int> GetBallotsForPerson (Person person)
|
||||
|
||||
@@ -271,10 +271,11 @@ namespace Swarmops.Logic.Security
|
||||
return Authorization.CheckAuthorization(new PermissionSet(perm), -1, -1, this, Authorization.Flag.AnyGeographyAnyOrganization);
|
||||
}
|
||||
|
||||
/* -- unused, apparently
|
||||
private bool HasPermission (Permission perm, int organizationId, Authorization.Flag flags)
|
||||
{
|
||||
return Authorization.CheckAuthorization(new PermissionSet(perm), organizationId, Organization.RootIdentity, this, flags);
|
||||
}
|
||||
} */
|
||||
|
||||
public bool HasPermission (Permission perm, int organizationId, int geographyId, Authorization.Flag flags)
|
||||
{
|
||||
|
||||
@@ -451,9 +451,9 @@ namespace Swarmops.Logic.Security
|
||||
|
||||
var clearedPeople = new Dictionary<int, Person>();
|
||||
|
||||
// TODO: Add org admin role, able to see previous members that aren't anonymized yet
|
||||
|
||||
// Clear by organization roles
|
||||
bool CanSeeNonMembers = authority.HasPermission(Permission.CanSeeNonMembers,Organization.PPSEid,-1,Flag.AnyGeographyExactOrganization);
|
||||
|
||||
foreach (BasicPersonRole role in authority.OrganizationPersonRoles)
|
||||
{
|
||||
@@ -481,11 +481,11 @@ namespace Swarmops.Logic.Security
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* -- commented out. This means "does the current authority have Org Admin privileges over Person"?
|
||||
else if (CanSeeNonMembers)
|
||||
{ //person isn't member anywhere
|
||||
clearedPeople[person.Identity] = person;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Swarmops.Basic.Enums;
|
||||
using Swarmops.Basic.Exceptions;
|
||||
using Swarmops.Basic.Interfaces;
|
||||
@@ -25,8 +26,10 @@ namespace Swarmops.Logic.Special.Sweden
|
||||
return SwedishForumDatabase.GetDatabase().GetAccountName(person.SwedishForumAccountId);
|
||||
}
|
||||
|
||||
|
||||
public void SetPersonHandle (int personId, string newHandle)
|
||||
{
|
||||
{ /* -- unused in Swarmops
|
||||
|
||||
Person person = Person.FromIdentity(personId);
|
||||
int newHandleAccountId = 0;
|
||||
|
||||
@@ -65,8 +68,13 @@ namespace Swarmops.Logic.Special.Sweden
|
||||
{
|
||||
SwedishForumDatabase.GetDatabase().SetPartyMember(newHandleAccountId);
|
||||
}
|
||||
}
|
||||
}
|
||||
} -- */
|
||||
|
||||
// suppress warnings with trace messages
|
||||
|
||||
Trace.WriteLine(personId);
|
||||
Trace.WriteLine(newHandle);
|
||||
}
|
||||
|
||||
public HandleErrorType CanSetHandle (string newHandle)
|
||||
{
|
||||
|
||||
@@ -132,20 +132,6 @@ namespace Swarmops.Logic.Structure
|
||||
}
|
||||
|
||||
|
||||
public Organizations GetMasterOrganizations ()
|
||||
{
|
||||
if (Identity == Organization.UPSEid || Inherits(Organization.UPSEid))
|
||||
{
|
||||
// HACK: Hardcoded
|
||||
|
||||
return Organizations.FromSingle(FromIdentity(Organization.PPSEid));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Organizations();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEconomyEnabled
|
||||
{
|
||||
get { return OptionalData.GetOptionalDataBool(ObjectOptionalDataType.OrgEconomyEnabled); }
|
||||
@@ -669,10 +655,6 @@ namespace Swarmops.Logic.Structure
|
||||
}
|
||||
}
|
||||
|
||||
public static Organization Root
|
||||
{
|
||||
get { return FromIdentity(RootIdentity); }
|
||||
}
|
||||
|
||||
[Obsolete ("This should never be used anymore!", true)]
|
||||
public static Organization PPSE
|
||||
|
||||
@@ -264,12 +264,19 @@ namespace Swarmops.Logic.Structure
|
||||
/// </summary>
|
||||
public static Organizations EconomyEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO
|
||||
|
||||
get
|
||||
{
|
||||
Organizations result = new Organizations();
|
||||
result.Add(Organization.PPSE);
|
||||
Organizations allOrganizations = GetAll();
|
||||
|
||||
foreach (Organization organization in allOrganizations)
|
||||
{
|
||||
if (organization.IsEconomyEnabled)
|
||||
{
|
||||
result.Add(organization);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -935,6 +935,7 @@ namespace Swarmops.Logic.Swarm
|
||||
|
||||
}
|
||||
|
||||
/* --- not used, commented out for usage of hardcoded org ids
|
||||
public int NationalPartyOrg (bool onlyIfMember)
|
||||
{
|
||||
//TODO: Implement a flag in Organization
|
||||
@@ -966,7 +967,7 @@ namespace Swarmops.Logic.Swarm
|
||||
//didn't find any
|
||||
return 0;
|
||||
|
||||
}
|
||||
} */
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
public string TShirtSize
|
||||
@@ -988,9 +989,9 @@ namespace Swarmops.Logic.Swarm
|
||||
set { OptionalData.SetOptionalDataString(ObjectOptionalDataType.BlogUrl, value); }
|
||||
}
|
||||
|
||||
public DashboardTasks.Tasks Tasks
|
||||
public DashboardTasks.Tasks GetTasksForOrganization(Organization organization)
|
||||
{
|
||||
get { return Logic.DashboardTasks.Tasks.ForPerson(this); }
|
||||
return Logic.DashboardTasks.Tasks.ForPersonOrganization(this, organization);
|
||||
}
|
||||
|
||||
public string Formal
|
||||
|
||||
Reference in New Issue
Block a user