Customer Management Guidelines
Since customers management have been through several phases in siwapp, the end result is kind of a mixture between two approaches. We believe it's "the best of both worlds" (Hanna Montana Dixit).
The "name slug"
Internally, each customer object has a "name_slug" field. the "name_slug" is a compacted version of the name, without spaces and tricky characters. This way:
- "Smith and Co." would produce the "smithandco" name_slug
- "Smith and !Co" will also produce the same "smithandco" name_slug
Database restrictions
The customer's name has to be unique. You can not have two customers with the same name.
Attention The customer's name_slug has to be unique, also, but -since you're not seeing it directly- , the error message in case you are "duplicating" a customer's name_slug will be that your customer's name is "too close" to one already existing in the db. This means that the customer's name you're trying to add generates a slug that already exists in the db. In that case, you should try to slightly modify your customer's name, so it generates a different slug.
Invoice Editing
When editing/creating an Invoice, when you start typing in the "customer's name" input, the system will show you possible matches within its database, if you choose one of them, the system will automatically fill the other customer inputs, and will associate the invoice being created/edited with that customer.
If you modify some way the customer's name, the system will try to find a customer in the db that has that same name (or a very similar one -in the "name_slug" sense-, and if it can finds it, it will re-establish a link between the invoice being edited and the found customer object. If the system can't find it, then it will create a new customer for the occasion.
All the other editing on the invoice customer's fields doesn't go on the customers "permanent record" any other thing customer-related that you may edit afterwards, will keep -of course- in the invoice you're editing them at, but will not go to the associated customers object. So, say:
- You create a customer A: as previously discussed, you can do this either by going to the customer's tab and clicking on "new customer", or simply by using a brand new customer's name in an invoice edition/creation page.
- You associate this customer A to an invoice: as previously discussed, you can do this on one step (by creating an invoice in which customer's name input there is a brand new customer name), or in two, (by creating the customer, then creating an invoice, and -when typing the customer's name- choosing the customer 'A' from those the system is offering).
- Afterwards:
- If you change the customer name for another one of the ones offered by the system, the invoice will be related to the customer described by that changed name. All customer's fields will be updated with that recently chosen customer's data. You may then save your invoice with your new customers details, or edit them a little more. The customer relationship with the invoice is determined by the customer's name, all the other fields doesn't matter
- If you change any other customer's data, those changes will not go to the customer table, but will remain in that particular invoice you're editing them at. The relationship remains the same. If your customers module is disabled, then the associated customer object is changed accordingly to the new data inputed at the invoice's customer fields
- If you make up a complete new customer's name, a new customer object will be created, and the invoice will be associated to it

