line.quantity,
discount_percent,
qty_sent as qty_done,
+ item.long_description,
item.units,
item.mb_flag,
item.material_cost
allocs.ord_payments,
inv.inv_payments,
sorder.total,
- sorder.trans_type
+ sorder.trans_type,
+ sorder.debtor_no
FROM ".TB_PREF."sales_orders as sorder
LEFT JOIN (SELECT trans_no_to, sum(amt) ord_payments FROM ".TB_PREF."cust_allocations WHERE trans_type_to=".ST_SALESORDER." GROUP BY trans_no_to)
allocs ON sorder.trans_type=".ST_SALESORDER." AND allocs.trans_no_to=sorder.order_no