How Customer Defaults and Validation Works
Source: `customer.rb`, `customers_controller.rb`
- New customers default to Cash (type "C") for payment terms and Company type ("C") for customer type
- Customer type "C" (Company) requires
company_nameto be present; type "I" (Individual) requires BOTHfirst_nameANDlast_name - Display name logic: Company type shows
company_name; Individual type shows "first last"; the sort name for Individual is "last, first" - The default contact method for a new customer inherits from the company-level setting; if the company has no setting, it falls back to EMAIL
- Setting a biller on a customer silently forces
cash_or_accountto Account -- no validation error is raised, the value is just overridden - If the price type field is set to a value longer than 1 character, the system interprets it as a price matrix assignment and overrides the type to "5"
- Name field length limits: first_name and last_name max 50 characters, company_name max 100 characters; address suburb max 30 characters
- Customer name uniqueness checking is case-insensitive (uses ILIKE), so "Smith Motors" and "SMITH MOTORS" are considered duplicates
Support scenarios
- "I created a customer but it says the name already exists" → Name uniqueness is case-insensitive. A customer with the same name in different casing already exists. Search using the include_archived scope to check for archived duplicates too.
- "My customer's payment type keeps changing to Account" → If a biller is assigned to the customer, the system silently forces the payment type to Account. Remove the biller if the customer should be Cash.
- "I can't save this individual customer" → Individual customers require both first_name and last_name. Check that both fields are filled in.
- "The customer's price type changed to 5 and I didn't set that" → A price type value longer than 1 character triggers price matrix assignment, which overrides the type to "5". Check what was entered in the price type field.