/** * Build the line * */ public static function makeLine($order, $orderline, &$errors) { $despatchline = array(); if ($order->isLoaded()) { if ($order->customerdetails->accountStopped()) { $errors['id' . $order->id] = 'Cannot despatch order ' . $order->order_number . ' (' . $order->customerdetails->name . ') Account Stopped'; } else { $despatchline['order_id'] = $order->id; $despatchline['orderline_id'] = $orderline->id; $despatchline['slmaster_id'] = $order->slmaster_id; $despatchline['stuom_id'] = $orderline->stuom_id; if ($orderline->stitem_id) { $despatchline['stitem_id'] = $orderline->stitem_id; } if ($orderline->productline_id) { $despatchline['productline_id'] = $orderline->productline_id; } $despatchline['despatch_qty'] = $orderline->os_qty; $despatchline['despatch_date'] = date(DATE_FORMAT); $despatchline['despatch_action'] = $order->despatch_action; $despatchline['status'] = 'N'; $stitem = new STItem(); $stitem->load($data['stitem_id']); $param = new GLParams(); $net_mass_uom_id = $param->intrastat_net_mass(); if ($stitem->isLoaded() && !empty($net_mass_uom_id)) { $despatchline['net_mass'] = $stitem->convertToUoM($despatchline['stuom_id'], $net_mass_uom_id, $despatchline['despatch_qty']); } } } if (empty($despatchline['net_mass']) || $despatchline['net_mass'] === false) { $despatchline['net_mass'] = 0; } return $despatchline; }