feat: add invoice and alternative_componen management functionality

This commit is contained in:
Tran Anh Tuan
2026-05-12 11:57:11 +07:00
parent c39b010e5e
commit e81a248a61
23 changed files with 3325 additions and 2 deletions

View File

@@ -1321,6 +1321,279 @@
}
}
},
"/v1/alternative-components": {
"get": {
"description": "Retrieve a list of all alternative components",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"alternative-component"
],
"summary": "List all alternative components",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/models.AlternativeComponent"
}
}
}
}
]
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
},
"post": {
"description": "Create a new alternative component with the provided details",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"alternative-component"
],
"summary": "Create a new alternative component",
"parameters": [
{
"description": "Alternative component request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.CreateAlternativeComponentRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.CreateAlternativeComponentResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/v1/alternative-components/{id}": {
"get": {
"description": "Retrieve a single alternative component using its unique identifier",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"alternative-component"
],
"summary": "Get alternative component by ID",
"parameters": [
{
"type": "integer",
"description": "Alternative component ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.AlternativeComponent"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
},
"put": {
"description": "Update an existing alternative component by its ID. Only non-empty fields will be updated.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"alternative-component"
],
"summary": "Update alternative component",
"parameters": [
{
"type": "integer",
"description": "Alternative component ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Alternative component request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.UpdateAlternativeComponentRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.UpdateAlternativeComponentResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
},
"delete": {
"description": "Delete an alternative component by its unique identifier",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"alternative-component"
],
"summary": "Delete alternative component",
"parameters": [
{
"type": "integer",
"description": "Alternative component ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.SuccessResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/v1/cabinets": {
"get": {
"description": "Retrieve a list of all cabinets ordered by creation date",
@@ -2413,6 +2686,279 @@
}
}
},
"/v1/invoices": {
"get": {
"description": "Retrieve a list of all invoices ordered by creation date",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"invoice"
],
"summary": "List all invoices",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Invoice"
}
}
}
}
]
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
},
"post": {
"description": "Create a new invoice with the provided details",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"invoice"
],
"summary": "Create a new invoice",
"parameters": [
{
"description": "Invoice request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.CreateInvoiceRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.CreateInvoiceResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/v1/invoices/{id}": {
"get": {
"description": "Retrieve a single invoice using its unique identifier",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"invoice"
],
"summary": "Get invoice by ID",
"parameters": [
{
"type": "integer",
"description": "Invoice ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.Invoice"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
},
"put": {
"description": "Update an existing invoice by its ID. Only non-empty fields will be updated.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"invoice"
],
"summary": "Update invoice",
"parameters": [
{
"type": "integer",
"description": "Invoice ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Invoice request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.UpdateInvoiceRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.UpdateInvoiceResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
},
"delete": {
"description": "Delete an invoice by its unique identifier",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"invoice"
],
"summary": "Delete invoice",
"parameters": [
{
"type": "integer",
"description": "Invoice ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.SuccessResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/v1/rooms": {
"get": {
"description": "Retrieve a list of all rooms ordered by creation date",
@@ -3228,6 +3774,35 @@
}
},
"definitions": {
"models.AlternativeComponent": {
"type": "object",
"properties": {
"alternativeComponentId": {
"type": "integer"
},
"conversionRatio": {
"type": "string"
},
"id": {
"type": "integer"
},
"invoiceConfigItemId": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
},
"note": {
"type": "string"
},
"priority": {
"type": "integer"
}
}
},
"models.Cabinet": {
"type": "object",
"properties": {
@@ -3446,6 +4021,53 @@
}
}
},
"models.Invoice": {
"type": "object",
"properties": {
"approvedBy": {
"type": "string"
},
"completedAt": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"createdBy": {
"type": "string"
},
"id": {
"type": "integer"
},
"invoiceCode": {
"type": "string"
},
"invoiceConfigId": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
},
"note": {
"type": "string"
},
"status": {
"type": "string"
},
"totalItems": {
"type": "integer"
},
"type": {
"type": "string"
},
"updatedAt": {
"type": "string"
}
}
},
"models.InvoiceConfig": {
"type": "object",
"properties": {
@@ -3605,6 +4227,32 @@
}
}
},
"requests.CreateAlternativeComponentRequest": {
"type": "object",
"required": [
"alternativeComponentId",
"conversionRatio",
"invoiceConfigItemId",
"priority"
],
"properties": {
"alternativeComponentId": {
"type": "integer"
},
"conversionRatio": {
"type": "string"
},
"invoiceConfigItemId": {
"type": "integer"
},
"note": {
"type": "string"
},
"priority": {
"type": "integer"
}
}
},
"requests.CreateCabinetRequest": {
"type": "object",
"required": [
@@ -3812,6 +4460,36 @@
}
}
},
"requests.CreateInvoiceRequest": {
"type": "object",
"required": [
"status",
"type"
],
"properties": {
"approvedBy": {
"type": "string"
},
"createdBy": {
"type": "string"
},
"invoiceConfigId": {
"type": "integer"
},
"note": {
"type": "string"
},
"status": {
"type": "string"
},
"totalItems": {
"type": "integer"
},
"type": {
"type": "string"
}
}
},
"requests.CreateRoomRequest": {
"type": "object",
"required": [
@@ -3870,6 +4548,26 @@
}
}
},
"requests.UpdateAlternativeComponentRequest": {
"type": "object",
"properties": {
"alternativeComponentId": {
"type": "integer"
},
"conversionRatio": {
"type": "string"
},
"invoiceConfigItemId": {
"type": "integer"
},
"note": {
"type": "string"
},
"priority": {
"type": "integer"
}
}
},
"requests.UpdateCabinetRequest": {
"type": "object",
"properties": {
@@ -4045,6 +4743,26 @@
}
}
},
"requests.UpdateInvoiceRequest": {
"type": "object",
"properties": {
"invoiceConfigId": {
"type": "integer"
},
"note": {
"type": "string"
},
"status": {
"type": "string"
},
"totalItems": {
"type": "integer"
},
"type": {
"type": "string"
}
}
},
"requests.UpdateRoomRequest": {
"type": "object",
"properties": {
@@ -4125,6 +4843,14 @@
}
}
},
"responses.CreateAlternativeComponentResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer"
}
}
},
"responses.CreateCabinetResponse": {
"type": "object",
"properties": {
@@ -4189,6 +4915,17 @@
}
}
},
"responses.CreateInvoiceResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"invoiceCode": {
"type": "string"
}
}
},
"responses.CreateRoomResponse": {
"type": "object",
"properties": {
@@ -4213,6 +4950,29 @@
}
}
},
"responses.UpdateAlternativeComponentResponse": {
"type": "object",
"properties": {
"alternativeComponentId": {
"type": "integer"
},
"conversionRatio": {
"type": "string"
},
"id": {
"type": "integer"
},
"invoiceConfigItemId": {
"type": "integer"
},
"note": {
"type": "string"
},
"priority": {
"type": "integer"
}
}
},
"responses.UpdateCabinetResponse": {
"type": "object",
"properties": {
@@ -4414,6 +5174,32 @@
}
}
},
"responses.UpdateInvoiceResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"invoiceCode": {
"type": "string"
},
"invoiceConfigId": {
"type": "integer"
},
"note": {
"type": "string"
},
"status": {
"type": "string"
},
"totalItems": {
"type": "integer"
},
"type": {
"type": "string"
}
}
},
"responses.UpdateRoomResponse": {
"type": "object",
"properties": {