- $tax_items = get_shipping_tax_as_array();
- $tax_rate = 0;
- if ($tax_items != null) {
- foreach ($tax_items as $item_tax) {
- $index = $item_tax['tax_type_id'];
- if (isset($this->tax_group_array[$index])) {
- $tax_rate += $item_tax['rate'];
- }
+ return $freight['Tax'];
+ }
+ /*
+ Returns transaction value including all taxes
+ */
+ function get_trans_total() {
+
+ $total = $this->get_items_total() + $this->freight_cost;
+ $dec = user_price_dec();
+ if (!$this->tax_included ) {
+ $total += $this->get_shipping_tax();
+ $taxes = $this->get_taxes();
+ foreach($taxes as $tax)
+ $total += round($tax['Value'], $dec);
+ }
+
+ return $total;
+ }
+
+ /*
+ Checks cart quantities on document_date.
+ Returns array of stock_ids which stock quantities would go negative on some day.
+ */
+ function check_qoh($date=null, $location=null)
+ {
+ $low_stock = array();
+ // check only for customer delivery and direct sales invoice
+ if (!($this->trans_type == ST_CUSTDELIVERY || ($this->trans_type == ST_SALESINVOICE && $this->trans_no==0)))
+ return $low_stock;
+
+ // collect quantities by stock_id
+ $qtys = array();
+ foreach ($this->line_items as $line_no => $line_item)
+ {
+ if (has_stock_holding($line_item->mb_flag))
+ {
+ if (!$this->trans_no) // new delivery
+ $qtys[$line_item->stock_id]['qty'] = $line_item->qty_dispatched + @$qtys[$line_item->stock_id]['qty'];
+ else // DN modification: check change in quantity
+ $qtys[$line_item->stock_id]['qty'] = ($line_item->qty_dispatched-$line_item->qty_old) + @$qtys[$line_item->stock_id]['qty'];
+ $qtys[$line_item->stock_id]['line'] = $line_no;