Work on Payment History
This commit is contained in:
@@ -44,9 +44,19 @@ namespace Swarmops.Logic.Financial
|
||||
// return payout;
|
||||
}
|
||||
|
||||
public static Payout FromDependency(IHasIdentity dependency)
|
||||
public static Payout FromDependency(IHasIdentity dependency, FinancialDependencyType dependencyType = FinancialDependencyType.Unknown)
|
||||
{
|
||||
int payoutId = SwarmDb.GetDatabaseForReading().GetPayoutIdFromDependency(dependency);
|
||||
int payoutId = 0;
|
||||
|
||||
if (dependencyType == FinancialDependencyType.Unknown)
|
||||
{
|
||||
payoutId = SwarmDb.GetDatabaseForReading().GetPayoutIdFromDependency(dependency);
|
||||
}
|
||||
else
|
||||
{
|
||||
payoutId = SwarmDb.GetDatabaseForReading().GetPayoutIdFromDependency(dependency, dependencyType);
|
||||
}
|
||||
|
||||
if (payoutId == 0)
|
||||
{
|
||||
throw new ArgumentException("Supplied item does not have an associated payout");
|
||||
|
||||
@@ -70,6 +70,12 @@ namespace Swarmops.Logic.Financial
|
||||
includeClosed ? DatabaseCondition.None : DatabaseCondition.OpenTrue));
|
||||
}
|
||||
|
||||
public static Salaries ForPersonAndOrganization(Person person, Organization organization, bool includeClosed)
|
||||
{
|
||||
return FromArray(SwarmDb.GetDatabaseForReading().GetSalaries(person, organization,
|
||||
includeClosed ? DatabaseCondition.None : DatabaseCondition.OpenTrue));
|
||||
}
|
||||
|
||||
public static void CreateAnnualStatements (int year)
|
||||
{
|
||||
// This function is supposed to be running once a year, and summarize the past year of salaries.
|
||||
|
||||
@@ -303,7 +303,7 @@ namespace Swarmops.Logic.Financial
|
||||
// Add the financial transaction
|
||||
|
||||
FinancialTransaction transaction =
|
||||
FinancialTransaction.Create (payrollItem.OrganizationId, DateTime.Now,
|
||||
FinancialTransaction.Create (payrollItem.OrganizationId, DateTime.UtcNow,
|
||||
"Salary #" + salary.Identity + ": " + payrollItem.PersonCanonical +
|
||||
" " +
|
||||
salary.PayoutDate.ToString ("yyyy-MMM", CultureInfo.InvariantCulture));
|
||||
|
||||
+2
-2
@@ -592,7 +592,7 @@ namespace Resources.Pages {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Dangling Payments (Must Balance, Match Or Fix).
|
||||
/// Looks up a localized string similar to Dangling Payments (Must Balance, Match, or Fix).
|
||||
/// </summary>
|
||||
internal static string BalanceTransactions_HeaderUnbalancedTransactions {
|
||||
get {
|
||||
@@ -601,7 +601,7 @@ namespace Resources.Pages {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Some auto-imported financial transactions can't be automatically matched to the ongoing accounting. This is where you manually match such transactions to "balance" them (if a transaction only has one part completed, like the money sent to the organization with no record of what the money is for, the transaction is said to be "unbalanced")..
|
||||
/// Looks up a localized string similar to Some auto-imported financial transactions can't be automatically matched to the ongoing accounting. This is where you manually match such transactions to "balance" them (if a transaction only has one part completed, like the money sent to the organization with no record of what the money is for, the transaction is said to be "unbalanced" and a "dangling payment", as in, missing its bookkeeping counterpart)..
|
||||
/// </summary>
|
||||
internal static string BalanceTransactions_Info {
|
||||
get {
|
||||
|
||||
@@ -638,7 +638,7 @@
|
||||
<value>(detailed description withheld)</value>
|
||||
</data>
|
||||
<data name="BalanceTransactions_HeaderUnbalancedTransactions" xml:space="preserve">
|
||||
<value>Dangling Payments (Must Balance, Match Or Fix)</value>
|
||||
<value>Dangling Payments (Must Balance, Match, or Fix)</value>
|
||||
<comment>A "dangling payment" is a transaction that's not yet completed to have equal parts debit and credit. Typically, it's a payment that hasn't been identified.</comment>
|
||||
</data>
|
||||
<data name="BalanceTransactions_GridHeader_AccountName" xml:space="preserve">
|
||||
@@ -656,7 +656,7 @@
|
||||
<comment>Keep VERY short.</comment>
|
||||
</data>
|
||||
<data name="BalanceTransactions_Info" xml:space="preserve">
|
||||
<value>Some auto-imported financial transactions can't be automatically matched to the ongoing accounting. This is where you manually match such transactions to "balance" them (if a transaction only has one part completed, like the money sent to the organization with no record of what the money is for, the transaction is said to be "unbalanced").</value>
|
||||
<value>Some auto-imported financial transactions can't be automatically matched to the ongoing accounting. This is where you manually match such transactions to "balance" them (if a transaction only has one part completed, like the money sent to the organization with no record of what the money is for, the transaction is said to be "unbalanced" and a "dangling payment", as in, missing its bookkeeping counterpart).</value>
|
||||
</data>
|
||||
<data name="BalanceTransactions_ModalHeader" xml:space="preserve">
|
||||
<value>Balancing/Matching Transaction #<span id="spanModalTransactionId">67890</span> From <span id="spanModalTransactionDate">yyyy-mmm-dd</span></value>
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Swarmops.Common;
|
||||
using Swarmops.Common.Enums;
|
||||
using Swarmops.Logic.Financial;
|
||||
using Swarmops.Logic.Swarm;
|
||||
|
||||
@@ -28,6 +29,13 @@ namespace Swarmops.Frontend.Automation
|
||||
}
|
||||
|
||||
this._person = Person.FromIdentity(personId);
|
||||
if (this._person.Identity != _authenticationData.CurrentUser.Identity)
|
||||
{
|
||||
if (!_authenticationData.Authority.CanSeePerson(_person))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
}
|
||||
|
||||
List<PaymentHistoryLineItem> list = new List<PaymentHistoryLineItem>();
|
||||
|
||||
@@ -74,6 +82,36 @@ namespace Swarmops.Frontend.Automation
|
||||
}
|
||||
}
|
||||
|
||||
// Salaries
|
||||
|
||||
Salaries salaries = Salaries.ForPersonAndOrganization(_person, _authenticationData.CurrentOrganization, true);
|
||||
|
||||
foreach (Salary salary in salaries)
|
||||
{
|
||||
if (salary.Open || salary.NetPaid) // either of these must be open for the salary to be valid
|
||||
{
|
||||
PaymentHistoryLineItem newItem = new PaymentHistoryLineItem();
|
||||
newItem.Id = "S" + salary.Identity.ToString(CultureInfo.InvariantCulture);
|
||||
newItem.Name = Resources.Global.Financial_Salary + " #" + salary.Identity.ToString("N0");
|
||||
newItem.Description = "Salary for something XYZ";
|
||||
newItem.OwedToPerson = salary.NetSalaryCents;
|
||||
|
||||
FinancialTransaction openTx = FinancialTransaction.FromDependency(salary);
|
||||
if (openTx != null)
|
||||
{
|
||||
newItem.OpenedDate = openTx.DateTime;
|
||||
}
|
||||
|
||||
Payout payout = Payout.FromDependency(salary, FinancialDependencyType.Salary);
|
||||
if (payout != null && payout.Open == false)
|
||||
{
|
||||
newItem.ClosedDate = payout.FinancialTransaction.DateTime;
|
||||
}
|
||||
|
||||
items.Add(newItem);
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
@@ -385,11 +385,11 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th field="name" width="138"><asp:Literal ID="MasterPersonEditLiteralHeaderItemName" Text="Item Type XYZ" runat="server"/></th>
|
||||
<th field="description" width="220"><asp:Literal ID="MasterPersonEditLiteralHeaderItemDescription" Text="Description XYZ" runat="server"/></th>
|
||||
<th field="opened" width="120"><asp:Literal ID="MasterPersonEditLiteralHeaderItemOpenedDate" Text="Opened date XYZ" runat="server"/></th>
|
||||
<th field="description" width="260"><asp:Literal ID="MasterPersonEditLiteralHeaderItemDescription" Text="Description XYZ" runat="server"/></th>
|
||||
<th field="opened" width="100"><asp:Literal ID="MasterPersonEditLiteralHeaderItemOpenedDate" Text="Opened date XYZ" runat="server"/></th>
|
||||
<th field="owedToPerson" width="120" align="right"><asp:Literal ID="MasterPersonEditLiteralHeaderAmountOwed" Text="Owed to you XYZ" runat="server"/></th>
|
||||
<th field="paidToPerson" width="120" align="right"><asp:Literal ID="MasterPersonEditLiteralHeaderAmountPaid" Text="Paid to you XYZ" runat="server"/></th>
|
||||
<th field="closed" width="120"><asp:Literal ID="MasterPersonEditLiteralHeaderItemClosedDate" Text="Closed date XYZ" runat="server"/></th>
|
||||
<th field="closed" width="100"><asp:Literal ID="MasterPersonEditLiteralHeaderItemClosedDate" Text="Closed date XYZ" runat="server"/></th>
|
||||
<th field="notes" width="80"><asp:Literal ID="MasterPersonEditLiteralHeaderItemNotes" Text="Notes XYZ" runat="server"/></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
Reference in New Issue
Block a user