A continuation of HomeBox the inventory and organization system built for the Home User
fix: javascript handles nulls in an incredibly stupid way.
Matt Kilgorec6158e7c9ebf
diff --git a/backend/app/api/static/docs/docs.go b/backend/app/api/static/docs/docs.goindex 79d62ccc..4e3a5db2 100644--- a/backend/app/api/static/docs/docs.go+++ b/backend/app/api/static/docs/docs.go@@ -2217,8 +2217,7 @@ const docTemplate = `{"type": "string"},"purchasePrice": {- "type": "string",- "example": "0"+ "type": "number"},"purchaseTime": {"description": "Purchase",@@ -2234,8 +2233,7 @@ const docTemplate = `{"type": "string"},"soldPrice": {- "type": "string",- "example": "0"+ "type": "number"},"soldTime": {"description": "Sold",@@ -2323,8 +2321,7 @@ const docTemplate = `{"type": "string"},"purchasePrice": {- "type": "string",- "example": "0"+ "type": "number"},"quantity": {"type": "integer"@@ -2412,7 +2409,9 @@ const docTemplate = `{"maxLength": 255},"purchasePrice": {- "type": "number"+ "type": "number",+ "x-nullable": true,+ "x-omitempty": true},"purchaseTime": {"description": "Purchase",@@ -2429,7 +2428,9 @@ const docTemplate = `{"type": "string"},"soldPrice": {- "type": "number"+ "type": "number",+ "x-nullable": true,+ "x-omitempty": true},"soldTime": {"description": "Sold",diff --git a/backend/app/api/static/docs/swagger.json b/backend/app/api/static/docs/swagger.jsonindex addf7280..532020b8 100644--- a/backend/app/api/static/docs/swagger.json+++ b/backend/app/api/static/docs/swagger.json@@ -2210,8 +2210,7 @@"type": "string"},"purchasePrice": {- "type": "string",- "example": "0"+ "type": "number"},"purchaseTime": {"description": "Purchase",@@ -2227,8 +2226,7 @@"type": "string"},"soldPrice": {- "type": "string",- "example": "0"+ "type": "number"},"soldTime": {"description": "Sold",@@ -2316,8 +2314,7 @@"type": "string"},"purchasePrice": {- "type": "string",- "example": "0"+ "type": "number"},"quantity": {"type": "integer"@@ -2405,7 +2402,9 @@"maxLength": 255},"purchasePrice": {- "type": "number"+ "type": "number",+ "x-nullable": true,+ "x-omitempty": true},"purchaseTime": {"description": "Purchase",@@ -2422,7 +2421,9 @@"type": "string"},"soldPrice": {- "type": "number"+ "type": "number",+ "x-nullable": true,+ "x-omitempty": true},"soldTime": {"description": "Sold",diff --git a/backend/app/api/static/docs/swagger.yaml b/backend/app/api/static/docs/swagger.yamlindex a7211acb..7939eb3d 100644--- a/backend/app/api/static/docs/swagger.yaml+++ b/backend/app/api/static/docs/swagger.yaml@@ -171,8 +171,7 @@ definitions:purchaseFrom:type: stringpurchasePrice:- example: "0"- type: string+ type: numberpurchaseTime:description: Purchasetype: string@@ -183,8 +182,7 @@ definitions:soldNotes:type: stringsoldPrice:- example: "0"- type: string+ type: numbersoldTime:description: Soldtype: string@@ -242,8 +240,7 @@ definitions:name:type: stringpurchasePrice:- example: "0"- type: string+ type: numberquantity:type: integerupdatedAt:@@ -304,6 +301,8 @@ definitions:type: stringpurchasePrice:type: number+ x-nullable: true+ x-omitempty: truepurchaseTime:description: Purchasetype: string@@ -316,6 +315,8 @@ definitions:type: stringsoldPrice:type: number+ x-nullable: true+ x-omitempty: truesoldTime:description: Soldtype: stringdiff --git a/backend/internal/data/repo/repo_items.go b/backend/internal/data/repo/repo_items.goindex d67a60a3..cffc910f 100644--- a/backend/internal/data/repo/repo_items.go+++ b/backend/internal/data/repo/repo_items.go@@ -93,12 +93,12 @@ type (// PurchasePurchaseTime types.Date `json:"purchaseTime"`PurchaseFrom string `json:"purchaseFrom" validate:"max=255"`- PurchasePrice float64 `json:"purchasePrice"`+ PurchasePrice float64 `json:"purchasePrice" extensions:"x-nullable,x-omitempty"`// SoldSoldTime types.Date `json:"soldTime"`SoldTo string `json:"soldTo" validate:"max=255"`- SoldPrice float64 `json:"soldPrice"`+ SoldPrice float64 `json:"soldPrice" extensions:"x-nullable,x-omitempty"`SoldNotes string `json:"soldNotes"`// Extras@@ -123,7 +123,7 @@ type (CreatedAt time.Time `json:"createdAt"`UpdatedAt time.Time `json:"updatedAt"`- PurchasePrice float64 `json:"purchasePrice,string"`+ PurchasePrice float64 `json:"purchasePrice"`// EdgesLocation *LocationSummary `json:"location,omitempty" extensions:"x-nullable,x-omitempty"`@@ -153,7 +153,7 @@ type (// SoldSoldTime types.Date `json:"soldTime"`SoldTo string `json:"soldTo"`- SoldPrice float64 `json:"soldPrice,string"`+ SoldPrice float64 `json:"soldPrice"`SoldNotes string `json:"soldNotes"`// Extrasdiff --git a/docs/docs/api/openapi-2.0.json b/docs/docs/api/openapi-2.0.jsonindex 12e556ce..532020b8 100644--- a/docs/docs/api/openapi-2.0.json+++ b/docs/docs/api/openapi-2.0.json@@ -2210,8 +2210,7 @@"type": "string"},"purchasePrice": {- "type": "string",- "example": "0"+ "type": "number"},"purchaseTime": {"description": "Purchase",@@ -2227,8 +2226,7 @@"type": "string"},"soldPrice": {- "type": "string",- "example": "0"+ "type": "number"},"soldTime": {"description": "Sold",@@ -2316,8 +2314,7 @@"type": "string"},"purchasePrice": {- "type": "string",- "example": "0"+ "type": "number"},"quantity": {"type": "integer"@@ -2340,6 +2337,9 @@},"repo.ItemUpdate": {"type": "object",+ "required": [+ "name"+ ],"properties": {"archived": {"type": "boolean"@@ -2348,7 +2348,8 @@"type": "string"},"description": {- "type": "string"+ "type": "string",+ "maxLength": 1000},"fields": {"type": "array",@@ -2383,7 +2384,9 @@"type": "string"},"name": {- "type": "string"+ "type": "string",+ "maxLength": 255,+ "minLength": 1},"notes": {"description": "Extras",@@ -2395,11 +2398,13 @@"x-omitempty": true},"purchaseFrom": {- "type": "string"+ "type": "string",+ "maxLength": 255},"purchasePrice": {- "type": "string",- "example": "0"+ "type": "number",+ "x-nullable": true,+ "x-omitempty": true},"purchaseTime": {"description": "Purchase",@@ -2416,15 +2421,17 @@"type": "string"},"soldPrice": {- "type": "string",- "example": "0"+ "type": "number",+ "x-nullable": true,+ "x-omitempty": true},"soldTime": {"description": "Sold","type": "string"},"soldTo": {- "type": "string"+ "type": "string",+ "maxLength": 255},"warrantyDetails": {"type": "string"@@ -2756,7 +2763,6 @@"type": "string"},"url": {- "description": "URL field is not exposed to the client","type": "string"},"userId": {diff --git a/frontend/lib/api/types/data-contracts.ts b/frontend/lib/api/types/data-contracts.tsindex 952e4f1e..c664c93f 100644--- a/frontend/lib/api/types/data-contracts.ts+++ b/frontend/lib/api/types/data-contracts.ts@@ -106,15 +106,13 @@ export interface ItemOut {notes: string;parent?: ItemSummary | null;purchaseFrom: string;- /** @example "0" */- purchasePrice: string;+ purchasePrice: number;/** Purchase */purchaseTime: Date | string;quantity: number;serialNumber: string;soldNotes: string;- /** @example "0" */- soldPrice: string;+ soldPrice: number;/** Sold */soldTime: Date | string;soldTo: string;@@ -145,8 +143,7 @@ export interface ItemSummary {/** Edges */location?: LocationSummary | null;name: string;- /** @example "0" */- purchasePrice: string;+ purchasePrice: number;quantity: number;updatedAt: Date | string;}@@ -181,14 +178,14 @@ export interface ItemUpdate {parentId?: string | null;/** @maxLength 255 */purchaseFrom: string;- purchasePrice: number;+ purchasePrice?: number | null;/** Purchase */purchaseTime: Date | string;quantity: number;/** Identifications */serialNumber: string;soldNotes: string;- soldPrice: number;+ soldPrice?: number | null;/** Sold */soldTime: Date | string;/** @maxLength 255 */diff --git a/frontend/pages/item/[id]/index/edit.vue b/frontend/pages/item/[id]/index/edit.vueindex 2d9c9a70..1f3cd0bc 100644--- a/frontend/pages/item/[id]/index/edit.vue+++ b/frontend/pages/item/[id]/index/edit.vue@@ -65,12 +65,24 @@return;}+ let purchasePrice = 0;+ let soldPrice = 0;+ if (item.value.purchasePrice) {+ purchasePrice = item.value.purchasePrice;+ }+ if (item.value.soldPrice) {+ soldPrice = item.value.soldPrice;+ }+ console.log((item.value.purchasePrice ??= 0));+ console.log((item.value.soldPrice ??= 0));const payload: ItemUpdate = {...item.value,locationId: item.value.location?.id,labelIds: item.value.labels.map(l => l.id),parentId: parent.value ? parent.value.id : null,assetId: item.value.assetId,+ purchasePrice,+ soldPrice,};const { error } = await api.items.update(itemId.value, payload);