Beispiel #1
0
        /// <summary>
        /// Sets TaxDeductiblePct and uses it to calculate the tax deductibility amounts for a Gift Detail
        /// </summary>
        /// <param name="AGiftDetail">Calculated amounts are added to this row</param>
        /// <param name="ADateEntered"></param>
        /// <param name="ATransaction"></param>
        public static void SetDefaultTaxDeductibilityData(
            ref AGiftDetailRow AGiftDetail, DateTime ADateEntered, TDBTransaction ATransaction)
        {
            bool FoundTaxDeductiblePct = false;

            // if the gift it tax deductible
            if (AGiftDetail.TaxDeductible)
            {
                AMotivationDetailTable Tbl = AMotivationDetailAccess.LoadByPrimaryKey(
                    AGiftDetail.LedgerNumber, AGiftDetail.MotivationGroupCode, AGiftDetail.MotivationDetailCode, ATransaction);
                AMotivationDetailRow MotivationDetailRow;

                Boolean HasTaxDeductibleAccountCode = false;

                if (Tbl.Rows.Count > 0)
                {
                    MotivationDetailRow         = Tbl[0];
                    HasTaxDeductibleAccountCode = !string.IsNullOrEmpty(MotivationDetailRow.TaxDeductibleAccountCode);
                }

                // if the gift's motivation detail has a tax-deductible account
                if (HasTaxDeductibleAccountCode)
                {
                    // default pct is 100
                    AGiftDetail.TaxDeductiblePct = 100;
                    FoundTaxDeductiblePct        = true;

                    PPartnerTaxDeductiblePctTable PartnerTaxDeductiblePctTable =
                        PPartnerTaxDeductiblePctAccess.LoadViaPPartner(AGiftDetail.RecipientKey, ATransaction);

                    // search for tax deductible pct for recipient
                    foreach (PPartnerTaxDeductiblePctRow Row in PartnerTaxDeductiblePctTable.Rows)
                    {
                        if (Row.DateValidFrom <= ADateEntered)
                        {
                            AGiftDetail.TaxDeductiblePct = Row.PercentageTaxDeductible;
                            break;
                        }
                    }
                }
            }

            // if a tax deductible pct is set for the recipient
            if (FoundTaxDeductiblePct)
            {
                // calculate TaxDeductibleAmount and NonDeductibleAmount for all three currencies
                TaxDeductibility.UpdateTaxDeductibiltyAmounts(ref AGiftDetail);
            }

            // if gift is not tax deductible or motivation detail does not hace a tax deductible account
            if (!AGiftDetail.TaxDeductible || !FoundTaxDeductiblePct)
            {
                AGiftDetail.TaxDeductiblePct        = 0;
                AGiftDetail.NonDeductibleAmount     = AGiftDetail.GiftTransactionAmount;
                AGiftDetail.NonDeductibleAmountBase = AGiftDetail.GiftAmount;
                AGiftDetail.NonDeductibleAmountIntl = AGiftDetail.GiftAmountIntl;
            }
        }
Beispiel #2
0
        public static bool SetDefaultMotivationDetail(Int32 ALedgerNumber,
                                                      String AMotivationGroupCode, String AMotivationDetailCode,
                                                      out TVerificationResultCollection AVerificationResult)
        {
            AVerificationResult = new TVerificationResultCollection();
            GiftBatchTDS MainDS = new GiftBatchTDS();

            TDBTransaction Transaction = new TDBTransaction();
            TDataBase      db          = DBAccess.Connect("SetDefaultMotivationDetail");

            if (!(AMotivationGroupCode == String.Empty && AMotivationDetailCode == String.Empty))
            {
                bool validDetail = true;

                db.ReadTransaction(
                    ref Transaction,
                    delegate
                {
                    // is this a valid motivation group and detail combination?
                    AMotivationDetailAccess.LoadByPrimaryKey(MainDS, ALedgerNumber, AMotivationGroupCode, AMotivationDetailCode, Transaction);

                    if (MainDS.AMotivationDetail.Rows.Count == 0)
                    {
                        validDetail = false;
                    }
                    else if (MainDS.AMotivationDetail[0].MotivationStatus == false)
                    {
                        validDetail = false;
                    }
                });

                if (!validDetail)
                {
                    AVerificationResult.Add(new TVerificationResult("error", "invalid or inactive motivation detail", TResultSeverity.Resv_Critical));
                    return(false);
                }
            }

            // Store System Default for this ledger
            return(new TSystemDefaults().SetSystemDefault("DEFAULTMOTIVATION" + ALedgerNumber.ToString(), AMotivationGroupCode + "::" + AMotivationDetailCode));
        }