VAT reports basically work
This commit is contained in:
@@ -107,6 +107,11 @@ namespace Swarmops.Logic.Financial
|
||||
}
|
||||
|
||||
vatReportTransaction.Dependency = newReport;
|
||||
newReport.OpenTransaction = vatReportTransaction;
|
||||
}
|
||||
else
|
||||
{
|
||||
newReport.Open = false; // nothing to close, no tx created
|
||||
}
|
||||
|
||||
return newReport;
|
||||
@@ -243,7 +248,10 @@ namespace Swarmops.Logic.Financial
|
||||
|
||||
public new int OpenTransactionId
|
||||
{
|
||||
get { return base.OpenTransactionId; }
|
||||
get
|
||||
{
|
||||
return base.OpenTransactionId;
|
||||
}
|
||||
set
|
||||
{
|
||||
SwarmDb.GetDatabaseForWriting().SetVatReportOpenTransaction(this.Identity, value);
|
||||
@@ -253,7 +261,11 @@ namespace Swarmops.Logic.Financial
|
||||
|
||||
public FinancialTransaction OpenTransaction
|
||||
{
|
||||
get { return FinancialTransaction.FromIdentity(OpenTransactionId); }
|
||||
get
|
||||
{
|
||||
if (base.OpenTransactionId == 0) return null;
|
||||
return FinancialTransaction.FromIdentity(OpenTransactionId);
|
||||
}
|
||||
set { this.OpenTransactionId = value.Identity; }
|
||||
}
|
||||
|
||||
@@ -269,8 +281,33 @@ namespace Swarmops.Logic.Financial
|
||||
|
||||
public FinancialTransaction CloseTransaction
|
||||
{
|
||||
get { return FinancialTransaction.FromIdentity(CloseTransactionId); }
|
||||
set { this.CloseTransactionId = value.Identity; }
|
||||
get
|
||||
{
|
||||
if (base.CloseTransactionId == 0) return null;
|
||||
return FinancialTransaction.FromIdentity(CloseTransactionId);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
this.CloseTransactionId = value.Identity;
|
||||
this.Open = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentNullException(); // is this a valid case?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public new bool Open
|
||||
{
|
||||
get { return base.Open; }
|
||||
set
|
||||
{
|
||||
SwarmDb.GetDatabaseForWriting().SetVatReportOpen(this.Identity, value);
|
||||
base.Open = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,9 +70,11 @@
|
||||
|
||||
if (data.OpenOutboundInvoiceData != null) {
|
||||
if (data.OpenOutboundInvoiceData.ExactMatches.length > 0) {
|
||||
$('#divOutboundInvoice').show();
|
||||
<%=this.DropOpenOutboundInvoices.ClientID%>_loadData(data.OpenOutboundInvoiceData.ExactMatches);
|
||||
<%=this.DropOpenOutboundInvoices.ClientID%>_text("<%=Resources.Global.Global_SelectOne%>");
|
||||
} else {
|
||||
$('#divOutboundInvoice').hide();
|
||||
<%=this.DropOpenOutboundInvoices.ClientID%>_loadData({});
|
||||
<%=this.DropOpenOutboundInvoices.ClientID%>_text("<%=Resources.Global.Global_NoMatch%>");
|
||||
}
|
||||
@@ -179,7 +181,7 @@
|
||||
}
|
||||
|
||||
|
||||
function onMatchVatReport() {
|
||||
function onMatchOpenVatReport() {
|
||||
var vatReportId = <%=this.DropOpenVatReports.ClientID%>_val();
|
||||
|
||||
if (vatReportId > 0) {
|
||||
@@ -232,7 +234,7 @@
|
||||
idField="id">
|
||||
<thead>
|
||||
<tr>
|
||||
<th field="checkTx" checkbox="true"></th>
|
||||
<!--<th field="checkTx" checkbox="true"></th>-->
|
||||
<th data-options="field:'id',width:60,align:'right'"><asp:Label ID="LabelGridHeaderId" runat="server" Text="ID#"/></th>
|
||||
<th data-options="field:'dateTime',width:170,sortable:true"><asp:Label ID="LabelGridHeaderDateTime" runat="server" Text="XYZ DateTime" /></th>
|
||||
<th data-options="field:'accountName',width:170"><asp:Label ID="LabelGridHeaderAccountName" runat="server" Text="XYZ Debit" /></th>
|
||||
@@ -248,7 +250,6 @@
|
||||
<DialogCode>
|
||||
<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"> <asp:Label runat="server" ID="LabelRadioBalance" Text="Balance the transaction manually? XYZ" /></label></p>
|
||||
<div id="divVatReport">
|
||||
<p><input type="radio" id="RadioVatReport" name="TxOptions" value="VatReport" /><label for="RadioVatReport"> <asp:Label runat="server" ID="LabelRadioVatReport" Text="Match to an open VAT report? XYZ" /></label></p>
|
||||
<div id="radioOptionVatReport" class="radioOption">
|
||||
@@ -284,17 +285,20 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="divPositiveDifference">
|
||||
<p><input type="radio" id="RadioOutboundInvoice" name="TxOptions" value="OutboundInvoice" /><label for="RadioOutboundInvoice"> <asp:Label runat="server" ID="LabelRadioOutboundInvoice" Text="Match to an open outbound invoice? XYZ" /></label></p>
|
||||
<div id="radioOptionOutboundInvoice" class="radioOption">
|
||||
<div class="entryFields">
|
||||
<Swarmops5:DropDown ID="DropOpenOutboundInvoices" runat="server" />​<br/>
|
||||
<input type="button" value='#PaymentInvoice#' class="buttonAccentColor" onclick="onMatchOpenOutboundInvoice(); return false;" id="buttonExecuteOutboundInvoice"/>
|
||||
</div>
|
||||
<div class="entryLabels">
|
||||
<asp:Label runat="server" ID="LabelDescribeOutboundInvoice" Text="Match to outbound invoice XYZ" />
|
||||
<div id="divOutboundInvoice">
|
||||
<p><input type="radio" id="RadioOutboundInvoice" name="TxOptions" value="OutboundInvoice" /><label for="RadioOutboundInvoice"> <asp:Label runat="server" ID="LabelRadioOutboundInvoice" Text="Match to an open outbound invoice? XYZ" /></label></p>
|
||||
<div id="radioOptionOutboundInvoice" class="radioOption">
|
||||
<div class="entryFields">
|
||||
<Swarmops5:DropDown ID="DropOpenOutboundInvoices" runat="server" />​<br/>
|
||||
<input type="button" value='#PaymentInvoice#' class="buttonAccentColor" onclick="onMatchOpenOutboundInvoice(); return false;" id="buttonExecuteOutboundInvoice"/>
|
||||
</div>
|
||||
<div class="entryLabels">
|
||||
<asp:Label runat="server" ID="LabelDescribeOutboundInvoice" Text="Match to outbound invoice XYZ" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p><input type="radio" id="RadioBalance" name="TxOptions" value="Balance" /><label for="RadioBalance"> <asp:Label runat="server" ID="LabelRadioBalance" Text="Balance the transaction manually? XYZ" /></label></p>
|
||||
<div id="radioOptionBalance" class="radioOption"> <!-- this should go last -->
|
||||
<div class="entryFields">
|
||||
<Swarmops5:ComboBudgets ID="DropBudgetBalance" runat="server" ListType="All" />​<br/>
|
||||
|
||||
@@ -458,7 +458,53 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
[WebMethod]
|
||||
public static void MatchTransactionOpenVatReport(int transactionId, int vatReportId)
|
||||
{
|
||||
|
||||
if (transactionId == 0 || vatReportId == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (
|
||||
!authData.Authority.HasAccess(new Access(authData.CurrentOrganization,
|
||||
AccessAspect.BookkeepingDetails)))
|
||||
{
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
|
||||
FinancialTransaction transaction = FinancialTransaction.FromIdentity(transactionId);
|
||||
VatReport vatReport = VatReport.FromIdentity(vatReportId);
|
||||
|
||||
if (authData.CurrentOrganization.Identity != transaction.OrganizationId
|
||||
|| authData.CurrentOrganization.Identity != vatReport.OrganizationId)
|
||||
{
|
||||
throw new InvalidOperationException("Organization mismatch");
|
||||
}
|
||||
|
||||
Int64 diffCents = vatReport.VatInboundCents - vatReport.VatOutboundCents;
|
||||
|
||||
if (transaction.Rows.AmountCentsTotal != diffCents)
|
||||
{
|
||||
throw new InvalidOperationException("Amount mismatch");
|
||||
}
|
||||
|
||||
// Go ahead and close
|
||||
|
||||
vatReport.CloseTransaction = transaction; // throws if already closed
|
||||
vatReport.Open = false;
|
||||
|
||||
if (diffCents > 0)
|
||||
{
|
||||
// Positive amount - asset account
|
||||
transaction.AddRow(authData.CurrentOrganization.FinancialAccounts.AssetsVatInboundReported, -diffCents,
|
||||
null);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Negative amount - liability account
|
||||
transaction.AddRow(authData.CurrentOrganization.FinancialAccounts.DebtsVatOutboundReported, -diffCents,
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+9
-9
@@ -102,15 +102,6 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers {
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Literal LabelDoYouWishTo;
|
||||
|
||||
/// <summary>
|
||||
/// LabelRadioBalance 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 LabelRadioBalance;
|
||||
|
||||
/// <summary>
|
||||
/// LabelRadioVatReport control.
|
||||
/// </summary>
|
||||
@@ -219,6 +210,15 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers {
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label LabelDescribeOutboundInvoice;
|
||||
|
||||
/// <summary>
|
||||
/// LabelRadioBalance 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 LabelRadioBalance;
|
||||
|
||||
/// <summary>
|
||||
/// DropBudgetBalance control.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user