| ... | ... | @@ -12,7 +12,7 @@ This means that we added plugins to the general queries and transitions, to make |
|
|
|
|
|
|
|
## Customers - Clients vs Companies
|
|
|
|
|
|
|
|
All customers are in **core.customer**. The "is_private" flag distinguishes actual people ("client") from companies. Storing them both in the same entity allows us to use either as an owner of a vehicle without any further adaptations.
|
|
|
|
All customers are in **core.customer**. The "is_client" flag distinguishes actual people ("client") from companies. Storing them both in the same entity allows us to use either as an owner of a vehicle without any further adaptations.
|
|
|
|
|
|
|
|
Clients have an attribute "owning_client" (refers **system.client**, where lots of attributes [i.e. first name, last name] are stored) and can log in with their email address. A user may belong to one or more companies.
|
|
|
|
|
| ... | ... | @@ -25,7 +25,7 @@ Companies do not have an "owning_client" and cannot log in. Any client belonging |
|
|
|
|
|
|
|
#POST /data/core/customer/query
|
|
|
|
{
|
|
|
|
"conds" : {"me.is_private" : 1}
|
|
|
|
"conds" : {"me.is_client" : 1}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
| ... | ... | @@ -37,7 +37,7 @@ additional attributes are stored and can be joined to the entry in core.customer |
|
|
|
|
|
|
|
#POST /data/core/customer/query
|
|
|
|
{
|
|
|
|
"conds" : {"me.is_private" : 1},
|
|
|
|
"conds" : {"me.is_client" : 1},
|
|
|
|
"attrs": {"prefetch" : "owning_client"}
|
|
|
|
}
|
|
|
|
```
|
| ... | ... | @@ -50,7 +50,7 @@ Companies can be retrieved with the equivalent query: |
|
|
|
|
|
|
|
#POST /data/core/customer/query
|
|
|
|
{
|
|
|
|
"conds" : {"me.is_private" : 0}
|
|
|
|
"conds" : {"me.is_client" : 0}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
| ... | ... | @@ -197,7 +197,7 @@ The IDs necessary here are die "id" attributes in core.customer. |
|
|
|
```
|
|
|
|
### List Client Companies
|
|
|
|
|
|
|
|
To list all companies a client is assigned to - get those entries from core.customers which are assigned to the client (5 = system.client.id = core.customer.owning_client) and which are labeled as companies (is_private = false).
|
|
|
|
To list all companies a client is assigned to - get those entries from core.customers which are assigned to the client (5 = system.client.id = core.customer.owning_client) and which are labeled as companies (is_client = false).
|
|
|
|
```
|
|
|
|
#!json
|
|
|
|
|
| ... | ... | @@ -206,7 +206,7 @@ To list all companies a client is assigned to - get those entries from core.cust |
|
|
|
{
|
|
|
|
"conds": {
|
|
|
|
"assignment__core_customer__binding_instance_of_customer.assigned_client" : 5,
|
|
|
|
"me.is_private" : false
|
|
|
|
"me.is_client" : false
|
|
|
|
},
|
|
|
|
"attrs" : {"join":"assignment__core_customer__binding_instance_of_customer"}
|
|
|
|
}
|
| ... | ... | @@ -234,7 +234,7 @@ To list all clients assigned to a company, join system.client via owning_client |
|
|
|
{
|
|
|
|
"conds": {
|
|
|
|
"assignment__core_customer__assigned_client.binding_instance_of_customer" : 4,
|
|
|
|
"me.is_private" : true
|
|
|
|
"me.is_client" : true
|
|
|
|
},
|
|
|
|
"attrs" : {
|
|
|
|
"prefetch" : "owning_client",
|
| ... | ... | |