VAT report work

This commit is contained in:
Rick Falkvinge
2017-10-10 09:11:12 +02:00
parent 9cf57ba3bf
commit abda957c77
11 changed files with 231 additions and 41 deletions
+7 -2
View File
@@ -13,7 +13,7 @@ namespace Swarmops.Basic.Types.Financial
public BasicVatReport(int vatReportId, int organizationId, string guid, DateTime createdDateTime,
int yearMonthStart, int monthCount, bool open, Int64 turnoverCents, Int64 vatInboundCents,
Int64 vatOutboundCents, bool underConstruction)
Int64 vatOutboundCents, int openTransactionId, int closeTransactionId, bool underConstruction)
{
this.VatReportId = vatReportId;
this.OrganizationId = organizationId;
@@ -25,6 +25,8 @@ namespace Swarmops.Basic.Types.Financial
this.TurnoverCents = turnoverCents;
this.VatInboundCents = vatInboundCents;
this.VatOutboundCents = vatOutboundCents;
this.OpenTransactionId = openTransactionId;
this.CloseTransactionId = closeTransactionId;
this.UnderConstruction = underConstruction;
}
@@ -33,7 +35,8 @@ namespace Swarmops.Basic.Types.Financial
public BasicVatReport(BasicVatReport original)
: this(original.Identity, original.OrganizationId, original.Guid, original.CreatedDateTime,
original.YearMonthStart, original.MonthCount, original.Open, original.TurnoverCents,
original.VatInboundCents, original.VatOutboundCents, original.UnderConstruction)
original.VatInboundCents, original.VatOutboundCents, original.OpenTransactionId,
original.CloseTransactionId, original.UnderConstruction)
{
// empty copy ctor
}
@@ -50,6 +53,8 @@ namespace Swarmops.Basic.Types.Financial
public Int64 VatInboundCents { get; protected set; }
public Int64 VatOutboundCents { get; protected set; }
public bool Open { get; protected set; }
public int OpenTransactionId { get; protected set; }
public int CloseTransactionId { get; protected set; }
public bool UnderConstruction { get; protected set; }
// Interfaces
+1 -1
View File
@@ -14,7 +14,7 @@ namespace Swarmops.Database
/// </summary>
public static int DbVersionExpected
{
get { return 49; }
get { return 50; }
}
+49 -3
View File
@@ -7,6 +7,7 @@ using System.Globalization;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Financial;
using Swarmops.Common.Enums;
using Swarmops.Common.Exceptions;
namespace Swarmops.Database
{
@@ -17,7 +18,7 @@ namespace Swarmops.Database
private const string vatReportFieldSequence =
" VatReportId,OrganizationId,Guid,CreatedDateTime,YearMonthStart," + // 0-4
"MonthCount,VatReports.Open,TurnoverCents,VatInboundCents,VatOutboundCents," + // 5-9
"UnderConstruction " + // 10
"OpenTransactionId,CloseTransactionId,UnderConstruction " + // 10-12
"FROM VatReports ";
private const string vatReportItemFieldSequence =
@@ -38,10 +39,12 @@ namespace Swarmops.Database
Int64 turnoverCents = reader.GetInt64(7);
Int64 vatInboundCents = reader.GetInt64(8);
Int64 vatOutboundCents = reader.GetInt64(9);
bool underConstruction = reader.GetBoolean (10);
int openTransactionId = reader.GetInt32(10);
int closeTransactionid = reader.GetInt32(11);
bool underConstruction = reader.GetBoolean (12);
return new BasicVatReport(vatReportId, organizationId, guid, createdDateTime, yearMonthStart, monthCount,
open, turnoverCents, vatInboundCents, vatOutboundCents, underConstruction);
open, turnoverCents, vatInboundCents, vatOutboundCents, openTransactionId, closeTransactionid, underConstruction);
}
@@ -289,6 +292,49 @@ namespace Swarmops.Database
}
public void SetVatReportOpenTransaction(int vatReportId, int financialTransactionId)
{
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
DbCommand command = GetDbCommand("SetVatReportOpenTransaction", connection);
command.CommandType = CommandType.StoredProcedure;
AddParameterWithName(command, "vatReportId", vatReportId);
AddParameterWithName(command, "openTransactionId", financialTransactionId);
if (Convert.ToInt32(command.ExecuteScalar()) != 1) // returns count of rows updated
{
throw new DatabaseConcurrencyException();
}
}
}
public void SetVatReportCloseTransaction(int vatReportId, int financialTransactionId)
{
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
DbCommand command = GetDbCommand("SetVatReportCloseTransaction", connection);
command.CommandType = CommandType.StoredProcedure;
AddParameterWithName(command, "vatReportId", vatReportId);
AddParameterWithName(command, "closeTransactionId", financialTransactionId);
if (Convert.ToInt32(command.ExecuteScalar()) != 1) // returns count of rows updated
{
throw new DatabaseConcurrencyException();
}
}
}
#endregion
}
}
+1
View File
@@ -47,3 +47,4 @@
0047 - Fix for null case in SetVatReportReleased [RF]
0048 - Fix for CreateVatReportItem, ForeignObjectId=>ForeignId [RF]
0049 - Another fix for CreateVatReportItem
0050 - Added VatReports.OpenTransaction, .CloseTransaction
+46
View File
@@ -0,0 +1,46 @@
ALTER TABLE `VatReports`
ADD COLUMN `OpenTransactionId` INT NOT NULL DEFAULT 0 AFTER `Open`,
ADD COLUMN `CloseTransactionId` INT NOT NULL DEFAULT 0 AFTER `OpenTransactionId`,
ADD INDEX `Ix_OpenTx` (`OpenTransactionId` ASC),
ADD INDEX `Ix_CloseTx` (`CloseTransactionId` ASC);
#
DROP PROCEDURE IF EXISTS `SetVatReportOpenTransaction`
#
DROP PROCEDURE IF EXISTS `SetVatReportCloseTransaction`
#
CREATE PROCEDURE `SetVatReportOpenTransaction`(
IN vatReportId INTEGER,
IN openTransactionId INTEGER
)
BEGIN
UPDATE VatReports SET OpenTransactionId=openTransactionId
WHERE VatReports.VatReportId=vatReportId;
SELECT ROW_COUNT() AS RecordsUpdated;
END
#
CREATE PROCEDURE `SetVatReportCloseTransaction`(
IN vatReportId INTEGER,
IN closeTransactionId INTEGER
)
BEGIN
UPDATE VatReports SET CloseTransactionId=closeTransactionId
WHERE VatReports.VatReportId=vatReportId
AND VatReports.CloseTransactionId=0;
SELECT ROW_COUNT() AS RecordsUpdated;
END
+32
View File
@@ -240,6 +240,38 @@ namespace Swarmops.Logic.Financial
}
}
}
public new int OpenTransactionId
{
get { return base.OpenTransactionId; }
set
{
SwarmDb.GetDatabaseForWriting().SetVatReportOpenTransaction(this.Identity, value);
base.OpenTransactionId = value;
}
}
public FinancialTransaction OpenTransaction
{
get { return FinancialTransaction.FromIdentity(OpenTransactionId); }
set { this.OpenTransactionId = value.Identity; }
}
public new int CloseTransactionId
{
get { return base.CloseTransactionId; }
set
{
SwarmDb.GetDatabaseForWriting().SetVatReportCloseTransaction(this.Identity, value);
base.CloseTransactionId = value;
}
}
public FinancialTransaction CloseTransaction
{
get { return FinancialTransaction.FromIdentity(CloseTransactionId); }
set { this.CloseTransactionId = value.Identity; }
}
}
}
+27
View File
@@ -618,6 +618,15 @@ namespace Resources.Pages {
}
}
/// <summary>
/// Looks up a localized string similar to Close VAT report.
/// </summary>
internal static string BalanceTransactions_ModalDialog_ButtonVatReport {
get {
return ResourceManager.GetString("BalanceTransactions_ModalDialog_ButtonVatReport", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Balance the difference against this account:.
/// </summary>
@@ -654,6 +663,15 @@ namespace Resources.Pages {
}
}
/// <summary>
/// Looks up a localized string similar to This transaction is payment/return for this VAT report:.
/// </summary>
internal static string BalanceTransactions_ModalDialog_DescribeVatReport {
get {
return ResourceManager.GetString("BalanceTransactions_ModalDialog_DescribeVatReport", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Transaction is unbalanced by &lt;span id=&quot;spanTransactionUnbalancedBy&quot;&gt;+FOO,BAR.QX&lt;/span&gt;. Do you wish to....
/// </summary>
@@ -708,6 +726,15 @@ namespace Resources.Pages {
}
}
/// <summary>
/// Looks up a localized string similar to Close a VAT report with this transaction?.
/// </summary>
internal static string BalanceTransactions_ModalDialog_RadioVatReport {
get {
return ResourceManager.GetString("BalanceTransactions_ModalDialog_RadioVatReport", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Balancing/Matching Transaction #&lt;span id=&quot;spanModalTransactionId&quot;&gt;67890&lt;/span&gt; From &lt;span id=&quot;spanModalTransactionDate&quot;&gt;yyyy-mmm-dd&lt;/span&gt;.
/// </summary>
@@ -862,4 +862,13 @@
<data name="BalanceTransactions_ModalDialog_ButtonPayoutForeign" xml:space="preserve">
<value>Match</value>
</data>
<data name="BalanceTransactions_ModalDialog_ButtonVatReport" xml:space="preserve">
<value>Close VAT report</value>
</data>
<data name="BalanceTransactions_ModalDialog_DescribeVatReport" xml:space="preserve">
<value>This transaction is payment/return for this VAT report:</value>
</data>
<data name="BalanceTransactions_ModalDialog_RadioVatReport" xml:space="preserve">
<value>Close a VAT report with this transaction?</value>
</data>
</root>
+21 -18
View File
@@ -30,6 +30,8 @@
$('#buttonExecutePayout').val(buttonPayoutValue);
$('#buttonExecutePayoutForeign').val(buttonPayoutForeignValue);
$('#buttonExecuteOutboundInvoice').val(buttonOutboundInvoiceValue);
$('#buttonExecuteVatReport').val(buttonVatReportValue);
});
var transactionId = 0;
@@ -195,6 +197,7 @@
var buttonPayoutValue = SwarmopsJS.unescape('<%=this.Localized_ButtonPayout%>');
var buttonPayoutForeignValue = SwarmopsJS.unescape('<%=this.Localized_ButtonPayoutForeign%>');
var buttonOutboundInvoiceValue = SwarmopsJS.unescape('<%=this.Localized_ButtonOutboundInvoice%>');
var buttonVatReportValue = SwarmopsJS.unescape('<%=this.Localized_ButtonVatReport%>');
</script>
@@ -246,15 +249,17 @@
<h2><asp:Literal runat="server" ID="LiteralModalHeader" Text="Matching/Balancing transaction #foobar XYZ" /></h2>
<p><asp:Literal ID="LabelDoYouWishTo" runat="server" Text="The balance is off by SEK +6,141.14. is Do you wish to... XYZ" /></p>
<p><input type="radio" id="RadioBalance" name="TxOptions" value="Balance" /><label for="RadioBalance">&nbsp;<asp:Label runat="server" ID="LabelRadioBalance" Text="Balance the transaction manually? XYZ" /></label></p>
<div id="radioOptionBalance" class="radioOption">
<div class="entryFields">
<Swarmops5:ComboBudgets ID="DropBudgetBalance" runat="server" ListType="All" />&#8203;<br/>
<input type="button" value='#Balance#' class="buttonAccentColor" onclick="onBalanceTransaction(); return false;" id="buttonExecuteBalance"/>
<div id="divVatReport">
<p><input type="radio" id="RadioVatReport" name="TxOptions" value="VatReport" /><label for="RadioVatReport">&nbsp;<asp:Label runat="server" ID="LabelRadioVatReport" Text="Match to an open VAT report? XYZ" /></label></p>
<div id="radioOptionVatReport" class="radioOption">
<div class="entryFields">
<Swarmops5:DropDown ID="DropOpenVatReports" runat="server" />&#8203;<br/>
<input type="button" value='#VatReport#' class="buttonAccentColor" onclick="onMatchOpenVatReport(); return false;" id="buttonExecuteVatReport"/>
</div>
<div class="entryLabels">
<asp:Label runat="server" ID="LabelDescribeVatReport" Text="Match to open VAT report XYZ" />
</div>
</div>
<div class="entryLabels">
<asp:Label runat="server" ID="LabelDescribeBalance" Text="Balance the difference against XYZ" />
</div>
<div style="clear:both"></div>
</div>
<div id="divNegativeDifference">
<p><input type="radio" id="RadioPayout" name="TxOptions" value="Payout" /><label for="RadioPayout">&nbsp;<asp:Label runat="server" ID="LabelRadioPayout" Text="Match this balance to an open payout? XYZ" /></label></p>
@@ -290,17 +295,15 @@
</div>
</div>
</div>
<div id="divVatReport">
<p><input type="radio" id="RadioVatReport" name="TxOptions" value="VatReport" /><label for="RadioVatReport">&nbsp;<asp:Label runat="server" ID="LabelRadioVatReport" Text="Match to an open VAT report? XYZ" /></label></p>
<div id="radioOptionVatReport" class="radioOption">
<div class="entryFields">
<Swarmops5:DropDown ID="DropOpenVatReports" runat="server" />&#8203;<br/>
<input type="button" value='#VatReport#' class="buttonAccentColor" onclick="onMatchOpenVatReports(); return false;" id="buttonExecuteVatReport"/>
</div>
<div class="entryLabels">
<asp:Label runat="server" ID="LabelDescrribeVatReport" Text="Match to open VAT report XYZ" />
</div>
<div id="radioOptionBalance" class="radioOption"> <!-- this should go last -->
<div class="entryFields">
<Swarmops5:ComboBudgets ID="DropBudgetBalance" runat="server" ListType="All" />&#8203;<br/>
<input type="button" value='#Balance#' class="buttonAccentColor" onclick="onBalanceTransaction(); return false;" id="buttonExecuteBalance"/>
</div>
<div class="entryLabels">
<asp:Label runat="server" ID="LabelDescribeBalance" Text="Balance the difference against XYZ" />
</div>
<div style="clear:both"></div>
</div>
<div id="radioOptionPayment2" class="radioOption"></div>
<div id="radioOptionPaymentForeign" class="radioOption"></div>
@@ -46,11 +46,15 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
this.LabelDescribePayoutForeign.Text = Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_DescribePayoutForeign;
this.LabelDescribeOutboundInvoice.Text =
Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_DescribeOutboundInvoice;
this.LabelDescribeVatReport.Text = Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_DescribeVatReport;
this.LabelRadioPayout.Text = Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_RadioPayout;
this.LabelRadioPayoutForeign.Text =
String.Format(Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_RadioPayoutForeign, 5);
this.LabelRadioOutboundInvoice.Text =
Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_RadioOutboundInvoice;
this.LabelRadioVatReport.Text =
Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_RadioVatReport;
}
@@ -451,9 +455,18 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
}
[WebMethod]
public static void MatchTransactionOpenVatReport(int transactionId, int vatReportId)
{
}
[WebMethod]
public static string GetTransactionDisplayIdentity(int transactionId)
{
GetAuthenticationDataAndCulture(); // Sets culture
FinancialTransaction tx = FinancialTransaction.FromIdentity(transactionId);
return tx.OrganizationSequenceId.ToString("N0");
}
@@ -496,5 +509,13 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_ButtonOutboundInvoice);
}
}
public string Localized_ButtonVatReport
{
get
{
return CommonV5.JavascriptEscape(Resources.Pages.Ledgers.BalanceTransactions_ModalDialog_ButtonVatReport);
}
}
}
}
+17 -17
View File
@@ -112,22 +112,31 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers {
protected global::System.Web.UI.WebControls.Label LabelRadioBalance;
/// <summary>
/// DropBudgetBalance control.
/// LabelRadioVatReport control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::Swarmops.Controls.Financial.ComboBudgets DropBudgetBalance;
protected global::System.Web.UI.WebControls.Label LabelRadioVatReport;
/// <summary>
/// LabelDescribeBalance control.
/// DropOpenVatReports control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelDescribeBalance;
protected global::Swarmops.Frontend.Controls.Base.DropDown DropOpenVatReports;
/// <summary>
/// LabelDescribeVatReport control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelDescribeVatReport;
/// <summary>
/// LabelRadioPayout control.
@@ -211,31 +220,22 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers {
protected global::System.Web.UI.WebControls.Label LabelDescribeOutboundInvoice;
/// <summary>
/// LabelRadioVatReport control.
/// DropBudgetBalance control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelRadioVatReport;
protected global::Swarmops.Controls.Financial.ComboBudgets DropBudgetBalance;
/// <summary>
/// DropOpenVatReports control.
/// LabelDescribeBalance control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::Swarmops.Frontend.Controls.Base.DropDown DropOpenVatReports;
/// <summary>
/// LabelDescrribeVatReport control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelDescrribeVatReport;
protected global::System.Web.UI.WebControls.Label LabelDescribeBalance;
/// <summary>
/// LabelRadioExistingPayment control.