Exemple #1
0
        public static void ConfirmDuePaidTransaction(Transaction ti, string transactionId, bool sendmail)
        {
            var Db = DbUtil.Db;
            var org = Db.LoadOrganizationById(ti.OrgId);
            ti.TransactionId = transactionId;
            if (ti.Testing == true && !ti.TransactionId.Contains("(testing)"))
                ti.TransactionId += "(testing)";

            var amt = ti.Amt;
            var due = PaymentForm.AmountDueTrans(Db, ti);
            foreach (var pi in ti.OriginalTrans.TransactionPeople)
            {
                var p = Db.LoadPersonById(pi.PeopleId);
                if (p != null)
                {
                    var om = Db.OrganizationMembers.SingleOrDefault(m => m.OrganizationId == ti.OrgId && m.PeopleId == pi.PeopleId);
                    if (om == null)
                        continue;
                    Db.SubmitChanges();
                    if (org.IsMissionTrip == true)
                    {
                        Db.GoerSenderAmounts.InsertOnSubmit(
                            new GoerSenderAmount
                            {
                                Amount = ti.Amt,
                                GoerId = pi.PeopleId,
                                Created = DateTime.Now,
                                OrgId = org.OrganizationId,
                                SupporterId = pi.PeopleId,
                            });
                        var setting = Db.CreateRegistrationSettings(org.OrganizationId);
                        var fund = setting.DonationFundId;
                        p.PostUnattendedContribution(Db, ti.Amt ?? 0, fund,
                            $"SupportMissionTrip: org={org.OrganizationId}; goer={pi.PeopleId}", typecode: BundleTypeCode.Online);
                    }
                    var pay = amt;
                    if (org.IsMissionTrip == true)
                        ti.Amtdue = due;

                    var sb = new StringBuilder();
                    sb.AppendFormat("{0:g} ----------\n", Util.Now);
                    sb.AppendFormat("{0:c} ({1} id) transaction amount\n", ti.Amt, ti.Id);
                    sb.AppendFormat("{0:c} applied to this registrant\n", pay);
                    sb.AppendFormat("{0:c} total due all registrants\n", due);

                    om.AddToMemberDataBelowComments(sb.ToString());
                    var reg = p.SetRecReg();
                    reg.AddToComments(sb.ToString());
                    reg.AddToComments($"{org.OrganizationName} ({org.OrganizationId})");

                    amt -= pay;
                }
                else
                    Db.Email(Db.StaffEmailForOrg(org.OrganizationId),
                        Db.PeopleFromPidString(org.NotifyIds),
                        "missing person on payment due",
                        $"Cannot find {pi.Person.Name} ({pi.PeopleId}), payment due completed of {pi.Amt:c} but no record");
            }
            Db.SubmitChanges();
            var names = string.Join(", ", ti.OriginalTrans.TransactionPeople.Select(i => i.Person.Name).ToArray());

            var pid = ti.FirstTransactionPeopleId();
            var p0 = Db.LoadPersonById(pid);
            // question: should we be sending to all TransactionPeople?
            if (sendmail)
            {
                if (p0 == null)
                    Util.SendMsg(Util.SysFromEmail, Util.Host, Util.TryGetMailAddress(Db.StaffEmailForOrg(org.OrganizationId)),
                        "Payment confirmation", $"Thank you for paying {ti.Amt:c} for {ti.Description}.<br/>Your balance is {ti.Amtdue:c}<br/>{names}",
                        Util.ToMailAddressList(Util.FirstAddress(ti.Emails)), 0, pid);
                else
                {
                    Db.Email(Db.StaffEmailForOrg(org.OrganizationId), p0, Util.ToMailAddressList(ti.Emails),
                        "Payment confirmation", $"Thank you for paying {ti.Amt:c} for {ti.Description}.<br/>Your balance is {ti.Amtdue:c}<br/>{names}", false);
                    Db.Email(p0.FromEmail,
                        Db.PeopleFromPidString(org.NotifyIds),
                        "payment received for " + ti.Description,
                        $"{Transaction.FullName(ti)} paid {ti.Amt:c} for {ti.Description}, balance of {due:c}\n({names})");
                }
            }
        }
