public static TransactionMatchabilityData GetTransactionMatchability(int transactionId) { AuthenticationData authData = GetAuthenticationDataAndCulture(); if ( !authData.Authority.HasAccess(new Access(authData.CurrentOrganization, AccessAspect.BookkeepingDetails))) { throw new UnauthorizedAccessException(); } FinancialTransaction transaction = FinancialTransaction.FromIdentity(transactionId); if (transaction.OrganizationId != authData.CurrentOrganization.Identity) { throw new UnauthorizedAccessException(); } TransactionMatchabilityData result = new TransactionMatchabilityData(); result.TransactionDate = transaction.DateTime.ToString("yyyy-MMM-dd HH:mm"); result.DifferingAmount = String.Format("{0} {1:+#,#.00;−#,#.00;0}", // this is a UNICODE MINUS (U+2212), not the hyphen on the keyboard authData.CurrentOrganization.Currency.DisplayCode, transaction.Rows.AmountCentsTotal / 100.0); result.OpenPayoutData = GetOpenPayoutData(transaction); return(result); }
public static TransactionMatchabilityData GetTransactionMatchability(int transactionId) { AuthenticationData authData = GetAuthenticationDataAndCulture(); if ( !authData.Authority.HasAccess(new Access(authData.CurrentOrganization, AccessAspect.BookkeepingDetails))) { throw new UnauthorizedAccessException(); } FinancialTransaction transaction = FinancialTransaction.FromIdentity(transactionId); if (transaction.OrganizationId != authData.CurrentOrganization.Identity) { throw new UnauthorizedAccessException(); } TransactionMatchabilityData result = new TransactionMatchabilityData(); Int64 transactionCents = transaction.Rows.AmountCentsTotal; result.TransactionDate = transaction.DateTime.ToString("yyyy-MMM-dd HH:mm"); result.TransactionDescription = transaction.Description; result.AmountAsPurchase = ((-transactionCents) / 100.0).ToString("N2"); result.DifferingAmount = String.Format("{0} {1:+#,#.00;−#,#.00;0}", // this is a UNICODE MINUS (U+2212), not the hyphen on the keyboard authData.CurrentOrganization.Currency.DisplayCode, transactionCents / 100.0); if (transaction.Rows.AmountCentsTotal > 0) { result.OpenOutboundInvoiceData = GetOpenOutboundInvoiceData(transaction); result.AmountSign = 1; } else { // Negative difference result.AmountSign = -1; result.OpenPayoutData = GetOpenPayoutData(transaction); } result.OpenVatReportData = GetOpenVatReportData(transaction); return(result); }