Files
ladill-pos/app/Services/Pos/PosTimelineService.php
T
isaaccladandCursor e5d2b84388
Deploy Ladill Mini / deploy (push) Successful in 23s
Add Ladill POS v1 — register, Pay checkout, and commerce links.
Staff-facing counter register at pos.ladill.com with catalog cart, cash and
MoMo/card checkout via Ladill Pay, CRM timeline/import, invoice prefill, and
Merchant catalog import.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-23 22:52:24 +00:00

40 lines
1.3 KiB
PHP

<?php
namespace App\Services\Pos;
use App\Models\PosSale;
use App\Services\Crm\CrmClient;
use Illuminate\Support\Facades\Log;
class PosTimelineService
{
public function pushPaidSale(PosSale $sale): void
{
if ($sale->status !== PosSale::STATUS_PAID) {
return;
}
try {
CrmClient::for($sale->owner_ref)->pushTimeline([
'event' => 'order.paid',
'title' => 'POS sale '.$sale->reference,
'external_id' => (string) $sale->id,
'amount_minor' => (int) $sale->total_minor,
'currency' => (string) $sale->currency,
'url' => route('pos.sales.show', $sale),
'customer_id' => $sale->crm_customer_id,
'customer_email' => $sale->customer_email,
'customer_phone' => $sale->customer_phone,
'customer_name' => $sale->customer_name,
'description' => ucfirst($sale->payment_method).' payment at register',
'occurred_at' => ($sale->paid_at ?? now())->toIso8601String(),
]);
} catch (\Throwable $e) {
Log::info('CRM timeline push skipped for POS sale', [
'sale_id' => $sale->id,
'error' => $e->getMessage(),
]);
}
}
}