Adjust schema for inventory management

This commit is contained in:
David Bomba 2022-06-03 20:50:19 +10:00
parent 3d9bb490e3
commit 849a3f6b7c
5 changed files with 14 additions and 4 deletions

View File

@ -106,6 +106,7 @@ class Company extends BaseModel
'enable_applying_payments',
'track_inventory',
'inventory_notification_threshold',
'stock_notification'
];
protected $hidden = [

View File

@ -38,6 +38,7 @@ class Product extends BaseModel
'tax_rate3',
'in_stock_quantity',
'stock_notification_threshold',
'stock_notification',
];
protected $touches = [];

View File

@ -170,6 +170,10 @@ class CompanyTransformer extends EntityTransformer
'markdown_email_enabled' => (bool) $company->markdown_email_enabled,
'stop_on_unpaid_recurring' => (bool) $company->stop_on_unpaid_recurring,
'use_quote_terms_on_conversion' => (bool) $company->use_quote_terms_on_conversion,
'stock_notification' => (bool) $company->stock_notification,
'inventory_notification_threshold' => (int) $company->inventory_notification_threshold,
'track_inventory' => (bool) $company->track_inventory,
'enable_applying_payments' => (bool) $company->enable_applying_payments,
];
}

View File

@ -90,6 +90,9 @@ class ProductTransformer extends EntityTransformer
'custom_value3' => $product->custom_value3 ?: '',
'custom_value4' => $product->custom_value4 ?: '',
'is_deleted' => (bool) $product->is_deleted,
'in_stock_quantity' => (int) $product->in_stock_quantity ?: 0,
'stock_notification' => (bool) $product->stock_notification,
'stock_notification_threshold' => (bool) $product->stock_notification_threshold,
];
}
}

View File

@ -18,13 +18,14 @@ class InventoryManagementSchema extends Migration
Schema::table('companies', function (Blueprint $table) {
$table->boolean('enable_applying_payments')->default(0);
$table->boolean('track_inventory')->default(0);
$table->integer('inventory_notification_threshold')->nullable();
$table->integer('inventory_notification_threshold')->default(0);
$table->boolean('stock_notification')->default(1);
});
Schema::table('products', function (Blueprint $table){
$table->integer('in_stock_quantity')->nullable();
$table->integer('stock_notification_threshold')->nullable();
$table->integer('in_stock_quantity')->default(0);
$table->boolean('stock_notification')->default(1);
$table->integer('stock_notification_threshold')->default(0);
});