Skip to content

Commit b22132b

Browse files
committed
Add permissions and types for invoice recipients
1 parent 114a325 commit b22132b

4 files changed

Lines changed: 186 additions & 34 deletions

File tree

app/Service/PermissionStore.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ class PermissionStore
8080
'invoices:update',
8181
'invoices:download',
8282
'invoices:delete',
83+
'invoice-recipients:view',
84+
'invoice-recipients:create',
85+
'invoice-recipients:update',
86+
'invoice-recipients:delete',
8387
'invoice-settings:view',
8488
'invoice-settings:update',
8589
],
@@ -147,6 +151,10 @@ class PermissionStore
147151
'invoices:update',
148152
'invoices:download',
149153
'invoices:delete',
154+
'invoice-recipients:view',
155+
'invoice-recipients:create',
156+
'invoice-recipients:update',
157+
'invoice-recipients:delete',
150158
'invoice-settings:view',
151159
'invoice-settings:update',
152160
],
@@ -203,6 +211,10 @@ class PermissionStore
203211
'invoices:update',
204212
'invoices:download',
205213
'invoices:delete',
214+
'invoice-recipients:view',
215+
'invoice-recipients:create',
216+
'invoice-recipients:update',
217+
'invoice-recipients:delete',
206218
'invoice-settings:view',
207219
'invoice-settings:update',
208220
],

extensions/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"Billing": {
33
"repository": "solidtime-io/extension-billing",
4-
"ref": "v0.0.3"
4+
"ref": "v0.0.4"
55
},
66
"Services": {
77
"repository": "solidtime-io/extension-services",
88
"ref": "v0.0.1"
99
},
1010
"Invoicing": {
1111
"repository": "solidtime-io/extension-invoicing",
12-
"ref": "v0.0.1"
12+
"ref": "feature/recipients"
1313
}
1414
}

resources/js/packages/api/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ export type DetailedInvoiceResponse = ZodiosResponseByAlias<SolidTimeApi, 'getIn
117117
export type DetailedInvoice = DetailedInvoiceResponse['data'];
118118

119119
export type InvoiceIndexEntry = ZodiosResponseByAlias<SolidTimeApi, 'getInvoices'>['data'][0];
120+
export type InvoiceRecipient = ZodiosResponseByAlias<SolidTimeApi, 'getInvoiceRecipients'>['data'][0];
121+
export type InvoiceRecipientBody = ZodiosBodyByAlias<SolidTimeApi, 'createInvoiceRecipient'>;
120122

121123
export type UpdateInvoiceSettings = ZodiosBodyByAlias<SolidTimeApi, 'updateInvoiceSettings'>;
122124

resources/js/packages/api/src/openapi.json.client.ts

