function check_data()
{
    global $total_grn_value, $total_gl_value, $Refs, $SysPrefs;
    if (!$_SESSION['supp_trans']->is_valid_trans_to_post()) {
        display_error(_("The credit note cannot be processed because the there are no items or values on the invoice.  Credit notes are expected to have a charge."));
        set_focus('');
        return false;
    }
    if (!$Refs->is_valid($_SESSION['supp_trans']->reference)) {
        display_error(_("You must enter an credit note reference."));
        set_focus('reference');
        return false;
    }
    if (!is_new_reference($_SESSION['supp_trans']->reference, ST_SUPPCREDIT)) {
        display_error(_("The entered reference is already in use."));
        set_focus('reference');
        return false;
    }
    if (!$Refs->is_valid($_SESSION['supp_trans']->supp_reference)) {
        display_error(_("You must enter a supplier's credit note reference."));
        set_focus('supp_reference');
        return false;
    }
    if (!is_date($_SESSION['supp_trans']->tran_date)) {
        display_error(_("The credit note as entered cannot be processed because the date entered is not valid."));
        set_focus('tran_date');
        return false;
    } elseif (!is_date_in_fiscalyear($_SESSION['supp_trans']->tran_date)) {
        display_error(_("The entered date is not in fiscal year."));
        set_focus('tran_date');
        return false;
    }
    if (!is_date($_SESSION['supp_trans']->due_date)) {
        display_error(_("The invoice as entered cannot be processed because the due date is in an incorrect format."));
        set_focus('due_date');
        return false;
    }
    if ($_SESSION['supp_trans']->ov_amount < $total_gl_value + $total_grn_value) {
        display_error(_("The credit note total as entered is less than the sum of the the general ledger entires (if any) and the charges for goods received. There must be a mistake somewhere, the credit note as entered will not be processed."));
        return false;
    }
    if (!$SysPrefs->allow_negative_stock()) {
        foreach ($_SESSION['supp_trans']->grn_items as $n => $item) {
            if (is_inventory_item($item->item_code)) {
                if (check_negative_stock($item->item_code, -$item->this_quantity_inv, null, $_SESSION['supp_trans']->tran_date)) {
                    $stock = get_item($item->item_code);
                    display_error(_("The return cannot be processed because there is an insufficient quantity for item:") . " " . $stock['stock_id'] . " - " . $stock['description'] . " - " . _("Quantity On Hand") . " = " . number_format2($qoh, get_qty_dec($stock['stock_id'])));
                    return false;
                }
            }
        }
    }
    return true;
}
function check_item_data()
{
    global $SysPrefs, $allow_negative_prices;
    $is_inventory_item = is_inventory_item(get_post('stock_id'));
    if (!get_post('stock_id_text', true)) {
        display_error(_("Item description cannot be empty."));
        set_focus('stock_id_edit');
        return false;
    } elseif (!check_num('qty', 0) || !check_num('Disc', 0, 100)) {
        display_error(_("The item could not be updated because you are attempting to set the quantity ordered to less than 0, or the discount percent to more than 100."));
        set_focus('qty');
        return false;
    } elseif (!check_num('price', 0) && (!$allow_negative_prices || $is_inventory_item)) {
        display_error(_("Price for inventory item must be entered and can not be less than 0"));
        set_focus('price');
        return false;
    } elseif (isset($_POST['LineNo']) && isset($_SESSION['Items']->line_items[$_POST['LineNo']]) && !check_num('qty', $_SESSION['Items']->line_items[$_POST['LineNo']]->qty_done)) {
        set_focus('qty');
        display_error(_("You attempting to make the quantity ordered a quantity less than has already been delivered. The quantity delivered cannot be modified retrospectively."));
        return false;
    }
    $cost_home = get_standard_cost(get_post('stock_id'));
    // Added 2011-03-27 Joe Hunt
    $cost = $cost_home / get_exchange_rate_from_home_currency($_SESSION['Items']->customer_currency, $_SESSION['Items']->document_date);
    if (input_num('price') < $cost) {
        $dec = user_price_dec();
        $curr = $_SESSION['Items']->customer_currency;
        $price = number_format2(input_num('price'), $dec);
        if ($cost_home == $cost) {
            $std_cost = number_format2($cost_home, $dec);
        } else {
            $price = $curr . " " . $price;
            $std_cost = $curr . " " . number_format2($cost, $dec);
        }
        display_warning(sprintf(_("Price %s is below Standard Cost %s"), $price, $std_cost));
    }
    return true;
}
Beispiel #3
0
     $_GET['stock_id'] = $stock_id;
     $_GET['popup'] = 1;
     include_once $path_to_root . "/inventory/prices.php";
     break;
 case 'purchase_pricing':
     $_GET['stock_id'] = $stock_id;
     $_GET['popup'] = 1;
     include_once $path_to_root . "/inventory/purchasing_data.php";
     break;
 case 'standard_cost':
     $_GET['stock_id'] = $stock_id;
     $_GET['popup'] = 1;
     include_once $path_to_root . "/inventory/cost_update.php";
     break;
 case 'reorder_level':
     if (!is_inventory_item($stock_id)) {
         break;
     }
     $_GET['stock_id'] = $stock_id;
     $_GET['popup'] = 1;
     include_once $path_to_root . "/inventory/reorder_level.php";
     break;
 case 'movement':
     $_GET['stock_id'] = $stock_id;
     $_GET['popup'] = 1;
     include_once $path_to_root . "/inventory/inquiry/stock_movements.php";
     break;
 case 'status':
     $_GET['stock_id'] = $stock_id;
     $_GET['popup'] = 1;
     include_once $path_to_root . "/inventory/inquiry/stock_status.php";