Fix transfer quantity, unify date format, align demo seeds
Stock Transfer list showed 0.00 (read in instead of out); stock-out/transfer forms show the location quantity; dates display as YYYY-MM-DD HH:mm:ss. Demo seeds map product accounts and use product names and supplier batches.
This commit is contained in:
@@ -39,7 +39,7 @@ function buildLineItem(array $products, string $sku, float $qty): array {
|
||||
$tax_amount = round($total_price * $tax_rate / 100, 4);
|
||||
return [
|
||||
'product_sku' => $sku,
|
||||
'product_name' => $sku,
|
||||
'product_name' => $p['product_name'],
|
||||
'quantity' => $qty,
|
||||
'unit_price' => $unit_price,
|
||||
'total_price' => $total_price,
|
||||
@@ -69,11 +69,16 @@ $sth->execute([':c' => $company_id]);
|
||||
$sales_dept_id = (int)$sth->fetchColumn();
|
||||
if (!$sales_dept_id) { exit("ERROR: SALES department not found — run demo_seed_transactions.php first.\n"); }
|
||||
|
||||
$sth = $pdo2->prepare("SELECT sku, price FROM md_product WHERE company_id = :c");
|
||||
$sth = $pdo2->prepare("SELECT sku, product_name, price FROM md_product WHERE company_id = :c");
|
||||
$sth->execute([':c' => $company_id]);
|
||||
$products = $sth->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_UNIQUE);
|
||||
|
||||
$sth = $pdo2->prepare("SELECT id, contact_name FROM md_contact WHERE company_id = :c AND contact_type = 1 ORDER BY id");
|
||||
// contact_type holds an md_contact_type id — resolve 'Customer' by name, not by a fixed id.
|
||||
$sth = $pdo2->prepare(
|
||||
"SELECT c.id, c.contact_name FROM md_contact c
|
||||
JOIN md_contact_type t ON t.company_id = c.company_id AND t.id = c.contact_type
|
||||
WHERE c.company_id = :c AND t.contact_type = 'Customer' ORDER BY c.id"
|
||||
);
|
||||
$sth->execute([':c' => $company_id]);
|
||||
$customers = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||
$customer_ids = array_column($customers, 'id');
|
||||
|
||||
Reference in New Issue
Block a user