Topic: Supplier Invoice
How can i edit supplier invoice?
It's much more fun, when you can discuss your problems with others...
You are not logged in. Please login or register.
FrontAccounting forum → FA Modifications → Supplier Invoice
How can i edit supplier invoice?
check this topic :
https://frontaccounting.com/punbb/viewtopic.php?id=1778
hi, i made the revision but still can't edit invoice. any suggestion?
supplier_invoice.php
//page(_($help_context = "Enter Supplier Invoice"), false, false, "", $js);
if (isset($_GET['ModifySI'])) {
//display_notification_centered(_("Modify SI TRUE<br>"));
$help_context = "Modifying Supplier Invoice";
$error_msg = '';
if (isset($_GET["trans_no"])) {
$trans_no = $_GET["trans_no"];
}
elseif (isset($_POST["trans_no"])) {
$trans_no = $_POST["trans_no"];
}
else $trans_no = null;
if ($trans_no != null) {
$_SESSION['page_title'] = sprintf(_("Modifying Supplier Invoice # %d."), $trans_no);
if (is_closed_trans(ST_SUPPINVOICE, $trans_no)) {
$error_msg = _("The selected transaction was closed for edition.");
}
else {
$void_entry = get_voided_entry(ST_SUPPINVOICE, $trans_no);
if ($void_entry != null) {
$error_msg = _("The selected transaction has already been voided.");
}
else {
$result = get_gl_trans(ST_SUPPINVOICE, $trans_no);
if (db_num_rows($result) == 0) {
$error_msg = _("Cannot find Supplier Invoice # ") . $trans_no;
}
}
}
}
else {
$_SESSION['page_title'] = _("Modifying Supplier Invoice (with missing #).");
$error_msg = _("Supplier Invoice # is missing!");
}
if ($error_msg == '') {
$supp_trans = new supp_trans(ST_SUPPINVOICE);
read_supp_invoice($trans_no, ST_SUPPINVOICE, $supp_trans);
page($_SESSION['page_title'], false, false,'', $js);
$_SESSION['supp_trans'] = $supp_trans;
$_SESSION['inv_modify'] = true;
$_SESSION['old_trans'] = $trans_no;
$_SESSION['old_date'] = $supp_trans->tran_date;
}
else {
$_SESSION['inv_modify'] = false;
$_SESSION['old_trans'] = null;
$_SESSION['old_date'] = null;
page($_SESSION['page_title'], false, false,'', $js);
display_error($error_msg);
end_page(true);
exit;
}
}
elseif (isset($_GET['New'])) {
//display_notification_centered(_("New TRUE, Modify SI FALSE<br>"));
$_SESSION['inv_modify'] = false;
$_SESSION['old_trans'] = null;
$_SESSION['old_date'] = null;
page(_($help_context = "Enter Supplier Invoice"), false, false, "", $js);
}
else {
//display_notification_centered(_("Modify SI unchanged...<br>"));
page(_($help_context = "Enter Supplier Invoice"), false, false, "", $js);
}
//----------------------------------------------------------------------------------------
check_db_has_suppliers(_("There are no suppliers defined in the system."));
//---------------------------------------------------------------------------------------------------------------
if (isset($_GET['AddedID']))
{
$invoice_no = $_GET['AddedID'];
$trans_type = ST_SUPPINVOICE;
echo "<center>";
display_notification_centered(_("Supplier invoice has been processed."));
display_note(get_trans_view_str($trans_type, $invoice_no, _("View this Invoice")));
display_note(get_gl_view_str($trans_type, $invoice_no, _("View the GL Journal Entries for this Invoice")), 1);
hyperlink_no_params("$path_to_root/purchasing/supplier_payment.php", _("Entry supplier &payment for this invoice"));
hyperlink_params($_SERVER['PHP_SELF'], _("Enter Another Invoice"), "New=1");
hyperlink_params("$path_to_root/admin/attachments.php", _("Add an Attachment"), "filterType=$trans_type&trans_no=$invoice_no");
display_footer_exit();
}
//--------------------------------------------------------------------------------------------------
if (isset($_GET['New']))
{
if (isset( $_SESSION['supp_trans']))
{
unset ($_SESSION['supp_trans']->grn_items);
unset ($_SESSION['supp_trans']->gl_codes);
unset ($_SESSION['supp_trans']);
}
$_SESSION['supp_trans'] = new supp_trans(ST_SUPPINVOICE);
}
//--------------------------------------------------------------------------------------------------
function clear_fields()
{
global $Ajax;
unset($_POST['gl_code']);
unset($_POST['dimension_id']);
unset($_POST['dimension2_id']);
unset($_POST['amount']);
unset($_POST['memo_']);
unset($_POST['AddGLCodeToTrans']);
$Ajax->activate('gl_items');
set_focus('gl_code');
}
function reset_tax_input()
{
global $Ajax;
unset($_POST['mantax']);
$Ajax->activate('inv_tot');
}
//------------------------------------------------------------------------------------------------
// GL postings are often entered in the same form to two accounts
// so fileds are cleared only on user demand.
//
if (isset($_POST['ClearFields']))
{
clear_fields();
}
if (isset($_POST['AddGLCodeToTrans'])){
$Ajax->activate('gl_items');
$input_error = false;
$result = get_gl_account_info($_POST['gl_code']);
if (db_num_rows($result) == 0)
{
display_error(_("The account code entered is not a valid code, this line cannot be added to the transaction."));
set_focus('gl_code');
$input_error = true;
}
else
{
$myrow = db_fetch_row($result);
$gl_act_name = $myrow[1];
if (!check_num('amount'))
{
display_error(_("The amount entered is not numeric. This line cannot be added to the transaction."));
set_focus('amount');
$input_error = true;
}
}
if (!is_tax_gl_unique(get_post('gl_code'))) {
display_error(_("Cannot post to GL account used by more than one tax type."));
set_focus('gl_code');
$input_error = true;
}
if ($input_error == false)
{
$_SESSION['supp_trans']->add_gl_codes_to_trans($_POST['gl_code'], $gl_act_name,
$_POST['dimension_id'], $_POST['dimension2_id'],
input_num('amount'), $_POST['memo_']);
reset_tax_input();
set_focus('gl_code');
}
}
//------------------------------------------------------------------------------------------------
function check_data()
{
global $Refs;
if (!$_SESSION['supp_trans']->is_valid_trans_to_post())
{
display_error(_("The invoice cannot be processed because the there are no items or values on the invoice. Invoices are expected to have a charge."));
return false;
}
if (!$Refs->is_valid($_SESSION['supp_trans']->reference))
{
display_error(_("You must enter an invoice reference."));
set_focus('reference');
return false;
}
if (!is_new_reference($_SESSION['supp_trans']->reference, ST_SUPPINVOICE))
{
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 invoice reference."));
set_focus('supp_reference');
return false;
}
if (!is_date( $_SESSION['supp_trans']->tran_date))
{
display_error(_("The invoice as entered cannot be processed because the invoice date is in an incorrect format."));
set_focus('trans_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('trans_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 (is_reference_already_there($_SESSION['supp_trans']->supplier_id, $_POST['supp_reference']))
{ /*Transaction reference already entered */
display_error(_("This invoice number has already been entered. It cannot be entered again.") . " (" . $_POST['supp_reference'] . ")");
return false;
}
return true;
}
function handle_void_invoice()
{
if (!exists_supp_trans(ST_SUPPINVOICE, $_SESSION['old_trans']))
return false;
if (!post_void_supp_trans(ST_SUPPINVOICE, $_SESSION['old_trans']))
return false;
$ret = void_transaction(ST_SUPPINVOICE, $_SESSION['old_trans'], $_SESSION['old_date'], 'Invoice Modification - Old Version');
if ($ret)
{
display_notification_centered(_("Old invoice has been voided."));
}
else {
display_error(_("Old invoice cannot be voided."));
set_focus('trans_no');
}
return $ret;
}
//--------------------------------------------------------------------------------------------------
function handle_commit_invoice()
{
copy_to_trans($_SESSION['supp_trans']);
if (!check_data())
return;
$invoice_no = add_supp_invoice($_SESSION['supp_trans']);
$_SESSION['supp_trans']->clear_items();
unset($_SESSION['supp_trans']);
meta_forward($_SERVER['PHP_SELF'], "AddedID=$invoice_no");
}
//--------------------------------------------------------------------------------------------------
if (isset($_POST['PostInvoice']))
{
// handle_commit_invoice();
if ($_SESSION['inv_modify']) {
if (handle_void_invoice($_SESSION['old_trans'], $_SESSION['old_date'])) {
display_notification_centered(_("New invoice data:<br>") . print_r($_SESSION['supp_trans'], TRUE) . "<br>");
handle_commit_invoice();
}
}
else {
handle_commit_invoice();
}
}
journal_inquiry.php
// "/sales/customer_credit_invoice.php?ModifyCredit=%d"
// 12=> Customer Payment,
ST_CUSTDELIVERY => "/sales/customer_delivery.php?ModifyDelivery=%d",
// 16=> Location Transfer,
// 17=> Inventory Adjustment,
// 20=> Supplier Invoice,
ST_SUPPINVOICE => "/purchasing/supplier_invoice.php?ModifySI=Yes&trans_no=%d",
// 21=> Supplier Credit Note,
FrontAccounting forum → FA Modifications → Supplier Invoice
Powered by PunBB, supported by Informer Technologies, Inc.
Currently installed 4 official extensions. Copyright © 2003–2009 PunBB.