Beispiel #1
0
		private void detach_SenderAmounts(GoerSenderAmount entity)
		{
			this.SendPropertyChanging();
			entity.Sender = null;
		}
Beispiel #2
0
		private void attach_SenderAmounts(GoerSenderAmount entity)
		{
			this.SendPropertyChanging();
			entity.Sender = this;
		}
        private bool DoMissionTripSupporter()
        {
            var notifyIds = GetNotifyIds();
            var p = List[0];
            Transaction.Fund = p.setting.DonationFund();
            var goerid = p.Parent.GoerId > 0
                ? p.Parent.GoerId
                : p.MissionTripGoerId;
            var forgoer = "";
            var forgeneral = "";
            if (p.MissionTripSupportGoer > 0 && p.orgid.HasValue && p.PeopleId.HasValue)
            {
                var gsa = new GoerSenderAmount
                {
                    Amount = p.MissionTripSupportGoer ?? 0,
                    Created = DateTime.Now,
                    OrgId = p.orgid.Value,
                    SupporterId = p.PeopleId.Value,
                    NoNoticeToGoer = p.MissionTripNoNoticeToGoer
                };
                if (goerid > 0)
                    gsa.GoerId = goerid;
                DbUtil.Db.GoerSenderAmounts.InsertOnSubmit(gsa);
                if (p.Parent.GoerSupporterId.HasValue)
                {
                    var gs = DbUtil.Db.GoerSupporters.Single(gg => gg.Id == p.Parent.GoerSupporterId);
                    if (!gs.SupporterId.HasValue)
                        gs.SupporterId = p.PeopleId;
                }
                if (!Transaction.TransactionId.StartsWith("Coupon"))
                {
                    p.person.PostUnattendedContribution(DbUtil.Db,
                        p.MissionTripSupportGoer ?? 0, p.setting.DonationFundId,
                        $"SupportMissionTrip: org={p.orgid}; goer={goerid}", tranid: Transaction.Id);
                    Log("GoerSupport");
                    // send notices
                    if (goerid > 0 && !p.MissionTripNoNoticeToGoer)
                    {
                        var goer = DbUtil.Db.LoadPersonById(goerid.Value);
                        forgoer = $", {p.MissionTripSupportGoer:c} for {goer.Name}";
                        DbUtil.Db.Email(notifyIds[0].FromEmail, goer, org.OrganizationName + "-donation",
                            $"{p.MissionTripSupportGoer ?? 0:C} donation received from {Transaction.FullName(Transaction)}{forgoer}");
                    }
                }
            }
            if (p.MissionTripSupportGeneral > 0 && p.orgid.HasValue && p.PeopleId.HasValue)
            {
                DbUtil.Db.GoerSenderAmounts.InsertOnSubmit(
                    new GoerSenderAmount
                    {
                        Amount = p.MissionTripSupportGeneral ?? 0,
                        Created = DateTime.Now,
                        OrgId = p.orgid.Value,
                        SupporterId = p.PeopleId.Value
                    });
                forgeneral = $", ({p.MissionTripSupportGeneral ?? 0:c}) for trip";
                if (!Transaction.TransactionId.StartsWith("Coupon"))
                {
                    p.person.PostUnattendedContribution(DbUtil.Db,
                        p.MissionTripSupportGeneral ?? 0, p.setting.DonationFundId,
                        "SupportMissionTrip: org=" + p.orgid, tranid: Transaction.Id);
                    Log("TripSupport");
                }
            }
            var notifyids = DbUtil.Db.NotifyIds(org.GiftNotifyIds);
            DbUtil.Db.Email(notifyIds[0].FromEmail, notifyids, org.OrganizationName + "-donation",
                $"${Transaction.Amt:N2} donation received from {Transaction.FullName(Transaction)}{forgoer}{forgeneral}");

            var orgsettings = settings[org.OrganizationId];
            var senderSubject = orgsettings.SenderSubject ?? "NO SUBJECT SET";
            var senderBody = orgsettings.SenderBody ?? "NO SENDEREMAIL MESSAGE HAS BEEN SET";
            senderBody = APIOrganization.MessageReplacements(DbUtil.Db, p.person,
                org.DivisionName, org.OrganizationId, org.OrganizationName, org.Location, senderBody);
            senderBody = senderBody.Replace("{phone}", org.PhoneNumber.FmtFone7());
            senderBody = senderBody.Replace("{paid}", Transaction.Amt.ToString2("c"));

            //Transaction.Description = "Mission Trip Giving";
            DbUtil.Db.Email(notifyids[0].FromEmail, p.person, listMailAddress, senderSubject, senderBody, false);
            DbUtil.Db.SubmitChanges();
            return true;
        }
        internal void PostTransaction(ModelStateDictionary modelState)
        {
            if (TransactionSummary != null && (Payment ?? 0) == 0)
                modelState.AddModelError("Payment", "must have non zero value");
            if (TransactionSummary == null && (Amount ?? 0) == 0)
                modelState.AddModelError("Amount", "Initial Fee Must be > 0");
            if (!modelState.IsValid)
                return;

            var reason = TransactionSummary == null
                ? "Initial Tran"
                : AdjustFee
                    ? "AdjustFee"
                    : "Adjustment";
            if (isMissionTrip)
            {
                if (TransactionSummary == null)
                {
                    om.AddToGroup(DbUtil.Db, "Goer");
                    om.Amount = Amount;
                }
                if (AdjustFee == false && (Payment ?? 0) != 0)
                {
                    var gs = new GoerSenderAmount
                    {
                        GoerId = om.PeopleId,
                        SupporterId = om.PeopleId,
                        Amount = Payment,
                        OrgId = om.OrganizationId,
                        Created = DateTime.Now,
                    };
                    DbUtil.Db.GoerSenderAmounts.InsertOnSubmit(gs);
                }
            }
            om.AddTransaction(DbUtil.Db, reason, Payment ?? 0, Description, Amount, AdjustFee);
            var showcount = "";
            if (TransactionSummary != null && TransactionSummary.NumPeople > 1)
                showcount = $"({TransactionSummary.NumPeople}) ";
            DbUtil.LogActivity($"OrgMem{showcount} {reason}", OrgId, PeopleId);
        }
Beispiel #5
0
 private void detach_GoerSenderAmounts(GoerSenderAmount entity)
 {
     this.SendPropertyChanging();
     entity.Organization = null;
 }