+ $qoh = get_qoh_on_date($entered_grn->item_code);
+ if ($qoh <= 0)
+ {
+ global $Refs;
+
+ //Chaitanya : Post a journal entry
+ $id = get_next_trans_no(ST_JOURNAL);
+ $ref = $Refs->get_next(ST_JOURNAL);
+ $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_,
+ $stock_gl_code["inventory_account"],
+ $dim, $dim2, $memo, -$entered_grn->this_quantity_inv * $diff);
+ //GL Posting to inventory adjustment account
+ add_gl_trans_std_cost(ST_JOURNAL, $id, $date_,
+ $stock_gl_code["adjustment_account"],
+ $dim, $dim2, $memo, $entered_grn->this_quantity_inv * $diff);
+
+ add_audit_trail(ST_JOURNAL, $id, $date_);
+ add_comments(ST_JOURNAL, $id, $date_, $memo);
+ $Refs->save(ST_JOURNAL, $id, $ref);
+ }
+
+ /*$qoh = get_qoh_on_date($entered_grn->item_code);
+ if ($qoh <= 0)
+ {
+ $memo = "Diff. in cost: ".$diff;
+ //Reverse the inventory effect if $qoh <=0
+ add_gl_trans_supplier($trans_type, $invoice_id, $date_,
+ $stock_gl_code["inventory_account"],
+ $dim, $dim2, -$entered_grn->this_quantity_inv * $diff, $supp_trans->supplier_id, "", null, $memo);
+ //GL Posting to inventory adjustment account
+ add_gl_trans_supplier($trans_type, $invoice_id, $date_,
+ $stock_gl_code["adjustment_account"],
+ $dim, $dim2, $entered_grn->this_quantity_inv * $diff, $supp_trans->supplier_id, "", null, $memo);
+ }*/
+
+ //add_gl_trans($trans_type, $invoice_id, $date_, $stock_gl_code["cogs_account"],
+ // 0, 0, 'GRN Provision', -$diff_amt, null, null, null,
+ // "The general ledger transaction could not be added for the GRN of the inventory item");
+ }
+ }