Fix negative values on item price (#335)

* Fix negative values on item price

* Remove console log
This commit is contained in:
mchev
2025-04-05 00:43:34 +02:00
committed by GitHub
parent 23a99758d2
commit 1bb65f420c
2 changed files with 31 additions and 13 deletions

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('invoice_items', function (Blueprint $table) {
$table->bigInteger('price')->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('invoice_items', function (Blueprint $table) {
$table->unsignedBigInteger('price')->change();
});
}
};

View File

@@ -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
},
set: (newValue) => {
if (parseFloat(newValue) > 0) {
let price = Math.round(newValue * 100)
updateItemAttribute('price', price)
} else {
updateItemAttribute('price', newValue)
}
setDiscount()
},
})