Lines changed: 170 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,54 @@ const InvitationResource = z
4545
const InvitationStoreRequest = z
4646
.object({ email: z.string().email(), role: z.enum(['admin', 'manager', 'employee']) })
4747
.passthrough();
48+
const InvoiceRecipientResource = z
49+
.object({
50+
id: z.string(),
51+
organization_id: z.string(),
52+
name: z.string(),
53+
vatin: z.union([z.string(), z.null()]),
54+
address_line_1: z.union([z.string(), z.null()]),
55+
address_line_2: z.union([z.string(), z.null()]),
56+
address_line_3: z.union([z.string(), z.null()]),
57+
address_post_code: z.union([z.string(), z.null()]),
58+
address_city: z.union([z.string(), z.null()]),
59+
address_country: z.union([z.string(), z.null()]),
60+
phone: z.union([z.string(), z.null()]),
61+
email: z.union([z.string(), z.null()]),
62+
is_archived: z.boolean(),
63+
archived_at: z.union([z.string(), z.null()]),
64+
invoices_count: z.number().int(),
65+
has_non_draft_invoices: z.boolean(),
66+
created_at: z.union([z.string(), z.null()]),
67+
updated_at: z.union([z.string(), z.null()]),
68+
})
69+
.passthrough();
70+
const InvoiceRecipientCollection = z.array(InvoiceRecipientResource);
71+
const InvoiceRecipientRequest = z
72+
.object({
73+
name: z.string(),
74+
vatin: z.union([z.string(), z.null()]).optional(),
75+
address_line_1: z.union([z.string(), z.null()]).optional(),
76+
address_line_2: z.union([z.string(), z.null()]).optional(),
77+
address_line_3: z.union([z.string(), z.null()]).optional(),
78+
address_post_code: z.union([z.string(), z.null()]).optional(),
79+
address_city: z.union([z.string(), z.null()]).optional(),
80+
address_country: z.union([z.string(), z.null()]).optional(),
81+
phone: z.union([z.string(), z.null()]).optional(),
82+
email: z.union([z.string(), z.null()]).optional(),
83+
is_archived: z.boolean().optional(),
84+
})
85+
.passthrough();
4886
const InvoiceResource = z
4987
.object({
5088
id: z.string(),
5189
organization_id: z.string(),
90+
invoice_recipient_id: z.string(),
5291
reference: z.string(),
5392
seller_name: z.string(),
54-
buyer_name: z.string(),
93+
recipient: z.string(),
5594
status: z.string(),
95+
status_label: z.string(),
5696
date: z.string(),
5797
due_at: z.string(),
5898
paid_date: z.string(),
@@ -76,16 +116,7 @@ const InvoiceStoreRequest = z
76116
seller_address_country: z.union([z.string(), z.null()]).optional(),
77117
seller_phone: z.union([z.string(), z.null()]).optional(),
78118
seller_email: z.union([z.string(), z.null()]).optional(),
79-
buyer_name: z.string(),
80-
buyer_vatin: z.union([z.string(), z.null()]).optional(),
81-
buyer_address_line_1: z.union([z.string(), z.null()]).optional(),
82-
buyer_address_line_2: z.union([z.string(), z.null()]).optional(),
83-
buyer_address_line_3: z.union([z.string(), z.null()]).optional(),
84-
buyer_address_post_code: z.union([z.string(), z.null()]).optional(),
85-
buyer_address_city: z.union([z.string(), z.null()]).optional(),
86-
buyer_address_country: z.union([z.string(), z.null()]).optional(),
87-
buyer_phone: z.union([z.string(), z.null()]).optional(),
88-
buyer_email: z.union([z.string(), z.null()]).optional(),
119+
invoice_recipient_id: z.string(),
89120
date: z.string(),
90121
billing_period_start: z.union([z.string(), z.null()]).optional(),
91122
billing_period_end: z.union([z.string(), z.null()]).optional(),
@@ -130,6 +161,7 @@ const DetailedInvoiceResource = z
130161
.object({
131162
id: z.string(),
132163
organization_id: z.string(),
164+
invoice_recipient_id: z.string(),
133165
reference: z.string(),
134166
seller_name: z.string(),
135167
seller_vatin: z.string(),
@@ -141,16 +173,7 @@ const DetailedInvoiceResource = z
141173
seller_address_country: z.string(),
142174
seller_phone: z.string(),
143175
seller_email: z.string(),
144-
buyer_name: z.string(),
145-
buyer_vatin: z.string(),
146-
buyer_address_line_1: z.string(),
147-
buyer_address_line_2: z.string(),
148-
buyer_address_line_3: z.string(),
149-
buyer_address_post_code: z.string(),
150-
buyer_address_city: z.string(),
151-
buyer_address_country: z.string(),
152-
buyer_phone: z.string(),
153-
buyer_email: z.string(),
176+
recipient: InvoiceRecipientResource,
154177
paid_date: z.string(),
155178
due_at: z.string(),
156179
discount_type: z.string(),
@@ -171,7 +194,7 @@ const DetailedInvoiceResource = z
171194
entries: z.array(InvoiceEntryResource),
172195
})
173196
.passthrough();
174-
const InvoiceStatus = z.enum(['draft', 'sent', 'cancelled']);
197+
const InvoiceStatus = z.enum(['draft', 'sent', 'paid', 'cancelled']);
175198
const InvoiceUpdateRequest = z
176199
.object({
177200
status: InvoiceStatus,
@@ -187,16 +210,7 @@ const InvoiceUpdateRequest = z
187210
seller_address_country: z.union([z.string(), z.null()]),
188211
seller_phone: z.union([z.string(), z.null()]),
189212
seller_email: z.union([z.string(), z.null()]),
190-
buyer_name: z.string(),
191-
buyer_vatin: z.union([z.string(), z.null()]),
192-
buyer_address_line_1: z.union([z.string(), z.null()]),
193-
buyer_address_line_2: z.union([z.string(), z.null()]),
194-
buyer_address_line_3: z.union([z.string(), z.null()]),
195-
buyer_address_post_code: z.union([z.string(), z.null()]),
196-
buyer_address_city: z.union([z.string(), z.null()]),
197-
buyer_address_country: z.union([z.string(), z.null()]),
198-
buyer_phone: z.union([z.string(), z.null()]),
199-
buyer_email: z.union([z.string(), z.null()]),
213+
invoice_recipient_id: z.string(),
200214
date: z.string(),
201215
billing_period_start: z.union([z.string(), z.null()]),
202216
billing_period_end: z.union([z.string(), z.null()]),
@@ -1885,6 +1899,125 @@ const endpoints = makeApi([
18851899
},
18861900
],
18871901
},
1902+
{
1903+
method: 'get',
1904+
path: '/v1/organizations/:organization/invoice-recipients',
1905+
alias: 'getInvoiceRecipients',
1906+
requestFormat: 'json',
1907+
parameters: [
1908+
{
1909+
name: 'organization',
1910+
type: 'Path',
1911+
schema: z.string(),
1912+
},
1913+
],
1914+
response: z.object({ data: InvoiceRecipientCollection }).passthrough(),
1915+
},
1916+
{
1917+
method: 'post',
1918+
path: '/v1/organizations/:organization/invoice-recipients',
1919+
alias: 'createInvoiceRecipient',
1920+
requestFormat: 'json',
1921+
parameters: [
1922+
{
1923+
name: 'body',
1924+
type: 'Body',
1925+
schema: InvoiceRecipientRequest,
1926+
},
1927+
{
1928+
name: 'organization',
1929+
type: 'Path',
1930+
schema: z.string(),
1931+
},
1932+
],
1933+
response: z.object({ data: InvoiceRecipientResource }).passthrough(),
1934+
},
1935+
{
1936+
method: 'get',
1937+
path: '/v1/organizations/:organization/invoice-recipients/:invoiceRecipient',
1938+
alias: 'getInvoiceRecipient',
1939+
requestFormat: 'json',
1940+
parameters: [
1941+
{
1942+
name: 'organization',
1943+
type: 'Path',
1944+
schema: z.string(),
1945+
},
1946+
{
1947+
name: 'invoiceRecipient',
1948+
type: 'Path',
1949+
schema: z.string(),
1950+
},
1951+
],
1952+
response: z.object({ data: InvoiceRecipientResource }).passthrough(),
1953+
},
1954+
{
1955+
method: 'put',
1956+
path: '/v1/organizations/:organization/invoice-recipients/:invoiceRecipient',
1957+
alias: 'updateInvoiceRecipient',
1958+
requestFormat: 'json',
1959+
parameters: [
1960+
{
1961+
name: 'body',
1962+
type: 'Body',
1963+
schema: InvoiceRecipientRequest,
1964+
},
1965+
{
1966+
name: 'organization',
1967+
type: 'Path',
1968+
schema: z.string(),
1969+
},
1970+
{
1971+
name: 'invoiceRecipient',
1972+
type: 'Path',
1973+
schema: z.string(),
1974+
},
1975+
],
1976+
response: z.object({ data: InvoiceRecipientResource }).passthrough(),
1977+
},
1978+
{
1979+
method: 'post',
1980+
path: '/v1/organizations/:organization/invoice-recipients/:invoiceRecipient/duplicate',
1981+
alias: 'duplicateInvoiceRecipient',
1982+
requestFormat: 'json',
1983+
parameters: [
1984+
{
1985+
name: 'body',
1986+
type: 'Body',
1987+
schema: InvoiceRecipientRequest,
1988+
},
1989+
{
1990+
name: 'organization',
1991+
type: 'Path',
1992+
schema: z.string(),
1993+
},
1994+
{
1995+
name: 'invoiceRecipient',
1996+
type: 'Path',
1997+
schema: z.string(),
1998+
},
1999+
],
2000+
response: z.object({ data: InvoiceRecipientResource }).passthrough(),
2001+
},
2002+
{
2003+
method: 'delete',
2004+
path: '/v1/organizations/:organization/invoice-recipients/:invoiceRecipient',
2005+
alias: 'deleteInvoiceRecipient',
2006+
requestFormat: 'json',
2007+
parameters: [
2008+
{
2009+
name: 'organization',
2010+
type: 'Path',
2011+
schema: z.string(),
2012+
},
2013+
{
2014+
name: 'invoiceRecipient',
2015+
type: 'Path',
2016+
schema: z.string(),
2017+
},
2018+
],
2019+
response: z.void(),
2020+
},
18882021
{
18892022
method: 'get',
18902023
path: '/v1/organizations/:organization/invoices',
@@ -1901,6 +2034,11 @@ const endpoints = makeApi([
19012034
type: 'Query',
19022035
schema: z.number().int().gte(1).lte(2147483647).optional(),
19032036
},
2037+
{
2038+
name: 'status',
2039+
type: 'Query',
2040+
schema: InvoiceStatus.optional(),
2041+
},
19042042
],
19052043
response: z.object({ data: InvoiceCollection }).passthrough(),
19062044
errors: [

0 commit comments

Comments
 (0)