$purchase_detail = new Purchase_detail(); } else { $purchase_detail = new Purchase_detail($row->{'detailId'}); } $purchase_detail->setDocNumber($key); $purchase_detail->setItemId($row->{'itemCode'}); $purchase_detail->setDescription($row->{'itemDesc'}); $purchase_detail->setQuantity($row->{'itemQuan'}); $purchase_detail->setUnitPrice($row->{'itemUnitP'}); $extendedPrice = $row->{'itemQuan'} * $row->{'itemUnitP'}; $total = $total + $extendedPrice; $purchase_detail->setExtendedPrice(round($extendedPrice, 2)); //$purchase_detail->setExtendedPrice($row->{'itemExtP'}); if ($_POST['approver_1'] != null && $_POST['approver_1_date'] != null) { $item = new Inv_item($row->{'itemCode'}); $item->setCurrencyId($purchase->getCurrency()); $item->setRate($row->{'itemUnitP'}); $item->store(); } if (!$error) { $purchase_detail->store(); } } catch (fExpectedException $e) { echo $e->printMessage(); $error = true; } } if (!$error) { $total = $total - $_POST['discount']; $purchase->setTotal(round($total, 2)); $purchase->store();