private void UpdateTransactionsCurrencyAmounts(AGiftBatchRow ABatchRow, Decimal AIntlToBaseCurrencyExchRate, Boolean ATransactionInIntlCurrency) { int LedgerNumber = ABatchRow.LedgerNumber; int BatchNumber = ABatchRow.BatchNumber; decimal BatchExchangeRateToBase = ABatchRow.ExchangeRateToBase; if (!LoadGiftDataForBatch(LedgerNumber, BatchNumber)) { return; } DataView transDV = new DataView(FMainDS.AGiftDetail); transDV.RowFilter = String.Format("{0}={1}", AGiftDetailTable.GetBatchNumberDBName(), BatchNumber); foreach (DataRowView drvTrans in transDV) { AGiftDetailRow gdr = (AGiftDetailRow)drvTrans.Row; gdr.GiftAmount = GLRoutines.Divide(gdr.GiftTransactionAmount, BatchExchangeRateToBase); if (!ATransactionInIntlCurrency) { gdr.GiftAmountIntl = (AIntlToBaseCurrencyExchRate == 0) ? 0 : GLRoutines.Divide(gdr.GiftAmount, AIntlToBaseCurrencyExchRate); } else { gdr.GiftAmountIntl = gdr.GiftTransactionAmount; } if (FSETUseTaxDeductiblePercentageFlag) { TaxDeductibility.UpdateTaxDeductibiltyAmounts(ref gdr); } } }
/// <summary> /// Update the transaction base amount calculation /// </summary> /// <param name="AUpdateCurrentRowOnly"></param> public void UpdateBaseAmount(Boolean AUpdateCurrentRowOnly) { Int32 LedgerNumber; Int32 CurrentBatchNumber; DateTime BatchEffectiveDate; decimal BatchExchangeRateToBase = 0; string BatchCurrencyCode = string.Empty; decimal IntlToBaseCurrencyExchRate = 0; bool IsTransactionInIntlCurrency; string LedgerBaseCurrency = string.Empty; string LedgerIntlCurrency = string.Empty; bool TransactionsFromCurrentBatch = false; AGiftBatchRow CurrentBatchRow = GetBatchRow(); if (FShowDetailsInProcess || !(((TFrmGiftBatch)this.ParentForm).GetBatchControl().FBatchLoaded) || (CurrentBatchRow == null) || (CurrentBatchRow.BatchStatus != MFinanceConstants.BATCH_UNPOSTED)) { return; } BatchCurrencyCode = CurrentBatchRow.CurrencyCode; BatchExchangeRateToBase = CurrentBatchRow.ExchangeRateToBase; if ((FBatchRow != null) && (CurrentBatchRow.LedgerNumber == FBatchRow.LedgerNumber) && (CurrentBatchRow.BatchNumber == FBatchRow.BatchNumber)) { TransactionsFromCurrentBatch = true; FBatchCurrencyCode = BatchCurrencyCode; FBatchExchangeRateToBase = BatchExchangeRateToBase; } LedgerNumber = CurrentBatchRow.LedgerNumber; CurrentBatchNumber = CurrentBatchRow.BatchNumber; BatchEffectiveDate = CurrentBatchRow.GlEffectiveDate; LedgerBaseCurrency = FMainDS.ALedger[0].BaseCurrency; LedgerIntlCurrency = FMainDS.ALedger[0].IntlCurrency; IntlToBaseCurrencyExchRate = ((TFrmGiftBatch)ParentForm).InternationalCurrencyExchangeRate(CurrentBatchRow, out IsTransactionInIntlCurrency); if (!LoadGiftDataForBatch(LedgerNumber, CurrentBatchNumber)) { //No transactions exist to process or corporate exchange rate not found return; } //If only updating the currency active row if (AUpdateCurrentRowOnly && (FPreviouslySelectedDetailRow != null)) { try { FPreviouslySelectedDetailRow.BeginEdit(); FPreviouslySelectedDetailRow.GiftAmount = GLRoutines.Divide((decimal)txtDetailGiftTransactionAmount.NumberValueDecimal, BatchExchangeRateToBase); if (!IsTransactionInIntlCurrency) { FPreviouslySelectedDetailRow.GiftAmountIntl = (IntlToBaseCurrencyExchRate == 0) ? 0 : GLRoutines.Divide( FPreviouslySelectedDetailRow.GiftAmount, IntlToBaseCurrencyExchRate); } else { FPreviouslySelectedDetailRow.GiftAmountIntl = FPreviouslySelectedDetailRow.GiftTransactionAmount; } if (FSETUseTaxDeductiblePercentageFlag) { EnableTaxDeductibilityPct(chkDetailTaxDeductible.Checked); UpdateTaxDeductibilityAmounts(this, null); } } finally { FPreviouslySelectedDetailRow.EndEdit(); } } else { if (TransactionsFromCurrentBatch && (FPreviouslySelectedDetailRow != null)) { try { //Rows already active in transaction tab. Need to set current row as code further below will not update selected row FPreviouslySelectedDetailRow.BeginEdit(); FPreviouslySelectedDetailRow.GiftAmount = GLRoutines.Divide(FPreviouslySelectedDetailRow.GiftTransactionAmount, BatchExchangeRateToBase); if (!IsTransactionInIntlCurrency) { FPreviouslySelectedDetailRow.GiftAmountIntl = (IntlToBaseCurrencyExchRate == 0) ? 0 : GLRoutines.Divide( FPreviouslySelectedDetailRow.GiftAmount, IntlToBaseCurrencyExchRate); } else { FPreviouslySelectedDetailRow.GiftAmountIntl = FPreviouslySelectedDetailRow.GiftTransactionAmount; } } finally { FPreviouslySelectedDetailRow.EndEdit(); } } //Update all transactions UpdateTransactionsCurrencyAmounts(CurrentBatchRow, IntlToBaseCurrencyExchRate, IsTransactionInIntlCurrency); } }