Unsorted work, picking up work again

This commit is contained in:
Rick Falkvinge
2016-01-03 20:29:37 +01:00
parent 787e0a48e6
commit d0c2aa5c90
17 changed files with 356 additions and 65 deletions
-1
View File
@@ -465,7 +465,6 @@ namespace Swarmops.Backend
private static void OnEveryHour()
{
DateTime startTime = DateTime.Now;
try
{
BotLog.Write (0, "MainCycle", "One-hour entry");
+16 -5
View File
@@ -8,7 +8,8 @@ namespace Swarmops.Common.Enums
Organization,
OutboundInvoice,
InboundInvoice,
FinancialTransaction
FinancialTransaction,
FinancialTransactionRow
}
public enum ObjectOptionalDataType
@@ -335,21 +336,31 @@ namespace Swarmops.Common.Enums
/// <summary>
/// If there's a hotwallet, its private root key (encrypted with file and db keys)
/// </summary>
BudgetBitcoinPrivateRoot,
FinancialAccountBitcoinPrivateRoot,
/// <summary>
/// If there's another wallet, its public root key (encrypted with db key)
/// </summary>
BudgetBitcoinPublicRoot,
FinancialAccountBitcoinPublicRoot,
/// <summary>
/// For cold wallets, we may prefer listing the public addresses directly
/// </summary>
BudgetBitcoinPublicAddress,
FinancialAccountBitcoinPublicAddress,
/// <summary>
/// For a bitcoin transaction, its hash on the blockchain
/// </summary>
FinancialTransactionBlockchainHash
FinancialTransactionBlockchainHash,
/// <summary>
/// For a financial account, the native currency (typically bitcoin). Used for multi-currency accounting.
/// </summary>
FinancialAccountNativeCurrency,
/// <summary>
/// For a hotwallet transaction, the complete derivation path used for this address
/// </summary>
FinancialTransactionRowBitcoinDerivationPath
}
}
+1 -1
View File
@@ -14,7 +14,7 @@ namespace Swarmops.Database
/// </summary>
public static int DbVersionExpected
{
get { return 32; }
get { return 33; }
}
+62 -33
View File
@@ -949,27 +949,8 @@ namespace Swarmops.Database
}
}
public void CreateFinancialTransactionRow (int financialTransactionId, int financialAccountId, double amount,
int personId)
{
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
DbCommand command = GetDbCommand ("CreateFinancialTransactionRow", connection);
command.CommandType = CommandType.StoredProcedure;
AddParameterWithName (command, "financialTransactionId", financialTransactionId);
AddParameterWithName (command, "financialAccountId", financialAccountId);
AddParameterWithName (command, "amount", amount);
AddParameterWithName (command, "dateTime", DateTime.Now);
AddParameterWithName (command, "personId", personId);
command.ExecuteNonQuery();
}
}
public void CreateFinancialTransactionRow (int financialTransactionId, int financialAccountId, Int64 amountCents,
public int CreateFinancialTransactionRow (int financialTransactionId, int financialAccountId, Int64 amountCents,
int personId)
{
using (DbConnection connection = GetMySqlDbConnection())
@@ -985,7 +966,7 @@ namespace Swarmops.Database
AddParameterWithName (command, "dateTime", DateTime.Now);
AddParameterWithName (command, "personId", personId);
command.ExecuteNonQuery();
return Convert.ToInt32(command.ExecuteScalar());
}
}
@@ -1048,35 +1029,37 @@ namespace Swarmops.Database
{
connection.Open();
DbCommand command = GetDbCommand("SetFinancialTransactionForeignId", connection);
command.CommandType = CommandType.StoredProcedure;
using (DbCommand command = GetDbCommand ("SetFinancialTransactionForeignId", connection))
{
command.CommandType = CommandType.StoredProcedure;
AddParameterWithName(command, "financialTransactionId", financialTransactionId);
AddParameterWithName(command, "financialTransactionForeignIdType", (int) foreignIdType);
AddParameterWithName(command, "foreignId", foreignId);
AddParameterWithName (command, "financialTransactionId", financialTransactionId);
AddParameterWithName (command, "financialTransactionForeignIdType", (int) foreignIdType);
AddParameterWithName (command, "foreignId", foreignId);
command.ExecuteNonQuery();
command.ExecuteNonQuery();
}
}
}
public Int64 GetFinancialTransactionFromForeignId(FinancialForeignIdType foreignIdType, string foreignId)
public int GetFinancialTransactionFromForeignId(FinancialForeignIdType foreignIdType, string foreignId)
{
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
DbCommand command =
using (DbCommand command =
GetDbCommand(
"Select FinancialTransactionId from FinancialTransactionForeignIds WHERE FinancialTransactionForeignIdType=" + (int) foreignIdType +
" AND ForeignId='" + SqlSanitize (foreignId) + "';", connection);
"Select FinancialTransactionId from FinancialTransactionForeignIds WHERE FinancialTransactionForeignIdType=" + (int)foreignIdType +
" AND ForeignId='" + SqlSanitize(foreignId) + "';", connection))
using (DbDataReader reader = command.ExecuteReader())
{
if (reader.Read())
{
return reader.GetInt32 (0);
return reader.GetInt32(0);
}
return 0; // none found. Todo: throw exception instead? This behavior is inconsistent
@@ -1086,7 +1069,53 @@ namespace Swarmops.Database
public DateTime GetFinancialAccountFirstTransactionDate (int financialAccountId)
public Int64 GetFinancialTransactionRowNativeAmountCents(int financialTransactionRowId, int currencyId)
{
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
using (DbCommand command =
GetDbCommand(
"Select NativeAmountCents from FinancialTransactionRows WHERE FinancialTransactionRowId=" + financialTransactionRowId +
" AND CurrencyId =" + currencyId + ";", connection))
using (DbDataReader reader = command.ExecuteReader())
{
if (reader.Read())
{
return reader.GetInt64(0);
}
return 0; // none found. Todo: throw exception instead? This behavior is inconsistent
}
}
}
public void SetFinancialTransactionRowNativeAmountCents(int financialTransactionRowId, int currencyId, Int64 nativeAmountCents)
{
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
using (DbCommand command = GetDbCommand("SetFinancialTransactionRowNativeCurrency", connection))
{
command.CommandType = CommandType.StoredProcedure;
AddParameterWithName(command, "financialTransactionRowId", financialTransactionRowId);
AddParameterWithName(command, "currencyId", currencyId);
AddParameterWithName(command, "nativeAmountCents", nativeAmountCents);
command.ExecuteNonQuery();
}
}
}
public DateTime GetFinancialAccountFirstTransactionDate(int financialAccountId)
{
using (DbConnection connection = GetMySqlDbConnection())
{
+2 -1
View File
@@ -29,4 +29,5 @@
0029 - Added unspent satoshis to hotaddress on create unspent [RF]
0030 - Added flexibility for Resolver classes for OutboundComms [RF]
0031 - Added foreign ID tables, procs for transactions, to track blockchain [RF]
0032 - Added native currency to transaction rows, for multi-currency accounting [RF]
0032 - Added native currency to transaction rows, for multi-currency accounting [RF]
0033 - Added transaction row identity return, necessary for 0032 [RF]
+21
View File
@@ -0,0 +1,21 @@
DROP procedure IF EXISTS `CreateFinancialTransactionRowPrecise`
#
CREATE PROCEDURE `CreateFinancialTransactionRowPrecise`(
IN financialTransactionId INTEGER,
IN financialAccountId INTEGER,
IN amountCents BIGINT,
IN dateTime DATETIME,
IN personId INTEGER
)
BEGIN
INSERT INTO FinancialTransactionRows (FinancialAccountId, FinancialTransactionId, Amount, AmountCents, CreatedDateTime, CreatedByPersonId)
VALUES (financialAccountId, financialTransactionid, amountCents/100.0, amountCents, dateTime, personId);
SELECT LAST_INSERT_ID() AS Identity;
END
@@ -86,8 +86,11 @@ namespace Swarmops.Logic.Communications.Payload
{
// TODO: Check if string ends in Float, and if so, parse and culturize it
input = input.Replace ("[" + notificationString /* this is an enum converted to string */+ "]",
Strings[notificationString]);
if (!String.IsNullOrEmpty (Strings[notificationString]))
{
input = input.Replace ("[" + notificationString /* this is an enum converted to string */+ "]",
Strings[notificationString]);
}
}
}
@@ -95,10 +98,13 @@ namespace Swarmops.Logic.Communications.Payload
{
foreach (string notificationCustomString in CustomStrings.Keys)
{
input =
input.Replace (
"[" + notificationCustomString /* this is a System.String as opposed to above */+ "]",
CustomStrings[notificationCustomString]);
if (!String.IsNullOrEmpty (CustomStrings[notificationCustomString]))
{
input =
input.Replace (
"[" + notificationCustomString /* this is a System.String as opposed to above */+ "]",
CustomStrings[notificationCustomString]);
}
}
}
@@ -174,7 +180,10 @@ namespace Swarmops.Logic.Communications.Payload
BitcoinPayoutAddress_Bad,
BitcoinPayoutAddress_PleaseSet,
BitcoinPayoutAddress_OfficerNotify,
BitcoinPayoutAddress_Changed
BitcoinPayoutAddress_Changed,
Salary_MonthlyStatement,
Salary_Paid,
Salary_LastYearSummary
}
// ReSharper restore InconsistentNaming
+13 -2
View File
@@ -194,8 +194,6 @@ namespace Swarmops.Logic.Financial
}
}
// https://blockchain.info/address/1Axd4QQhRSCMAuHe93uVKRjNSFj6WypcZa?format=json&api_key=I_am_testing_the_format_please_ignore
static private void CheckColdStorageRecurse (FinancialAccount parent)
{
foreach (FinancialAccount child in parent.Children)
@@ -216,6 +214,8 @@ namespace Swarmops.Logic.Financial
catch (Exception e)
{
// the name wasn't an address, so return
return;
}
var addressData =
@@ -225,6 +225,17 @@ namespace Swarmops.Logic.Financial
// TODO: PARSE (awaiting functions for native currency to be added to FinancialTransactionRows)
int transactionCount = (int)(addressData["n_tx"]);
foreach (var tx in addressData["txs"])
{
string blockchainTransactionId = (string) tx["hash"];
FinancialTransaction ourTx = FinancialTransaction.FromBlockchainHash (parent.Organization, blockchainTransactionId);
}
// TODO: CONTINUE HERE
}
+15
View File
@@ -114,6 +114,21 @@ namespace Swarmops.Logic.Financial
}
}
public Currency NativeCurrency
{
get
{
int currencyId = OptionalData.GetOptionalDataInt (ObjectOptionalDataType.FinancialAccountNativeCurrency);
return (currencyId != 0 ? Currency.FromIdentity (currencyId) : null);
}
set
{
OptionalData.SetOptionalDataInt (ObjectOptionalDataType.FinancialAccountNativeCurrency, value.Identity);
}
}
public ExternalBankDataProfile ExternalBankDataProfile
{
get
+32 -8
View File
@@ -159,6 +159,28 @@ namespace Swarmops.Logic.Financial
}
}
public static FinancialTransaction FromBlockchainHash (Organization organization, string blockchainTransactionHash)
{
int[] transactionIds =
SwarmDb.GetDatabaseForReading()
.GetObjectsByOptionalData (ObjectType.FinancialTransaction,
ObjectOptionalDataType.FinancialTransactionBlockchainHash, blockchainTransactionHash);
// There may be multiple transactions in this Swarmops installation referring to this transaction on the blockchain, but only
// one per organization. So find the transaction that matches the org we want.
foreach (int transactionId in transactionIds)
{
FinancialTransaction potentialResult = FinancialTransaction.FromIdentity (transactionId);
if (potentialResult.OrganizationId == organization.Identity)
{
return potentialResult;
}
}
throw new ArgumentException("No match for supplied blockchain tx hash and organization");
}
public IHasIdentity Dependency
{
set
@@ -229,18 +251,20 @@ namespace Swarmops.Logic.Financial
AddRow (account, (Int64) (amount*100), person);
}
public void AddRow (FinancialAccount account, Int64 amountCents, Person person)
public FinancialTransactionRow AddRow (FinancialAccount account, Int64 amountCents, Person person)
{
AddRow (account.Identity, amountCents, person != null ? person.Identity : 0);
return AddRow (account.Identity, amountCents, person != null ? person.Identity : 0);
}
private void AddRow (int financialAccountId, Int64 amountCents, int personId)
private FinancialTransactionRow AddRow (int financialAccountId, Int64 amountCents, int personId)
{
if (DateTime.Year <=
FinancialAccount.FromIdentity (financialAccountId).Organization.Parameters.FiscalBooksClosedUntilYear)
{
// Recurse down into continuation transactions to write row in first nonclosed year
FinancialTransactionRow newRow = null;
FinancialTransaction transactionContinued = ContinuedTransaction;
if (transactionContinued == null)
@@ -249,21 +273,21 @@ namespace Swarmops.Logic.Financial
transactionContinued = Create (OrganizationId, DateTime.Now,
"Continued Tx #" + Identity);
transactionContinued.AddRow (financialAccountId, amountCents, personId);
newRow = transactionContinued.AddRow (financialAccountId, amountCents, personId);
transactionContinued.Dependency = this;
}
else
{
// Recurse
transactionContinued.AddRow (financialAccountId, amountCents, personId);
newRow = transactionContinued.AddRow (financialAccountId, amountCents, personId);
}
return;
return newRow;
}
SwarmDb.GetDatabaseForWriting()
.CreateFinancialTransactionRow (Identity, financialAccountId, amountCents, personId);
return FinancialTransactionRow.FromIdentityAggressive (SwarmDb.GetDatabaseForWriting()
.CreateFinancialTransactionRow (Identity, financialAccountId, amountCents, personId));
}
public void AddDocument (string serverFileName, string originalFileName, Int64 fileSize, string description,
+22 -2
View File
@@ -59,6 +59,21 @@ namespace Swarmops.Logic.Financial
}
}
public Money NativeAmountCents
{
get
{
Currency currency = this.Account.NativeCurrency;
int currencyId = currency.Identity;
Int64 nativeCents = SwarmDb.GetDatabaseForReading().GetFinancialTransactionRowNativeAmountCents (this.Identity, currencyId);
return new Money(nativeCents, currency, this.CreatedDateTime); // includes the valuation datetime, as it's a non-org currency
}
set
{
SwarmDb.GetDatabaseForWriting().SetFinancialTransactionRowNativeAmountCents (this.Identity, value.Currency.Identity, value.Cents);
}
}
[Obsolete ("Do not use. Use Int64 AmountCents.", true)]
public decimal Amount
{
@@ -70,9 +85,14 @@ namespace Swarmops.Logic.Financial
return new FinancialTransactionRow (basic);
}
public static FinancialTransactionRow FromIdentity (int identity)
public static FinancialTransactionRow FromIdentity(int identity)
{
return FromBasic (SwarmDb.GetDatabaseForReading().GetFinancialTransactionRow (identity));
return FromBasic(SwarmDb.GetDatabaseForReading().GetFinancialTransactionRow(identity));
}
public static FinancialTransactionRow FromIdentityAggressive(int identity)
{
return FromBasic(SwarmDb.GetDatabaseForWriting().GetFinancialTransactionRow(identity)); // "For writing" is intentional
}
}
}
+4
View File
@@ -92,6 +92,10 @@ namespace Swarmops.Logic.Financial
// TODO: CREATE SALARY SPECIFICATION, SEND TO PERSON
}
// If this is January, also send the annual statements for last year
Salaries.CreateAnnualStatements (today.Year-1);
}
}
}
+95
View File
@@ -1,10 +1,15 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Financial;
using Swarmops.Database;
using Swarmops.Logic.Communications;
using Swarmops.Logic.Communications.Payload;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
using Swarmops.Logic.Swarm;
namespace Swarmops.Logic.Financial
{
@@ -64,5 +69,95 @@ namespace Swarmops.Logic.Financial
return FromArray (SwarmDb.GetDatabaseForReading().GetSalaries (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.
// Get all organizations.
Organizations organizations = Organizations.GetAll();
foreach (Organization organization in organizations)
{
// Get all salaries for this organization (filter year in logic - this function is allowed to be expensive, rather than
// adding a custom database query for this particular operation)
Salaries allSalaries = ForOrganization (organization, true);
Salaries yearSalaries = new Salaries();
yearSalaries.AddRange (allSalaries.Where (salary => salary.PayoutDate.Year == year));
Dictionary<int, Dictionary<int, Salary>> personSalaryLookup = new Dictionary<int, Dictionary<int, Salary>>();
// Go through the salaries and store them in the dictionary, so we can process the statement by person later
foreach (Salary salary in yearSalaries)
{
int personId = salary.PayrollItem.PersonId;
if (!personSalaryLookup.ContainsKey (personId))
{
personSalaryLookup[personId] = new Dictionary<int, Salary>();
}
personSalaryLookup[personId][salary.PayoutDate.Month] = salary;
}
// Once here, salaries are arranged by person and month. Iterate over people, create statements.
foreach (int personId in personSalaryLookup.Keys)
{
Person person = Person.FromIdentity (personId);
Int64 grossTotal = 0;
Int64 subTaxTotal = 0;
Int64 addTaxTotal = 0;
Int64 netTotal = 0;
string preFormattedStatement = string.Empty;
for (int monthNumber = 1; monthNumber <= 12; monthNumber++)
{
string monthName = new DateTime (year, monthNumber, 1).ToString ("MMM",
new CultureInfo (person.PreferredCulture));
string lineItem = " " + monthName;
if (personSalaryLookup[personId].ContainsKey (monthNumber) && personSalaryLookup[personId][monthNumber].GrossSalaryCents > 0)
{
Salary monthSalary = personSalaryLookup[personId][monthNumber];
// TODO: replace "bitcoin" with actual payout method - this is just for show at the moment
lineItem += String.Format (" {0,8:N2} {1,9:N2} {2,8:N2} bitcoin",
monthSalary.GrossSalaryCents/100.0, -monthSalary.SubtractiveTaxCents/100.0,
monthSalary.NetSalaryCents/100.0);
grossTotal += monthSalary.GrossSalaryCents;
addTaxTotal += monthSalary.AdditiveTaxCents;
subTaxTotal += monthSalary.SubtractiveTaxCents;
netTotal += monthSalary.NetSalaryCents;
}
preFormattedStatement += lineItem + "\r\n";
}
NotificationStrings notificationStrings = new NotificationStrings();
NotificationCustomStrings customStrings = new NotificationCustomStrings();
notificationStrings[NotificationString.CurrencyCode] = organization.Currency.DisplayCode;
notificationStrings[NotificationString.EmbeddedPreformattedText] = preFormattedStatement;
customStrings["LastYear"] = year.ToString(CultureInfo.InvariantCulture);
customStrings["GrossSalaryTotal"] = String.Format("{0:N2,8}", grossTotal / 100.0);
customStrings["TaxDeductedTotal"] = String.Format("{0:N2,9}", -subTaxTotal / 100.0);
customStrings["NetSalaryTotal"] = String.Format("{0:N2,8}", netTotal / 100.0);
customStrings["TaxAdditiveTotalUnpadded"] = String.Format("{0:N2}", addTaxTotal / 100.0);
// Send notification
OutboundComm.CreateNotification (organization, NotificationResource.Salary_LastYearSummary,
notificationStrings, customStrings, People.FromSingle (Person.FromIdentity (1)));
}
}
}
}
}
@@ -685,6 +685,28 @@ namespace Swarmops.Logic.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to This is your summary salary statement for [LastYear]. It is not a statement of a new salary, but a statement of the monthly salaries paid to you over the course of the last year as well as any taxes deducted. The purpose of this statement is to serve as data for your records and/or for tax declaration purposes for last year.
///
///Gross salary for [LastYear]: [CurrencyCode] [GrossSalaryTotal]
///Tax deducted therefrom: [CurrencyCode] [TaxDeductedTotal]
///Net salary paid out: [CurrencyCode] [NetSalaryTotal] [rest of string was truncated]&quot;;.
/// </summary>
internal static string Salary_LastYearSummary_Body {
get {
return ResourceManager.GetString("Salary_LastYearSummary_Body", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to [[OrganizationName]] Salary summary statement for [LastYear].
/// </summary>
internal static string Salary_LastYearSummary_Subject {
get {
return ResourceManager.GetString("Salary_LastYearSummary_Subject", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Swarmops Backend [SwarmopsVersion] on host [HostName] has successfully upgraded the Swarmops database schema to revision [DbVersion].
///
@@ -382,6 +382,27 @@ Please log on to [InstallationName] at [ExternalUrl]Financial/ValidateReceipts t
<value>[[OrganizationName] - ACTION ITEM] Receipts Filed - Validation Needed</value>
<comment>ACTION ITEM should be translated.</comment>
</data>
<data name="Salary_LastYearSummary_Body" xml:space="preserve">
<value>This is your summary salary statement for [LastYear]. It is not a statement of a new salary, but a statement of the monthly salaries paid to you over the course of the last year as well as any taxes deducted. The purpose of this statement is to serve as data for your records and/or for tax declaration purposes for last year.
Gross salary for [LastYear]: [CurrencyCode] [GrossSalaryTotal]
Tax deducted therefrom: [CurrencyCode] [TaxDeductedTotal]
Net salary paid out: [CurrencyCode] [NetSalaryTotal]
Month Gross Deducted Net Paid using
----- ---------- ----------- ---------- -----------
[EmbeddedPreformattedText]
TOTAL [GrossSalaryTotal] [TaxDeductedTotal] [NetSalaryTotal]
In addition, [CurrencyCode] [TaxAdditiveTotalUnpadded] have been paid in taxes by the organization for your employment. This is also a tax on your salary, even if its nature as such has been bureaucratically concealed.</value>
<comment>Note the hard spacing - maintain character count to align columns and elements.</comment>
</data>
<data name="Salary_LastYearSummary_Subject" xml:space="preserve">
<value>[[OrganizationName]] Salary summary statement for [LastYear]</value>
</data>
<data name="System_DatabaseSchemaUpgraded_Body" xml:space="preserve">
<value>Swarmops Backend [SwarmopsVersion] on host [HostName] has successfully upgraded the Swarmops database schema to revision [DbVersion].
+4
View File
@@ -36,6 +36,10 @@ namespace Swarmops
Response.Redirect("/", true);
}
// Test code
// Salaries.CreateAnnualStatements (2015);
// Ugly ugly UGLY legacy: Do not allow Sandbox logins on first pilot - it's broken
if (this._authority.Organization.Identity == 3 &&
+10 -5
View File
@@ -98,6 +98,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
{
HotBitcoinAddressUnspents unspents = HotBitcoinAddress.FromAddress (bitcoinAddress).Unspents;
// TODO: Update the HotBitcoinAddress with the new amount?
Int64 satoshisReceived = unspents.Last().AmountSatoshis;
if (unspents.Last().TransactionHash != txHash && txHash.Length > 0)
@@ -106,9 +108,12 @@ namespace Swarmops.Frontend.Pages.v5.Financial
Debugger.Break();
}
Swarmops.Logic.Financial.Money moneyReceived = new Swarmops.Logic.Financial.Money (satoshisReceived,
Swarmops.Logic.Financial.Money moneyReceived = new Swarmops.Logic.Financial.Money(satoshisReceived,
Currency.Bitcoin);
// Make sure that the hotwallet native currency is bitcoin
authData.CurrentOrganization.FinancialAccounts.AssetsBitcoinHot.NativeCurrency = Currency.Bitcoin;
// Create success message and ledger transaction
string successMessage = string.Empty;
@@ -137,15 +142,15 @@ namespace Swarmops.Frontend.Pages.v5.Financial
{
// The ledger is NOT native bitcoin, so we'll need to convert currencies
long nativeCents = moneyReceived.ToCurrency (authData.CurrentOrganization.Currency).Cents;
long orgNativeCents = moneyReceived.ToCurrency (authData.CurrentOrganization.Currency).Cents;
FinancialTransaction ledgerTx = FinancialTransaction.Create(authData.CurrentOrganization,
DateTime.UtcNow, "Donation (bitcoin to hotwallet)");
ledgerTx.AddRow(authData.CurrentOrganization.FinancialAccounts.IncomeDonations, -nativeCents, authData.CurrentUser);
ledgerTx.AddRow(authData.CurrentOrganization.FinancialAccounts.AssetsBitcoinHot, nativeCents, authData.CurrentUser);
ledgerTx.AddRow(authData.CurrentOrganization.FinancialAccounts.IncomeDonations, -orgNativeCents, authData.CurrentUser);
ledgerTx.AddRow(authData.CurrentOrganization.FinancialAccounts.AssetsBitcoinHot, orgNativeCents, authData.CurrentUser).NativeAmountCents = new Swarmops.Logic.Financial.Money(satoshisReceived, Currency.Bitcoin);
ledgerTx.BlockchainHash = txHash;
successMessage = string.Format (Resources.Pages.Financial.Donate_FundsReceived,
authData.CurrentOrganization.Currency.DisplayCode, nativeCents/100.0, satoshisReceived/100.0);
authData.CurrentOrganization.Currency.DisplayCode, orgNativeCents/100.0, satoshisReceived/100.0);
}
return new AjaxCallResult() {DisplayMessage = successMessage, Success = true};