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 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; }
public void Test_09_TAccountPropertyHandler() { TLedgerInfo tHandleLedgerInfo = new TLedgerInfo(LedgerNumber); TAccountInfo tHandleAccountInfo = new TAccountInfo(tHandleLedgerInfo); tHandleAccountInfo.SetSpecialAccountCode(TAccountPropertyEnum.ICH_ACCT); Assert.IsTrue(tHandleAccountInfo.IsValid, "ICH_ACCT shall exist"); Assert.AreEqual("8500", tHandleAccountInfo.AccountCode); }
private void CalculateAccountInfo() { FaccountInfo = new TAccountInfo(FledgerInfo); bool blnIncomeFound = false; bool blnExpenseFound = false; String strIncomeAccount = TAccountTypeEnum.Income.ToString(); String strExpenseAccount = TAccountTypeEnum.Expense.ToString(); FaccountInfo.Reset(); FAccountList = new List <String>(); while (FaccountInfo.MoveNext()) { if (FaccountInfo.PostingStatus) { if (FaccountInfo.AccountType == strIncomeAccount) { FAccountList.Add(FaccountInfo.AccountCode); blnIncomeFound = true; } if (FaccountInfo.AccountType == strExpenseAccount) { FAccountList.Add(FaccountInfo.AccountCode); blnExpenseFound = true; } } } if (!blnIncomeFound) { TVerificationResult tvt = new TVerificationResult(Catalog.GetString("No Income Account found"), Catalog.GetString("At least one income account is required."), "", TPeriodEndErrorAndStatusCodes.PEEC_09.ToString(), TResultSeverity.Resv_Critical); FverificationResults.Add(tvt); FHasCriticalErrors = true; } if (!blnExpenseFound) { TVerificationResult tvt = new TVerificationResult(Catalog.GetString("No Expense Account found"), Catalog.GetString("At least one expense account is required."), "", TPeriodEndErrorAndStatusCodes.PEEC_10.ToString(), TResultSeverity.Resv_Critical); FverificationResults.Add(tvt); FHasCriticalErrors = true; } FaccountInfo.SetSpecialAccountCode(TAccountPropertyEnum.ICH_ACCT); if (FaccountInfo.IsValid) { FAccountList.Add(FaccountInfo.AccountCode); } else { TVerificationResult tvt = new TVerificationResult(Catalog.GetString("No ICH_ACCT Account defined"), Catalog.GetString("An ICH Account must be defined."), "", TPeriodEndErrorAndStatusCodes.PEEC_11.ToString(), TResultSeverity.Resv_Critical); FverificationResults.Add(tvt); FHasCriticalErrors = true; } TDBTransaction Transaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref Transaction, delegate { FCostCentreTbl = ACostCentreAccess.LoadViaALedger(FledgerInfo.LedgerNumber, Transaction); }); FCostCentreTbl.DefaultView.Sort = ACostCentreTable.GetCostCentreCodeDBName(); }