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); } } var descriptionForPayment = OnlineRegModel.GetDescriptionForPayment(OrgId); om.AddTransaction(DbUtil.Db, reason, Payment ?? 0, Description, Amount, AdjustFee, descriptionForPayment); var showcount = ""; if (TransactionSummary != null && TransactionSummary.NumPeople > 1) { showcount = $"({TransactionSummary.NumPeople}) "; } DbUtil.LogActivity($"OrgMem{showcount} {reason}", OrgId, PeopleId); }
internal void PostTransactions() { foreach (var pid in Pids) { var db = DbUtil.Create(Util.Host); var om = DbUtil.Db.OrganizationMembers.Single(mm => mm.PeopleId == pid && mm.OrganizationId == OrgId); var ts = DbUtil.Db.ViewTransactionSummaries.SingleOrDefault( tt => tt.RegId == om.TranId && tt.PeopleId == om.PeopleId); var reason = ts == null ? "Initial Tran" : "Adjustment"; var descriptionForPayment = OnlineRegModel.GetDescriptionForPayment(OrgId); om.AddTransaction(DbUtil.Db, reason, Payment ?? 0, Description, Amount, AdjustFee, descriptionForPayment); DbUtil.Db.SubmitChanges(); DbUtil.LogActivity("OrgMem " + reason, OrgId, pid); } }
internal void PostContribution() { if (!(AmountGeneral > 0) && !(AmountGoer > 0)) { return; } var org = DbUtil.Db.LoadOrganizationById(OrgId); var notifyIds = DbUtil.Db.NotifyIds(org.GiftNotifyIds); var person = DbUtil.Db.LoadPersonById(PeopleId ?? 0); var setting = DbUtil.Db.CreateRegistrationSettings(OrgId ?? 0); var fund = setting.DonationFundId; if (AmountGoer > 0) { var goerid = Goer.Value.ToInt(); DbUtil.Db.GoerSenderAmounts.InsertOnSubmit( new GoerSenderAmount { Amount = AmountGoer, GoerId = goerid, Created = DateTime.Now, OrgId = org.OrganizationId, SupporterId = PeopleId ?? 0, }); var c = person.PostUnattendedContribution(DbUtil.Db, AmountGoer ?? 0, fund, $"SupportMissionTrip: org={OrgId}; goer={Goer.Value}", typecode: BundleTypeCode.MissionTrip); c.CheckNo = (CheckNo ?? "").Trim().Truncate(20); if (PeopleId == goerid) { var om = DbUtil.Db.OrganizationMembers.Single( mm => mm.PeopleId == goerid && mm.OrganizationId == OrgId); var descriptionForPayment = OnlineRegModel.GetDescriptionForPayment(OrgId); om.AddTransaction(DbUtil.Db, "Payment", AmountGoer ?? 0, "Payment", pmtDescription: descriptionForPayment); } // send notices var goer = DbUtil.Db.LoadPersonById(goerid); ToGoerName = "to " + goer.Name; DbUtil.Db.Email(notifyIds[0].FromEmail, goer, org.OrganizationName + "-donation", $"{AmountGoer:C} donation received from {person.Name}"); DbUtil.LogActivity("OrgMem SupportMissionTrip goer=" + goerid, OrgId, PeopleId); } if (AmountGeneral > 0) { DbUtil.Db.GoerSenderAmounts.InsertOnSubmit( new GoerSenderAmount { Amount = AmountGeneral, Created = DateTime.Now, OrgId = org.OrganizationId, SupporterId = PeopleId ?? 0 }); var c = person.PostUnattendedContribution(DbUtil.Db, AmountGeneral ?? 0, fund, $"SupportMissionTrip: org={OrgId}", typecode: BundleTypeCode.MissionTrip); if (CheckNo.HasValue()) { c.CheckNo = (CheckNo ?? "").Trim().Truncate(20); } DbUtil.LogActivity("OrgMem SupportMissionTrip", OrgId, PeopleId); } DbUtil.Db.SubmitChanges(); }