Deploy Ladill Mini / deploy (push) Successful in 23s
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>
34 lines
1.0 KiB
PHP
34 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Services\CrossApp;
|
|
|
|
use App\Models\PosSale;
|
|
use App\Support\CrmPrefillCodec;
|
|
use App\Support\LadillAppUrl;
|
|
|
|
class CrossAppLinkService
|
|
{
|
|
public function invoiceFromSale(PosSale $sale): string
|
|
{
|
|
$sale->loadMissing('lines');
|
|
|
|
$lines = $sale->lines->map(fn ($line) => [
|
|
'description' => $line->name,
|
|
'quantity' => (float) $line->quantity,
|
|
'unit_price' => number_format($line->unit_price_minor / 100, 2, '.', ''),
|
|
])->values()->all();
|
|
|
|
$prefill = CrmPrefillCodec::encode([
|
|
'kind' => 'pos_sale',
|
|
'crm_customer_id' => $sale->crm_customer_id,
|
|
'client_name' => $sale->customer_name ?: 'Walk-in customer',
|
|
'client_email' => $sale->customer_email,
|
|
'notes' => 'Receipt for POS sale '.$sale->reference,
|
|
'payment_enabled' => false,
|
|
'lines' => $lines,
|
|
]);
|
|
|
|
return LadillAppUrl::connect('invoice', '/invoices/create?prefill='.urlencode($prefill));
|
|
}
|
|
}
|