Merged last changes from stable.
[fa-stable.git] / purchasing / includes / ui / invoice_ui.inc
index 298fcb828f33d9fb665673fad6b7d7f481b0af4f..983e507c9e8d5273ee9bdd2701ceb5c8ea5d8a4f 100644 (file)
@@ -20,6 +20,11 @@ function copy_from_trans(&$supp_trans)
        $_POST['reference'] = $supp_trans->reference;
        $_POST['supplier_id'] = $supp_trans->supplier_id;
        $_POST['tax_algorithm'] = $supp_trans->tax_algorithm;
+
+       $_POST['_ex_rate'] = $supp_trans->ex_rate;
+       if (isset($supp_trans->tax_overrides))
+           foreach($supp_trans->tax_overrides as $id => $value)
+                   $_POST['mantax'][$id] = price_format($value);
 }
 
 //--------------------------------------------------------------------------------------------------
@@ -34,7 +39,17 @@ function copy_to_trans(&$supp_trans)
        if (isset($_POST['tax_algorithm']))
            $supp_trans->tax_algorithm = $_POST['tax_algorithm'];
 
-       $supp_trans->ov_amount = 0; /* for starters */
+       $supp_trans->ex_rate = input_num('_ex_rate', null);
+
+       $supp_trans->ov_amount = $supp_trans->ov_discount = 0; /* for starters */
+    if (isset($_POST['mantax'])) {
+               foreach($_POST['mantax'] as $id => $tax) {
+               $supp_trans->tax_overrides[$id] = user_numeric($_POST['mantax'][$id]);
+               }
+       }
+       else
+               unset($supp_trans->tax_overrides);
+
        if (count($supp_trans->grn_items) > 0)
        {
                foreach ( $supp_trans->grn_items as $grn)
@@ -135,7 +150,7 @@ function invoice_header(&$supp_trans)
        if ($supplier_currency != $company_currency)
        {
         label_row(_("Supplier's Currency:"), "<b>" . $supplier_currency . "</b>");
-               exchange_rate_display($supplier_currency, $company_currency, $_POST['tran_date']);
+               exchange_rate_display($company_currency, $supplier_currency, $_POST['tran_date']);
        }
 
        label_row(_("Tax Group:"), $supp_trans->tax_description);
@@ -159,7 +174,7 @@ function invoice_totals(&$supp_trans)
        label_row(_("Sub-total:"), price_format( $supp_trans->ov_amount), "colspan=$colspan align=right", "align=right");
 
     $taxes = $supp_trans->get_taxes($supp_trans->tax_group_id);
-    $tax_total = display_edit_tax_items($taxes, $colspan, $supp_trans->tax_included);
+    $tax_total = display_edit_tax_items($taxes, $colspan, $supp_trans->tax_included, 0, true);
 
     $display_total = price_format($supp_trans->ov_amount + $tax_total);
 
@@ -468,7 +483,8 @@ function display_grn_items(&$supp_trans, $mode=0)
                if ($supp_trans->trans_type == ST_SUPPCREDIT)
                {
                        echo "</td>";
-                       date_cells(_("Received between"), 'receive_begin', "", null, -30, 0, 0, "valign=middle");
+                       date_cells(_("Received between"), 'receive_begin', "", null, 
+                               -$_SESSION["wa_current_user"]->prefs->transaction_days(), 0, 0, "valign=middle");
                        date_cells(_("and"), 'receive_end', '', null, 1, 0, 0, "valign=middle");
                        submit_cells('RefreshInquiry', _("Search"),'',_('Refresh Inquiry'), true);
                        echo "<td>";