devsofttech_hms_ci4/scratch/check_recent_sales.php
DevSoftTech Server d2f069e3c8 feat(medical-store): add B2C sales returns, same-invoice exchanges, and DB migrations
- Add B2C same-invoice exchange and pure refund workflows (Marg ERP standard)
- Support returning excess/unused medicines with proportional unit pricing on original invoice
- Auto-net return credits against new medicines in POS cart with refund outflow handling
- Implement stock replenishment for restocked batches with audit trail in mst_stock_audit
- Generate sequential GST Credit Notes in mst_sale_returns and mst_sale_return_items
- Update Thermal 80mm, A5, and A4 print templates with separated dispensed vs returned items
- Add CI4 migration 2026-09-08-000001_CreateMedicalStoreReturnsAndExchanges.php for remote execution
- Add standalone SQL script scripts/sql/2026-09-08_medical_store_b2c_returns_and_exchanges.sql
2026-09-08 05:07:45 +05:30

15 lines
941 B
PHP

<?php
$mysqli = new mysqli('localhost', 'root', '', 'hms_data_ci4');
if ($mysqli->connect_error) {
die("Connection failed: " . $mysqli->connect_error);
}
$res = $mysqli->query("SELECT sale_id, invoice_no, sale_date, patient_name, uhid, net_amount, return_amount FROM mst_sales ORDER BY sale_id DESC LIMIT 5");
while ($s = $res->fetch_assoc()) {
echo "ID: {$s['sale_id']} | Bill: {$s['invoice_no']} | Date: {$s['sale_date']} | Patient: {$s['patient_name']} ({$s['uhid']}) | Net: ₹{$s['net_amount']} | Ret: ₹{$s['return_amount']}\n";
$iRes = $mysqli->query("SELECT si.*, i.item_name FROM mst_sales_items si JOIN mst_items i ON i.item_id = si.item_id WHERE si.sale_id = {$s['sale_id']}");
while ($it = $iRes->fetch_assoc()) {
echo " -> [{$it['item_type']}] {$it['item_name']} | Batch: {$it['batch_no']} | Qty: {$it['total_units']} tabs | Rate: ₹{$it['unit_price']} | Total: ₹{$it['total_amount']}\n";
}
}