Exemple #2
0
        public static void ConfirmDuePaidTransaction(Transaction ti, string transactionId, bool sendmail)
        {
            var db = DbUtil.Db;
            var org = db.LoadOrganizationById(ti.OrgId);
            ti.TransactionId = transactionId;
            if (ti.Testing == true && !ti.TransactionId.Contains("(testing)"))
                ti.TransactionId += "(testing)";

            var amt = ti.Amt;
            var due = PaymentForm.AmountDueTrans(db, ti);
            foreach (var pi in ti.OriginalTrans.TransactionPeople)
            {
                var p = db.LoadPersonById(pi.PeopleId);
                if (p != null)
                {
                    var om = db.OrganizationMembers.SingleOrDefault(m => m.OrganizationId == ti.OrgId && m.PeopleId == pi.PeopleId);
                    if (om == null)
                        continue;
                    db.SubmitChanges();
                    if (org.IsMissionTrip == true)
                    {
                        db.GoerSenderAmounts.InsertOnSubmit(
                            new GoerSenderAmount
                            {
                                Amount = ti.Amt,
                                GoerId = pi.PeopleId,
                                Created = DateTime.Now,
                                OrgId = org.OrganizationId,
                                SupporterId = pi.PeopleId,
                            });
                        var setting = db.CreateRegistrationSettings(org.OrganizationId);
                        var fund = setting.DonationFundId;
                        p.PostUnattendedContribution(db, ti.Amt ?? 0, fund,
                            $"SupportMissionTrip: org={org.OrganizationId}; goer={pi.PeopleId}", typecode: BundleTypeCode.Online);
                    }
                    var pay = amt;
                    if (org.IsMissionTrip == true)
                        ti.Amtdue = due;

                    var sb = new StringBuilder();
                    sb.AppendFormat("{0:g} ----------\n", Util.Now);
                    sb.AppendFormat("{0:c} ({1} id) transaction amount\n", ti.Amt, ti.Id);
                    sb.AppendFormat("{0:c} applied to this registrant\n", pay);
                    sb.AppendFormat("{0:c} total due all registrants\n", due);

                    om.AddToMemberDataBelowComments(sb.ToString());
                    var reg = p.SetRecReg();
                    reg.AddToComments(sb.ToString());
                    reg.AddToComments($"{org.OrganizationName} ({org.OrganizationId})");

                    amt -= pay;
                }
                else
                    db.Email(db.StaffEmailForOrg(org.OrganizationId),
                        db.PeopleFromPidString(org.NotifyIds),
                        "missing person on payment due",
                        $"Cannot find {pi.Person.Name} ({pi.PeopleId}), payment due completed of {pi.Amt:c} but no record");
            }
            db.SubmitChanges();

            dynamic d = new DynamicData();
            d.Name = Transaction.FullName(ti);
            d.Amt = ti.Amt;
            d.Description = ti.Description;
            d.Amtdue = PaymentForm.AmountDueTrans(db, ti);
            d.names = string.Join(", ", ti.OriginalTrans.TransactionPeople.Select(i => i.Person.Name));

            var msg = DbUtil.Db.RenderTemplate(@"
            <p>
            Thank you {{Name}}, for your payment of {{Fmt Amt 'c'}} on {{Description}}.<br/>
            {{#if Amtdue}}
            Your balance is {{Fmt Amtdue 'c'}}<br/>
            {{/if}}
            {{names}}
            </p>", d);
            var msgstaff = DbUtil.Db.RenderTemplate(@"
            <p>
            {{Name}} paid {{Fmt Amt 'c'}} on {{Description}}.<br/>
            {{#if Amtdue}}
            The balance is {{Fmt Amtdue 'c'}}<br/>
            {{/if}}
            {{names}}
            </p>", d);

            var pid = ti.FirstTransactionPeopleId();
            var p0 = db.LoadPersonById(pid);
            // question: should we be sending to all TransactionPeople?
            if (sendmail)
            {
                if (p0 == null)
                    db.SendEmail(Util.TryGetMailAddress(db.StaffEmailForOrg(org.OrganizationId)),
                        "Payment confirmation", msg, Util.ToMailAddressList(Util.FirstAddress(ti.Emails)), pid: pid).Wait();
                else
                {
                    db.Email(db.StaffEmailForOrg(org.OrganizationId), p0, Util.ToMailAddressList(ti.Emails),
                        "Payment confirmation", msg, false);
                    db.Email(p0.FromEmail, db.PeopleFromPidString(org.NotifyIds),
                        "payment received for " + ti.Description, msgstaff);
                }
            }
        }
Exemple #3
0
        public void ConfirmDuePaidTransaction(Transaction ti, string TransactionID, bool sendmail)
        {
            var Db = DbUtil.Db;
            var org = Db.LoadOrganizationById(ti.OrgId);
            ti.TransactionId = TransactionID;
            if (ti.Testing == true)
                ti.TransactionId += "(testing)";

            var amt = ti.Amt;
            foreach (var pi in ti.OriginalTransaction.TransactionPeople)
            {
                var p = Db.LoadPersonById(pi.PeopleId);
                if (p != null)
                {
                    var om = Db.OrganizationMembers.SingleOrDefault(m => m.OrganizationId == ti.OrgId && m.PeopleId == pi.PeopleId);
                    if (om == null)
                        continue;
                    var pay = amt;
                    if (org.IsMissionTrip == true)
                    {
                        Db.ExecuteCommand(@"
            INSERT dbo.GoerSenderAmounts ( OrgId , SupporterId , GoerId , Amount , Created ) VALUES  ( {0}, {1}, {1}, {2}, {3} )",
                             org.OrganizationId, p.PeopleId, pay, DateTime.Now);
                    }
                    else
                    {
                        var due = om.Amount - om.TotalPaid(Db);
                        if (pay > due)
                            pay = due;
                        //om.AmountPaid += pay;
                    }

                    var sb = new StringBuilder();
                    sb.AppendFormat("{0:g} ----------\n", Util.Now);
                    sb.AppendFormat("{0:c} ({1} id) transaction amount\n", ti.Amt, ti.Id);
                    sb.AppendFormat("{0:c} applied to this registrant\n", pay);
                    sb.AppendFormat("{0:c} total due all registrants\n", ti.Amtdue);

                    om.AddToMemberData(sb.ToString());
                    var reg = p.RecRegs.Single();
                    reg.AddToComments(sb.ToString());
                    reg.AddToComments("{0} ({1})".Fmt(org.OrganizationName, org.OrganizationId));

                    amt -= pay;
                }
                else
                    Db.Email(Db.StaffEmailForOrg(org.OrganizationId),
                        Db.PeopleFromPidString(org.NotifyIds),
                        "missing person on payment due",
                        "Cannot find {0} ({1}), payment due completed of {2:c} but no record".Fmt(pi.Person.Name, pi.PeopleId, pi.Amt));
            }
            Db.SubmitChanges();
            var names = string.Join(", ", ti.OriginalTransaction.TransactionPeople.Select(i => i.Person.Name).ToArray());

            var pid = ti.FirstTransactionPeopleId();
            var p0 = Db.LoadPersonById(pid);
            //todo: should we be sending to all TransactionPeople?
            if (sendmail)
            {
                if (p0 == null)
                    Util.SendMsg(Util.SysFromEmail, Util.Host, Util.TryGetMailAddress(Db.StaffEmailForOrg(org.OrganizationId)),
                        "Payment confirmation", "Thank you for paying {0:c} for {1}.<br/>Your balance is {2:c}<br/>{3}".Fmt(ti.Amt, ti.Description, ti.Amtdue, names), Util.ToMailAddressList(Util.FirstAddress(ti.Emails)), 0, pid);
                else
                {
                    Db.Email(Db.StaffEmailForOrg(org.OrganizationId),
                        p0, Util.ToMailAddressList(ti.Emails), "Payment confirmation", "Thank you for paying {0:c} for {1}.<br/>Your balance is {2:c}<br/>{3}".Fmt(ti.Amt, ti.Description, ti.Amtdue, names), false);
                    Db.Email(p0.FromEmail,
                        Db.PeopleFromPidString(org.NotifyIds),
                        "payment received for " + ti.Description,
                        "{0} paid {1:c} for {2}, balance of {3:c}\n({4})".Fmt(
                            Transaction.FullName(ti), ti.Amt, ti.Description, ti.Amtdue, names));
                }
            }
        }