private void LoadDatabase() { intBaseCurrencyDigits = DIGIT_INIT_VALUE; intForeignCurrencyDigits = DIGIT_INIT_VALUE; TDBTransaction transaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref transaction, delegate { currencyTable = ACurrencyAccess.LoadAll(transaction); }); if (currencyTable.Rows.Count == 0) { EVerificationException terminate = new EVerificationException( Catalog.GetString("The table a_currency is empty!")); terminate.Context = "Common Accounting"; terminate.ErrorCode = "TCurrencyInfo01"; throw terminate; } }
/// <summary> /// /// </summary> public FormatConverter(string strFormat) { sRegex = ">9.(9)+|>9$"; reg = new Regex(sRegex); matchCollection = reg.Matches(strFormat); if (matchCollection.Count != 1) { EVerificationException terminate = new EVerificationException( String.Format(Catalog.GetString("The regular expression {0} does not fit for a match in {1}"), sRegex, strFormat)); terminate.Context = "Common Accountig"; terminate.ErrorCode = "TCurrencyInfo03"; throw terminate; } intDigits = (matchCollection[0].Value).Length - 3; if (intDigits == -1) { intDigits = 0; } if (intDigits < -1) { intDigits = 2; } }
private ATransactionRow AddATransaction(string AAccount, string ACostCenter, string ANarrativeMessage, string AReferenceMessage, bool AIsDebit, decimal AAmountBaseCurrency, decimal AAmountForeignCurrency, bool ATransActionIsInForeign) { if (!blnReadyForTransaction) { EVerificationException terminate = new EVerificationException( Catalog.GetString("You have to add a journal before you can add a transaction!")); terminate.Context = "Common Accounting"; terminate.ErrorCode = "GL.CAT.06"; throw terminate; } if (AAccount.Trim().Length == 0) { throw new Exception("account code is empty"); } if (FForeignJournal) { if (ATransActionIsInForeign) { TAccountInfo accountCheck = new TAccountInfo(FLedgerInfo, AAccount); if (accountCheck.IsValid) { if (accountCheck.ForeignCurrencyFlag) { if (!accountCheck.ForeignCurrencyCode.Equals(this.FForeignCurrencyInfo.CurrencyCode)) { // This is a difficult error situation. Someone wants to account // JYP-Currencies on a GBP-account in an EUR ledger. string strMessage = Catalog.GetString("The ledger is defined in {0}, the account {1} is defined in " + "{2} and you want to account something in {3}?"); strMessage = String.Format(strMessage, FLedgerInfo.BaseCurrency, AAccount, accountCheck.ForeignCurrencyCode, FForeignCurrencyInfo.CurrencyCode); EVerificationException terminate = new EVerificationException(strMessage); terminate.Context = "Common Accounting"; terminate.ErrorCode = "GL.CAT.07"; throw terminate; } } } } } ATransactionRow transRow = null; transRow = FBatchTDS.ATransaction.NewRowTyped(); transRow.LedgerNumber = FJournalRow.LedgerNumber; transRow.BatchNumber = FJournalRow.BatchNumber; transRow.JournalNumber = FJournalRow.JournalNumber; transRow.TransactionNumber = ++FJournalRow.LastTransactionNumber; transRow.AccountCode = AAccount; transRow.CostCentreCode = ACostCenter; transRow.Narrative = ANarrativeMessage; transRow.Reference = AReferenceMessage; transRow.DebitCreditIndicator = AIsDebit; transRow.AmountInBaseCurrency = AAmountBaseCurrency; transRow.TransactionAmount = (ATransActionIsInForeign) ? AAmountForeignCurrency : AAmountBaseCurrency; // // The International currency calculation is changed to "Base -> International", because it's likely // we won't have a "Transaction -> International" conversion rate defined. // transRow.AmountInIntlCurrency = GLRoutines.Multiply(transRow.AmountInBaseCurrency, TExchangeRateTools.GetDailyExchangeRate( FLedgerInfo.BaseCurrency, FLedgerInfo.InternationalCurrency, transRow.TransactionDate)); transRow.TransactionDate = FBatchRow.DateEffective; FBatchTDS.ATransaction.Rows.Add(transRow); if (AIsDebit) { FJournalRow.JournalDebitTotal += AAmountBaseCurrency; } else { FJournalRow.JournalCreditTotal += AAmountBaseCurrency; } return transRow; }
private ACurrencyRow SetRowToCode(string ACurrencyCode) { if (ACurrencyCode.Equals(String.Empty)) { return null; } for (int i = 0; i < currencyTable.Rows.Count; ++i) { if (ACurrencyCode.Equals(((ACurrencyRow)currencyTable[i]).CurrencyCode)) { return (ACurrencyRow)currencyTable[i]; } } EVerificationException terminate = new EVerificationException( String.Format(Catalog.GetString( "No Data for currency {0} found"), ACurrencyCode)); terminate.Context = "Common Accounting"; terminate.ErrorCode = "TCurrencyInfo02"; throw terminate; }
/// <summary> /// Add a foreign currency transaction ... /// </summary> /// <param name="AAccount"></param> /// <param name="ACostCenter"></param> /// <param name="ANarrativeMessage"></param> /// <param name="AReferenceMessage"></param> /// <param name="AIsDebit"></param> /// <param name="AAmountBaseCurrency"></param> /// <param name="AAmountForeignCurrency"></param> public ATransactionRow AddForeignCurrencyTransaction(string AAccount, string ACostCenter, string ANarrativeMessage, string AReferenceMessage, bool AIsDebit, decimal AAmountBaseCurrency, decimal AAmountForeignCurrency) { if (!FForeignJournal) { EVerificationException terminate = new EVerificationException( Catalog.GetString("You cannot account foreign currencies in a base journal!")); terminate.Context = "Common Accounting"; terminate.ErrorCode = "GL.CAT.05"; throw terminate; } return AddATransaction(AAccount, ACostCenter, ANarrativeMessage, AReferenceMessage, AIsDebit, AAmountBaseCurrency, AAmountForeignCurrency, true); }