From 1bb65f420c33c129409e1d6c072bf9c98af02315 Mon Sep 17 00:00:00 2001 From: mchev Date: Sat, 5 Apr 2025 00:43:34 +0200 Subject: [PATCH] Fix negative values on item price (#335) * Fix negative values on item price * Remove console log --- ...03_15_160016_allow_unsigned_item_price.php | 28 +++++++++++++++++++ .../estimate-invoice-common/CreateItemRow.vue | 16 ++--------- 2 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 database/migrations/2025_03_15_160016_allow_unsigned_item_price.php diff --git a/database/migrations/2025_03_15_160016_allow_unsigned_item_price.php b/database/migrations/2025_03_15_160016_allow_unsigned_item_price.php new file mode 100644 index 00000000..941b20a7 --- /dev/null +++ b/database/migrations/2025_03_15_160016_allow_unsigned_item_price.php @@ -0,0 +1,28 @@ +bigInteger('price')->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('invoice_items', function (Blueprint $table) { + $table->unsignedBigInteger('price')->change(); + }); + } +}; diff --git a/resources/scripts/admin/components/estimate-invoice-common/CreateItemRow.vue b/resources/scripts/admin/components/estimate-invoice-common/CreateItemRow.vue index 80d6dbf5..0b0dd4c1 100644 --- a/resources/scripts/admin/components/estimate-invoice-common/CreateItemRow.vue +++ b/resources/scripts/admin/components/estimate-invoice-common/CreateItemRow.vue @@ -254,22 +254,12 @@ const quantity = computed({ const price = computed({ get: () => { const price = props.itemData.price - - if (parseFloat(price) > 0) { - return price / 100 - } - - return price + return price / 100 }, set: (newValue) => { - if (parseFloat(newValue) > 0) { - let price = Math.round(newValue * 100) - - updateItemAttribute('price', price) - } else { - updateItemAttribute('price', newValue) - } + let price = Math.round(newValue * 100) + updateItemAttribute('price', price) setDiscount() }, })