public void PayInvoice(DojoSeminarRegistration registration, RHCustomer customer, decimal amount, string reference) { RHReceivePayment payment = new RHReceivePayment(); payment.Account = registration.ParentSeminar.Item.SalesIncomeAccount; payment.Customer = customer; payment.Invoice1 = registration.InvoiceLine.Invoice; payment.IsAutomatic = false; payment.ReferenceNumber = reference; payment.TotalAmount = amount; payment.Save(); registration.InvoiceLine.Invoice.AppliedAmount += payment.TotalAmount; registration.InvoiceLine.Invoice.Save(); }
protected void ok_Click(object sender, EventArgs e) { if (dojoSeminarRegistrationID == 0) { obj = new DojoSeminarRegistration(); } else { obj = new DojoSeminarRegistration(dojoSeminarRegistrationID); } obj.Status = byte.Parse(tbStatus.Text); obj.RegistrationDate = deRegistrationDate.Date; obj.ClassUnits = int.Parse(tbClassUnits.Text); obj.TotalFee = decimal.Parse(tbTotalFee.Text); obj.PaymentDate = dePaymentDate.Date; obj.PaymentReference = tbPaymentReference.Text; obj.PaymentAmount = decimal.Parse(tbPaymentAmount.Text); if (msContact.SelectedItem != null && msContact.SelectedItem.Value != "Null") { obj.Contact = GreyFoxContact.NewPlaceHolder("kitTessen_SeminarRegistrations_Contacts", int.Parse(msContact.SelectedItem.Value)); } else { obj.Contact = null; } if (msCustomer.SelectedItem != null && msCustomer.SelectedItem.Value != "Null") { obj.Customer = RHCustomer.NewPlaceHolder( int.Parse(msCustomer.SelectedItem.Value)); } else { obj.Customer = null; } if (msInvoiceLine.SelectedItem != null && msInvoiceLine.SelectedItem.Value != "Null") { obj.InvoiceLine = RHInvoiceLine.NewPlaceHolder( int.Parse(msInvoiceLine.SelectedItem.Value)); } else { obj.InvoiceLine = null; } if (msSalesOrderLine.SelectedItem != null && msSalesOrderLine.SelectedItem.Value != "Null") { obj.SalesOrderLine = RHSalesOrderLine.NewPlaceHolder( int.Parse(msSalesOrderLine.SelectedItem.Value)); } else { obj.SalesOrderLine = null; } if (editOnAdd) { dojoSeminarRegistrationID = obj.Save(); } else { obj.Save(); } if (resetOnAdd) { tbStatus.Text = string.Empty; deRegistrationDate.Date = DateTime.Now; tbClassUnits.Text = string.Empty; tbTotalFee.Text = string.Empty; dePaymentDate.Date = DateTime.Now; tbPaymentReference.Text = string.Empty; tbPaymentAmount.Text = string.Empty; msContact.SelectedIndex = 0; msCustomer.SelectedIndex = 0; msInvoiceLine.SelectedIndex = 0; msSalesOrderLine.SelectedIndex = 0; } OnUpdated(EventArgs.Empty); }
protected void ok_Click(object sender, EventArgs e) { if (dojoMemberID == 0) { obj = new DojoMember(); } else { obj = new DojoMember(dojoMemberID); } obj.MemberSince = deMemberSince.Date; obj.IsPrimaryOrgActive = cbIsPrimaryOrgActive.Checked; obj.IsParentOrgActive = cbIsParentOrgActive.Checked; obj.LastMembershipScan = DateTime.Parse(tbLastMembershipScan.Text); obj.AttendanceMessage = tbAttendanceMessage.Text; obj.HasWaiver = cbHasWaiver.Checked; obj.IsPromotable = cbIsPromotable.Checked; obj.IsInstructor = cbIsInstructor.Checked; obj.RankDate = deRankDate.Date; obj.IsPastDue = cbIsPastDue.Checked; if (msMemberType.SelectedItem != null && msMemberType.SelectedItem.Value != "Null") { obj.MemberType = DojoMemberType.NewPlaceHolder( int.Parse(msMemberType.SelectedItem.Value)); } else { obj.MemberType = null; } if (msPublicContact.SelectedItem != null && msPublicContact.SelectedItem.Value != "Null") { obj.PublicContact = GreyFoxContact.NewPlaceHolder("kitTessen_Members_PublicContacts", int.Parse(msPublicContact.SelectedItem.Value)); } else { obj.PublicContact = null; } if (msParentMember.SelectedItem != null && msParentMember.SelectedItem.Value != "Null") { obj.ParentMember = DojoMember.NewPlaceHolder( int.Parse(msParentMember.SelectedItem.Value)); } else { obj.ParentMember = null; } if (msPrimaryOrgMembership.SelectedItem != null && msPrimaryOrgMembership.SelectedItem.Value != "Null") { obj.PrimaryOrgMembership = DojoMembership.NewPlaceHolder( int.Parse(msPrimaryOrgMembership.SelectedItem.Value)); } else { obj.PrimaryOrgMembership = null; } if (msParentOrgMembership.SelectedItem != null && msParentOrgMembership.SelectedItem.Value != "Null") { obj.ParentOrgMembership = DojoMembership.NewPlaceHolder( int.Parse(msParentOrgMembership.SelectedItem.Value)); } else { obj.ParentOrgMembership = null; } if (msInstructor1.SelectedItem != null && msInstructor1.SelectedItem.Value != "Null") { obj.Instructor1 = DojoMember.NewPlaceHolder( int.Parse(msInstructor1.SelectedItem.Value)); } else { obj.Instructor1 = null; } if (msInstructor2.SelectedItem != null && msInstructor2.SelectedItem.Value != "Null") { obj.Instructor2 = DojoMember.NewPlaceHolder( int.Parse(msInstructor2.SelectedItem.Value)); } else { obj.Instructor2 = null; } if (msInstructor3.SelectedItem != null && msInstructor3.SelectedItem.Value != "Null") { obj.Instructor3 = DojoMember.NewPlaceHolder( int.Parse(msInstructor3.SelectedItem.Value)); } else { obj.Instructor3 = null; } if (msPromotionFlags.IsChanged) { obj.PromotionFlags = new DojoPromotionFlagCollection(); foreach (ListItem i in msPromotionFlags.Items) { if (i.Selected) { obj.PromotionFlags.Add(DojoPromotionFlag.NewPlaceHolder(int.Parse(i.Value))); } } } if (msRank.SelectedItem != null && msRank.SelectedItem.Value != "Null") { obj.Rank = DojoRank.NewPlaceHolder( int.Parse(msRank.SelectedItem.Value)); } else { obj.Rank = null; } if (msCustomer.SelectedItem != null && msCustomer.SelectedItem.Value != "Null") { obj.Customer = RHCustomer.NewPlaceHolder( int.Parse(msCustomer.SelectedItem.Value)); } else { obj.Customer = null; } if (editOnAdd) { dojoMemberID = obj.Save(); } else { obj.Save(); } if (resetOnAdd) { deMemberSince.Date = DateTime.Now; cbIsPrimaryOrgActive.Checked = false; cbIsParentOrgActive.Checked = false; tbLastMembershipScan.Text = DateTime.Now.ToString(); tbAttendanceMessage.Text = string.Empty; cbHasWaiver.Checked = false; cbIsPromotable.Checked = false; cbIsInstructor.Checked = false; deRankDate.Date = DateTime.Now; cbIsPastDue.Checked = false; msMemberType.SelectedIndex = 0; msPublicContact.SelectedIndex = 0; msParentMember.SelectedIndex = 0; msPrimaryOrgMembership.SelectedIndex = 0; msParentOrgMembership.SelectedIndex = 0; msInstructor1.SelectedIndex = 0; msInstructor2.SelectedIndex = 0; msInstructor3.SelectedIndex = 0; msRank.SelectedIndex = 0; msCustomer.SelectedIndex = 0; } OnUpdated(EventArgs.Empty); }
public static RHCustomer Customer(DojoMember member) { RHCustomer customer = RHFactory.Customer(member.UserAccount); return(customer); }
public void CreateInvoice(DojoSeminarRegistration registration, RHCustomer customer) { DojoSeminar seminar = registration.ParentSeminar; // Create Invoice and set the duedate according to the seminar // registration settings. RHInvoice invoice = new RHInvoice(); invoice.Customer = customer; if (seminar.EarlyEndDate > DateTime.Now) { invoice.DueDate = seminar.EarlyEndDate; } else if (seminar.EndDate > DateTime.Now) { invoice.DueDate = seminar.LateStartDate; } else { invoice.DueDate = seminar.StartDate; } invoice.FOB = seminar.Location.BusinessName; invoice.ReceivableAccount = seminar.Item.SalesIncomeAccount; invoice.BillingContact = new GreyFoxContact(RHInvoiceManager.BillingContactTable); invoice.BillingContact.Prefix = customer.PrivateContact.Prefix; invoice.BillingContact.FirstName = customer.PrivateContact.FirstName; invoice.BillingContact.MiddleName = customer.PrivateContact.MiddleName; invoice.BillingContact.LastName = customer.PrivateContact.LastName; invoice.BillingContact.Suffix = customer.PrivateContact.Suffix; invoice.BillingContact.Address1 = customer.PrivateContact.Address1; invoice.BillingContact.Address2 = customer.PrivateContact.Address2; invoice.BillingContact.City = customer.PrivateContact.City; invoice.BillingContact.StateProvince = customer.PrivateContact.StateProvince; invoice.BillingContact.PostalCode = customer.PrivateContact.PostalCode; invoice.BillingContact.Country = customer.PrivateContact.Country; invoice.ShipContact = new GreyFoxContact(RHInvoiceManager.ShipContactTable); invoice.ShipContact.Prefix = registration.Contact.Prefix; invoice.ShipContact.FirstName = registration.Contact.FirstName; invoice.ShipContact.MiddleName = registration.Contact.MiddleName; invoice.ShipContact.LastName = registration.Contact.LastName; invoice.ShipContact.Suffix = registration.Contact.Suffix; invoice.ShipContact.Address1 = registration.Contact.Address1; invoice.ShipContact.Address2 = registration.Contact.Address2; invoice.ShipContact.City = registration.Contact.City; invoice.ShipContact.StateProvince = registration.Contact.StateProvince; invoice.ShipContact.PostalCode = registration.Contact.PostalCode; invoice.ShipContact.Country = registration.Contact.Country; invoice.Subtotal = registration.TotalFee; // TODO: Handle Taxes invoice.BalanceRemaining = registration.TotalFee; invoice.Save(); // Create Invoice Line RHInvoiceLine line = new RHInvoiceLine(); line.Invoice = invoice; line.Description = "Seminar Registration - " + seminar.Name + "\r\n"; line.Item = seminar.Item; line.OrderNum = 1; line.Quantity = 1; line.Amount = registration.TotalFee; line.Rate = registration.TotalFee; line.Save(); registration.InvoiceLine = line; registration.Save(); }
/// <summary> /// /// </summary> /// <param name="member">Member to sync.</param> /// <param name="customer">Customer to sync.</param> /// <param name="forceSync"></param> public void SyncItem(DojoMember member, RHCustomer customer) { if (member.Customer == null) { if (member.PrivateContact.FirstName == customer.PrivateContact.FirstName & member.PrivateContact.LastName == customer.PrivateContact.LastName & member.PrivateContact.MiddleName == customer.PrivateContact.MiddleName) { member.Customer = customer; if (member.ModifyDate > customer.ModifyDate) { if (customer.PrivateContact == null) { customer.PrivateContact = new GreyFoxContact(RHCustomerManager.PrivateContactTable); } customer.PrivateContact.DisplayName = member.PrivateContact.ConstructName("L S, F Mi."); customer.PrivateContact.Prefix = member.PrivateContact.Prefix; customer.PrivateContact.FirstName = member.PrivateContact.FirstName; customer.PrivateContact.MiddleName = member.PrivateContact.MiddleName; customer.PrivateContact.LastName = member.PrivateContact.LastName; customer.PrivateContact.Suffix = member.PrivateContact.Suffix; customer.PrivateContact.SuffixCommaEnabled = member.PrivateContact.SuffixCommaEnabled; customer.PrivateContact.HomePhone = member.PrivateContact.HomePhone; customer.PrivateContact.WorkPhone = member.PrivateContact.WorkPhone; customer.PrivateContact.MobilePhone = member.PrivateContact.MobilePhone; customer.PrivateContact.Email1 = member.PrivateContact.Email1; customer.PrivateContact.Url = member.PrivateContact.Url; customer.PrivateContact.BusinessName = member.PrivateContact.BusinessName; customer.PrivateContact.BirthDate = member.PrivateContact.BirthDate; customer.PrivateContact.Address1 = member.PrivateContact.Address1; customer.PrivateContact.Address2 = member.PrivateContact.Address2; customer.PrivateContact.City = member.PrivateContact.City; customer.PrivateContact.StateProvince = member.PrivateContact.StateProvince; customer.PrivateContact.PostalCode = member.PrivateContact.PostalCode; customer.PrivateContact.Country = member.PrivateContact.Country; if (!customer.PrivateContact.IsSynced) { customer.IsSynced = false; } customer.PrivateContact.Save(); customer.Save(); } else { } } } }
/// <summary> /// Syncs the Members List to the Customer List. If a Member does not /// have an associated Customer, the Customer List is checked for an /// existing customer with the same name. If a matching customer is not /// found, a new customer is created. /// </summary> /// <param name="forceSync"></param> public void SyncCustomers() { DojoMemberCollection members; RHCustomerCollection customers; bool addCustomer; bool skipChildren; members = new DojoMemberManager().GetCollection(string.Empty, string.Empty, DojoMemberFlags.PrivateContact); customers = new RHCustomerManager().GetCollection(string.Empty, string.Empty, RHCustomerFlags.PrivateContact, RHCustomerFlags.BillingContact, RHCustomerFlags.ShippingContact); skipChildren = customerExportMode == RHCustomerExportMode.ExportParentsOnly; foreach (DojoMember member in members) { if (skipChildren && member.Parent != null) { continue; } // Reset addcustomer flag to keep track of customers // that need to be added. addCustomer = true; foreach (RHCustomer customer in customers) { if (member.Customer == null) { if (member.PrivateContact.FirstName == customer.PrivateContact.FirstName & member.PrivateContact.LastName == customer.PrivateContact.LastName & member.PrivateContact.MiddleName == customer.PrivateContact.MiddleName) { member.Customer = customer; } } if (member.Customer.ID == customer.ID) { SyncItem(member, customer); addCustomer = false; break; } } if (addCustomer) { RHCustomer newCustomer = new RHCustomer(); newCustomer.PrivateContact = new GreyFoxContact(RHCustomerManager.PrivateContactTable); newCustomer.BillingContact = new GreyFoxContact(RHCustomerManager.BillingContactTable); newCustomer.ShippingContact = new GreyFoxContact(RHCustomerManager.ShippingContactTable); member.PrivateContact.CopyValuesTo(newCustomer.PrivateContact, false); member.PrivateContact.CopyValuesTo(newCustomer.BillingContact, false); member.PrivateContact.CopyValuesTo(newCustomer.ShippingContact, false); newCustomer.PrivateContact.Save(); newCustomer.BillingContact.Save(); newCustomer.ShippingContact.Save(); newCustomer.Save(); } } }