diff --git a/Basic/Types/Financial/BasicVatReport.cs b/Basic/Types/Financial/BasicVatReport.cs index 82c94d6a..4fb555e5 100644 --- a/Basic/Types/Financial/BasicVatReport.cs +++ b/Basic/Types/Financial/BasicVatReport.cs @@ -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 diff --git a/Database/Configuration.cs b/Database/Configuration.cs index 5dcac3c8..5761b9b9 100644 --- a/Database/Configuration.cs +++ b/Database/Configuration.cs @@ -14,7 +14,7 @@ namespace Swarmops.Database /// public static int DbVersionExpected { - get { return 49; } + get { return 50; } } diff --git a/Database/Database-VatReports.cs b/Database/Database-VatReports.cs index 67a97498..ee25c72f 100644 --- a/Database/Database-VatReports.cs +++ b/Database/Database-VatReports.cs @@ -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 } } diff --git a/Database/Schemata/revisions.txt b/Database/Schemata/revisions.txt index 18186653..34f8ba25 100644 --- a/Database/Schemata/revisions.txt +++ b/Database/Schemata/revisions.txt @@ -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 \ No newline at end of file diff --git a/Database/Schemata/upgrade-0050.sql b/Database/Schemata/upgrade-0050.sql new file mode 100644 index 00000000..c8b38391 --- /dev/null +++ b/Database/Schemata/upgrade-0050.sql @@ -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 diff --git a/Logic/Financial/VatReport.cs b/Logic/Financial/VatReport.cs index f1b186a9..0d441a8f 100644 --- a/Logic/Financial/VatReport.cs +++ b/Logic/Financial/VatReport.cs @@ -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; } + } } } diff --git a/Site/App_GlobalResources/Pages.Ledgers.designer.cs b/Site/App_GlobalResources/Pages.Ledgers.designer.cs index 6eb7796d..ccef928f 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.designer.cs +++ b/Site/App_GlobalResources/Pages.Ledgers.designer.cs @@ -618,6 +618,15 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to Close VAT report. + /// + internal static string BalanceTransactions_ModalDialog_ButtonVatReport { + get { + return ResourceManager.GetString("BalanceTransactions_ModalDialog_ButtonVatReport", resourceCulture); + } + } + /// /// Looks up a localized string similar to Balance the difference against this account:. /// @@ -654,6 +663,15 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to This transaction is payment/return for this VAT report:. + /// + internal static string BalanceTransactions_ModalDialog_DescribeVatReport { + get { + return ResourceManager.GetString("BalanceTransactions_ModalDialog_DescribeVatReport", resourceCulture); + } + } + /// /// Looks up a localized string similar to Transaction is unbalanced by <span id="spanTransactionUnbalancedBy">+FOO,BAR.QX</span>. Do you wish to.... /// @@ -708,6 +726,15 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to Close a VAT report with this transaction?. + /// + internal static string BalanceTransactions_ModalDialog_RadioVatReport { + get { + return ResourceManager.GetString("BalanceTransactions_ModalDialog_RadioVatReport", resourceCulture); + } + } + /// /// Looks up a localized string similar to Balancing/Matching Transaction #<span id="spanModalTransactionId">67890</span> From <span id="spanModalTransactionDate">yyyy-mmm-dd</span>. /// diff --git a/Site/App_GlobalResources/Pages.Ledgers.resx b/Site/App_GlobalResources/Pages.Ledgers.resx index c3658329..1e0df4e9 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.resx +++ b/Site/App_GlobalResources/Pages.Ledgers.resx @@ -862,4 +862,13 @@ Match + + Close VAT report + + + This transaction is payment/return for this VAT report: + + + Close a VAT report with this transaction? + \ No newline at end of file diff --git a/Site/Pages/v5/Ledgers/BalanceTransactions.aspx b/Site/Pages/v5/Ledgers/BalanceTransactions.aspx index c78b0d5e..3cc7fbba 100644 --- a/Site/Pages/v5/Ledgers/BalanceTransactions.aspx +++ b/Site/Pages/v5/Ledgers/BalanceTransactions.aspx @@ -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%>'); @@ -246,15 +249,17 @@

-
-
- ​
- +
+

+
+
+ ​
+ +
+
- -

@@ -290,17 +295,15 @@
-
-

-
-
- ​
- -
- +
+
+ ​
+
+ +
diff --git a/Site/Pages/v5/Ledgers/BalanceTransactions.aspx.cs b/Site/Pages/v5/Ledgers/BalanceTransactions.aspx.cs index 87d218a3..00642598 100644 --- a/Site/Pages/v5/Ledgers/BalanceTransactions.aspx.cs +++ b/Site/Pages/v5/Ledgers/BalanceTransactions.aspx.cs @@ -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); + } + } } } \ No newline at end of file diff --git a/Site/Pages/v5/Ledgers/BalanceTransactions.aspx.designer.cs b/Site/Pages/v5/Ledgers/BalanceTransactions.aspx.designer.cs index 733dc180..bbafa3c6 100644 --- a/Site/Pages/v5/Ledgers/BalanceTransactions.aspx.designer.cs +++ b/Site/Pages/v5/Ledgers/BalanceTransactions.aspx.designer.cs @@ -112,22 +112,31 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers { protected global::System.Web.UI.WebControls.Label LabelRadioBalance; /// - /// DropBudgetBalance control. + /// LabelRadioVatReport control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::Swarmops.Controls.Financial.ComboBudgets DropBudgetBalance; + protected global::System.Web.UI.WebControls.Label LabelRadioVatReport; /// - /// LabelDescribeBalance control. + /// DropOpenVatReports control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.Label LabelDescribeBalance; + protected global::Swarmops.Frontend.Controls.Base.DropDown DropOpenVatReports; + + /// + /// LabelDescribeVatReport control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelDescribeVatReport; /// /// LabelRadioPayout control. @@ -211,31 +220,22 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers { protected global::System.Web.UI.WebControls.Label LabelDescribeOutboundInvoice; /// - /// LabelRadioVatReport control. + /// DropBudgetBalance control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.Label LabelRadioVatReport; + protected global::Swarmops.Controls.Financial.ComboBudgets DropBudgetBalance; /// - /// DropOpenVatReports control. + /// LabelDescribeBalance control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::Swarmops.Frontend.Controls.Base.DropDown DropOpenVatReports; - - /// - /// LabelDescrribeVatReport control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Label LabelDescrribeVatReport; + protected global::System.Web.UI.WebControls.Label LabelDescribeBalance; /// /// LabelRadioExistingPayment control.