return $diff;
}
//----------------------------------------------------------------------------------------
-
function add_supp_invoice(&$supp_trans)
{
global $Refs;
foreach ($taxes as $n => $taxitem)
$item_added_tax += isset($taxitem['Override']) ? $taxitem['Override'] : round2($taxitem['Value'], user_price_dec());
}
-
if ($trans_type == ST_SUPPCREDIT)
{
// let's negate everything because it's a credit note
$ref = $Refs->get_next(ST_JOURNAL, null, $date_);
add_journal(ST_JOURNAL, $id, $diff, $date_, get_company_currency(), $ref);
$stock_id = $entered_grn->item_code;
- $stock_gl_code = get_stock_gl_code($stock_id);
$memo = _("Supplier invoice adjustment for zero inventory of ").$stock_id." "._("Invoice")." ".$supp_trans->reference;
//Reverse the inventory effect if $qoh <=0
add_gl_trans_std_cost(ST_JOURNAL, $id, $date_,
$supp_trans->add_grn_to_trans($details_row["grn_item_id"], $details_row["po_detail_item_id"], $details_row["stock_id"],
$details_row["description"],
$details_row['qty_recd'],
- $details_row['quantity_inv']-$details_row["quantity"],
- $details_row["quantity"], 0, $details_row["FullUnitPrice"],
+ $details_row['quantity_inv'],
+ ($trans_type == ST_SUPPCREDIT ? -1 : 1) * $details_row["quantity"], 0, $details_row["FullUnitPrice"], // SUPPCREDIT quantities are stored negative in database
0, 0);
}
else
//Reverse the inventory effect if $qoh <=0
add_gl_trans_std_cost(ST_JOURNAL, $id, $old_date,
$stock_gl_code["inventory_account"],
- $dim, $dim2, $memo, $details_row["quantity"] * $diff);
+ $details_row['dimension_id'], $details_row['dimension2_id'], $memo, $details_row["quantity"] * $diff);
//GL Posting to inventory adjustment account
add_gl_trans_std_cost(ST_JOURNAL, $id, $old_date,
$stock_gl_code["adjustment_account"],
- $dim, $dim2, $memo, -$details_row["quantity"] * $diff);
+ $details_row['dimension_id'], $details_row['dimension2_id'], $memo, -$details_row["quantity"] * $diff);
add_audit_trail(ST_JOURNAL, $id, $old_date);
add_comments(ST_JOURNAL, $id, $old_date, $memo);