Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 6f3d86d

Browse files
authored
GraphQL: Add company credit coverage (#8305)
* GraphQL: Add company credit coverage * Add example
1 parent 39f0d89 commit 6f3d86d

File tree

2 files changed

+269
-18
lines changed

2 files changed

+269
-18
lines changed

src/_includes/graphql/company.md

Lines changed: 93 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,29 @@ The `Company` object can contain the following attributes:
22

33
Attribute | Data type | Description
44
--- | --- | ---
5-
`acl_resources` [CompanyAclResource] | Returns the list of all resources defined within the company
5+
`acl_resources` | [[CompanyAclResource]](#CompanyAclResource) | Returns the list of all resources defined within the company
66
`company_admin` | [Customer]({{page.baseurl}}/graphql/queries/customer.html) | An object containing information about the company administrator
7+
`credit` | CompanyCredit! | The company credit balance
8+
`credit_history(filter: CompanyCreditHistoryFilterInput, pageSize: Int = 20, currentPage: Int = 1)` | CompanyCreditHistory! | A history of company credit operations
79
`email` | String | The email address of the company contact
810
`id` | ID! | The ID assigned to the company
9-
`legal_address` | CompanyLegalAddress | The address where the company is registered to conduct business
11+
`legal_address` | [CompanyLegalAddress](#CompanyLegalAddress) | The address where the company is registered to conduct business
1012
`legal_name` | String | The full legal name of the company
1113
`name` | String | The name of the company
12-
`payment_methods` | [String] The list of payment methods available to a company
14+
`payment_methods` | [String] | The list of payment methods available to a company
1315
`reseller_id` | String | The resale number that is assigned to the company for tax reporting purposes
14-
`role(id: ID!)` | CompanyRole | Returns information about the specified company role
15-
`roles(pageSize: Int = 20, currentPage: Int = 1 )` | CompanyRoles! | Returns the list of company roles
16-
`sales_representative` | CompanySalesRepresentative | The company sales representative
17-
`structure(rootId: ID = 0 depth: Int = 10 )` | CompanyStructure | Returns the company structure of teams and customers in depth-first order
18-
`team(id: ID!)` | CompanyTeam | Returns the specified company team
19-
`user(id: ID!)` | Customer | Returns the specified company user
20-
`users(filter: CompanyUsersFilterInput, pageSize: Int = 20, currentPage: Int = 1)`| CompanyUsers | Returns the company users that match the specified filter
21-
`vat_tax_id` | String | The value-added tax number that is assigned to the company by some jurisdictions for tax reporting purposes
16+
`role(id: ID!)` | [CompanyRole](#CompanyRole) | Returns information about the specified company role
17+
`roles(pageSize: Int = 20, currentPage: Int = 1 )` | [CompanyRoles!](#CompanyRoles) | Returns the list of company roles
18+
`sales_representative` | [CompanySalesRepresentative](#CompanySalesRepresentative) | The company sales representative
19+
`structure(rootId: ID = 0 depth: Int = 10 )` | [CompanyStructure](#CompanyStructure) | Returns the company structure of teams and customers in depth-first order
20+
`team(id: ID!)` | [CompanyTeam](#CompanyTeam) | Returns the specified company team
21+
`user(id: ID!)` | [Customer]({{page.baseurl}}/graphql/queries/customer.html) | Returns the specified company user
22+
`users(filter: CompanyUsersFilterInput, pageSize: Int = 20, currentPage: Int = 1)`| [CompanyUsers](#CompanyUsers) | Returns the company users that match the specified filter
23+
`vat_id` | String | The value-added tax number that is assigned to the company by some jurisdictions for tax reporting purposes
2224

2325
### CompanyAclResource attributes {#CompanyAclResource}
2426

25-
The `CompanyAclResource` object can contain the following attributes:
27+
The `CompanyAclResource` object can contain the following attributes.
2628

2729
Attribute | Data Type | Description
2830
--- | --- | ---
@@ -33,7 +35,7 @@ Attribute | Data Type | Description
3335

3436
### CompanyAdmin attributes {#CompanyAdmin}
3537

36-
The `CompanyAdmin` object can contain the following attributes:
38+
The `CompanyAdmin` object can contain the following attributes.
3739

3840
Attribute | Data Type | Description
3941
--- | --- | ---
@@ -44,9 +46,61 @@ Attribute | Data Type | Description
4446
`job_title` | String | The job title of the company administrator
4547
`lastname` | String! | The company administrator's last name
4648

49+
### CompanyCredit {#CompanyCredit}
50+
51+
The `CompanyCredit` object can contain the following attributes.
52+
53+
Attribute | Data Type | Description
54+
--- | --- | ---
55+
`available_credit` | Money! | The amount of company credit available
56+
`credit_limit` | Money! | The company's credit limit
57+
`outstanding_balance` | Money! | The outstanding company credit amount
58+
59+
### CompanyCreditHistory attributes {#CompanyCreditHistory}
60+
61+
The `CompanyCreditHistory` object can contain the following attributes.
62+
63+
Attribute | Data Type | Description
64+
--- | --- | ---
65+
`items` | [[CompanyCreditOperation]!](#CompanyCreditOperation) | An array of company credit operations
66+
`page_info` | SearchResultPageInfo! | Metadata for pagination rendering
67+
`total_count` | Int | The number of the company credit operations matching the specified filter
68+
69+
### CompanyCreditHistoryFilterInput attributes {#CompanyCreditHistoryFilterInput}
70+
71+
The `CompanyCreditHistoryFilterInput` object can contain the following attributes.
72+
73+
Attribute | Data Type | Description
74+
--- | --- | ---
75+
`custom_reference_number` | String | Filters by the purchase order number associated with the company credit operation
76+
`operation_type` | CompanyCreditOperationType | An enum that defines the type of the company credit operation. Possible values are ADMIN and CUSTOMER
77+
`updated_by` | String | Filters by the name of the person submitting the company credit operation
78+
79+
### CompanyCreditOperation attributes {#CompanyCreditOperation}
80+
81+
The `CompanyCreditOperation` object can contain the following attributes.
82+
83+
Attribute | Data Type | Description
84+
--- | --- | ---
85+
`amount` | Money | The amount of the company credit operation
86+
`balance` | [CompanyCredit!](#CompanyCredit) | The credit balance after the company credit operation
87+
`custom_reference_number` | String | The purchase order number associated with the company credit operation
88+
`date` | String! | The date the operation was performed
89+
`type` | CompanyCreditOperationType! | The type of the company credit operation. Possible values are ALLOCATION, PURCHASE, REFUND, REIMBURSEMENT, REVERT, UPDATE
90+
`updated_by` | [CompanyCreditOperationUser!](#CompanyCreditOperationUser) | The company user submitting the company credit operation
91+
92+
### CompanyCreditOperationUser attributes {#CompanyCreditOperationUser}
93+
94+
The `CompanyCreditOperationUser` object can contain the following attributes.
95+
96+
Attribute | Data Type | Description
97+
--- | --- | ---
98+
`name` | String! | The name of the company user submitting the company credit operation
99+
`type` | CompanyCreditOperationUserType! | The type of the company user submitting the company credit operation. Possible values are ADMIN and CUSTOMER
100+
47101
### CompanyLegalAddress attributes {#CompanyLegalAddress}
48102

49-
The `CompanyLegalAddress` object can contain the following attributes:
103+
The `CompanyLegalAddress` object can contain the following attributes.
50104

51105
Attribute | Data Type | Description
52106
--- | --- | ---
@@ -59,7 +113,7 @@ Attribute | Data Type | Description
59113

60114
### CompanyRole attributes {#CompanyRole}
61115

62-
The `CompanyRole` object can contain the following attributes:
116+
The `CompanyRole` object can contain the following attributes.
63117

64118
Attribute | Data Type | Description
65119
--- | --- | ---
@@ -70,7 +124,7 @@ Attribute | Data Type | Description
70124

71125
### CompanyRoles attributes {#CompanyRoles}
72126

73-
The `CompanyRoles` object can contain the following attributes:
127+
The `CompanyRoles` object can contain the following attributes.
74128

75129
Attribute | Data Type | Description
76130
--- | --- | ---
@@ -80,17 +134,38 @@ Attribute | Data Type | Description
80134

81135
### CompanySalesRepresentative attributes {#CompanySalesRepresentative}
82136

83-
The `CompanySalesRepresentative` object can contain the following attributes:
137+
The `CompanySalesRepresentative` object can contain the following attributes.
84138

85139
Attribute | Data Type | Description
86140
--- | --- | ---
87141
`email` | String! | The email address of the company sales representative
88142
`firstname` | String! | The company sales representative's first name
89143
`lastname` | String! | The company sales representative's last name
90144

145+
### CompanyStructure attributes {#CompanyStructure}
146+
147+
The `CompanyStructure` object can contain the following attribute.
148+
149+
Attribute | Data Type | Description
150+
--- | --- | ---
151+
`items` | [CompanyStructureItem] | An array of elements in a company structure
152+
153+
### CompanyStructureItem attributes {#CompanyStructureItem}
154+
155+
The `CompanyStructureItem` object can contain the following attributes.
156+
157+
Attribute | Data Type | Description
158+
--- | --- | ---
159+
`entity` | CompanyStructureEntity | A union of [CompanyTeam](#CompanyTeam) and [Customer]({{page.baseurl}}/graphql/queries/customer.html) objects
160+
`id` | ID! | The ID of the item in the hierarchy
161+
`parent_id` | ID | The ID of the parent item in the hierarchy
162+
163+
### CompanyTeam attributes {#CompanyTeam}
164+
165+
{% include graphql/company-team.md %}
91166
### CompanyUsers attributes {#CompanyUsers}
92167

93-
The `CompanyUsers` object can contain the following attributes:
168+
The `CompanyUsers` object can contain the following attributes.
94169

95170
Attribute | Data Type | Description
96171
--- | --- | ---

src/guides/v2.4/graphql/queries/company.md

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,182 @@ query{
187187
}
188188
```
189189

190+
### Return the company credit history
191+
192+
The following query returns a company's current company credit balance as well as a record of all company credit events.
193+
194+
**Request:**
195+
196+
```graphql
197+
query{
198+
company{
199+
name
200+
id
201+
credit {
202+
available_credit {
203+
value
204+
currency
205+
}
206+
credit_limit {
207+
value
208+
currency
209+
}
210+
outstanding_balance {
211+
value
212+
currency
213+
}
214+
}
215+
credit_history{
216+
items {
217+
date
218+
type
219+
amount {
220+
value
221+
currency
222+
}
223+
balance {
224+
outstanding_balance {
225+
value
226+
currency
227+
}
228+
available_credit {
229+
value
230+
currency
231+
}
232+
credit_limit {
233+
value
234+
currency
235+
}
236+
}
237+
}
238+
}
239+
240+
payment_methods
241+
242+
}
243+
}
244+
```
245+
246+
**Response:**
247+
248+
```json
249+
{
250+
"data": {
251+
"company": {
252+
"name": "TestCo",
253+
"id": "MQ==",
254+
"credit": {
255+
"available_credit": {
256+
"value": 436,
257+
"currency": "USD"
258+
},
259+
"credit_limit": {
260+
"value": 500,
261+
"currency": "USD"
262+
},
263+
"outstanding_balance": {
264+
"value": -64,
265+
"currency": "USD"
266+
}
267+
},
268+
"credit_history": {
269+
"items": [
270+
{
271+
"date": "2020-12-02 16:38:11",
272+
"type": "ALLOCATION",
273+
"amount": {
274+
"value": 0,
275+
"currency": "USD"
276+
},
277+
"balance": {
278+
"outstanding_balance": {
279+
"value": 0,
280+
"currency": "USD"
281+
},
282+
"available_credit": {
283+
"value": 500,
284+
"currency": "USD"
285+
},
286+
"credit_limit": {
287+
"value": 500,
288+
"currency": "USD"
289+
}
290+
}
291+
},
292+
{
293+
"date": "2020-12-02 17:05:12",
294+
"type": "PURCHASE",
295+
"amount": {
296+
"value": -192,
297+
"currency": "USD"
298+
},
299+
"balance": {
300+
"outstanding_balance": {
301+
"value": -192,
302+
"currency": "USD"
303+
},
304+
"available_credit": {
305+
"value": 308,
306+
"currency": "USD"
307+
},
308+
"credit_limit": {
309+
"value": 500,
310+
"currency": "USD"
311+
}
312+
}
313+
},
314+
{
315+
"date": "2020-12-02 17:27:57",
316+
"type": "PURCHASE",
317+
"amount": {
318+
"value": -64,
319+
"currency": "USD"
320+
},
321+
"balance": {
322+
"outstanding_balance": {
323+
"value": -256,
324+
"currency": "USD"
325+
},
326+
"available_credit": {
327+
"value": 244,
328+
"currency": "USD"
329+
},
330+
"credit_limit": {
331+
"value": 500,
332+
"currency": "USD"
333+
}
334+
}
335+
},
336+
{
337+
"date": "2020-12-02 17:35:47",
338+
"type": "REIMBURSEMENT",
339+
"amount": {
340+
"value": 192,
341+
"currency": "USD"
342+
},
343+
"balance": {
344+
"outstanding_balance": {
345+
"value": -64,
346+
"currency": "USD"
347+
},
348+
"available_credit": {
349+
"value": 436,
350+
"currency": "USD"
351+
},
352+
"credit_limit": {
353+
"value": 500,
354+
"currency": "USD"
355+
}
356+
}
357+
}
358+
]
359+
},
360+
"payment_methods": []
361+
}
362+
}
363+
}
364+
```
365+
190366
## Output attributes
191367

192368
The `company` object returns the `Company` object.

0 commit comments

Comments
 (0)