Make quick sale products on machines as orders paid when ready
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -26,11 +26,12 @@ use Illuminate\Support\Carbon;
|
||||
* @property int $total_cents
|
||||
* @property int|null $credits_quick_sale_id
|
||||
* @property string|null $receipt_email
|
||||
* @property int|null $quick_sale_order_id
|
||||
* @property Carbon|null $receipt_sent_at
|
||||
* @property Carbon|null $receipt_send_failed_at
|
||||
*/
|
||||
#[Table('quick_sales')]
|
||||
#[Fillable(['user_id', 'customer_id', 'payment_method', 'sold_at', 'sold_on', 'total_cents', 'credits_quick_sale_id', 'receipt_email'])]
|
||||
#[Fillable(['user_id', 'customer_id', 'payment_method', 'sold_at', 'sold_on', 'total_cents', 'credits_quick_sale_id', 'receipt_email', 'quick_sale_order_id'])]
|
||||
#[Hidden(['receipt_email'])]
|
||||
#[UseFactory(QuickSaleFactory::class)]
|
||||
class QuickSaleModel extends Model
|
||||
@@ -67,6 +68,7 @@ class QuickSaleModel extends Model
|
||||
'total_cents' => 'integer',
|
||||
'credits_quick_sale_id' => 'integer',
|
||||
'receipt_email' => 'encrypted',
|
||||
'quick_sale_order_id' => 'integer',
|
||||
'receipt_sent_at' => 'datetime',
|
||||
'receipt_send_failed_at' => 'datetime',
|
||||
];
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Sales\Infrastructure\Persistence\Eloquent;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Table;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* Persistence model, used only inside the Sales Infrastructure layer.
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $quick_sale_order_id
|
||||
* @property int $product_id
|
||||
* @property string $product_name
|
||||
* @property int $quantity
|
||||
* @property int $unit_price_cents
|
||||
* @property int $vat_basis_points
|
||||
* @property list<array{machineId?: ?int, durationQuarters?: int, workTypeId?: int, materials?: list<array{stockItemId: int, quantityMilli: int}>}> $production_steps
|
||||
* @property int|null $current_step
|
||||
* @property Carbon|null $made_at
|
||||
* @property int $sort_order
|
||||
*/
|
||||
#[Table('quick_sale_order_lines')]
|
||||
#[Fillable(['quick_sale_order_id', 'product_id', 'product_name', 'quantity', 'unit_price_cents', 'vat_basis_points', 'production_steps', 'current_step', 'made_at', 'sort_order'])]
|
||||
class QuickSaleOrderLineModel extends Model
|
||||
{
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'quick_sale_order_id' => 'integer',
|
||||
'product_id' => 'integer',
|
||||
'quantity' => 'integer',
|
||||
'unit_price_cents' => 'integer',
|
||||
'vat_basis_points' => 'integer',
|
||||
'production_steps' => 'array',
|
||||
'current_step' => 'integer',
|
||||
'made_at' => 'immutable_datetime',
|
||||
'sort_order' => 'integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Sales\Infrastructure\Persistence\Eloquent;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Table;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* Persistence model, used only inside the Sales Infrastructure layer.
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $ordered_on Y-m-d
|
||||
* @property int $pickup_number
|
||||
* @property Carbon $ordered_at
|
||||
* @property int $user_id
|
||||
* @property int|null $customer_id
|
||||
* @property string|null $customer_name
|
||||
* @property string $status
|
||||
* @property Carbon|null $made_at
|
||||
* @property Carbon|null $paid_at
|
||||
* @property Carbon|null $cancelled_at
|
||||
* @property int|null $cancelled_by
|
||||
*/
|
||||
#[Table('quick_sale_orders')]
|
||||
#[Fillable(['ordered_on', 'pickup_number', 'ordered_at', 'user_id', 'customer_id', 'customer_name', 'status', 'made_at', 'paid_at', 'cancelled_at', 'cancelled_by'])]
|
||||
class QuickSaleOrderModel extends Model
|
||||
{
|
||||
/**
|
||||
* @return HasMany<QuickSaleOrderLineModel, $this>
|
||||
*/
|
||||
public function lines(): HasMany
|
||||
{
|
||||
return $this->hasMany(QuickSaleOrderLineModel::class, 'quick_sale_order_id')->orderBy('sort_order');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasOne<QuickSaleModel, $this>
|
||||
*/
|
||||
public function sale(): HasOne
|
||||
{
|
||||
return $this->hasOne(QuickSaleModel::class, 'quick_sale_order_id')->whereNull('credits_quick_sale_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'pickup_number' => 'integer',
|
||||
'ordered_at' => 'immutable_datetime',
|
||||
'user_id' => 'integer',
|
||||
'customer_id' => 'integer',
|
||||
'made_at' => 'immutable_datetime',
|
||||
'paid_at' => 'immutable_datetime',
|
||||
'cancelled_at' => 'immutable_datetime',
|
||||
'cancelled_by' => 'integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user