! -> Note
$ -> Affected files
+30-Dec-2010 Janusz Dobrowolski
++ Added option for using GRN Clearing Account for yet non invoiced GRNs.
+$ /purchasing/includes/po_class.inc
+ /purchasing/includes/db/grn_db.inc
+ /purchasing/includes/db/invoice_db.inc
+ /sql/en_US-demo.sql
+ /sql/en_US-new.sql
+! Added GRN clearing account setting
+$ /admin/gl_setup.php
+! Added set_company_pref() function
+$ /admin/db/company_db.inc
+
29-Dec-2010 Janusz Dobrowolski
! Hook files inclusion moved to session.inc
$ /includes/hooks.inc
$grn = add_grn_batch($po->order_no, $po->supplier_id, $po->reference, $po->Location, $date_);
+ $clearing_act = get_company_pref('grn_clearing_act');
+ if ($clearing_act) { // otherwise GRN clearing account is not used
+ $total = 0;
+ $supplier_accounts = get_supplier_accounts($po->supplier_id);
+ }
foreach ($po->line_items as $line_no => $order_line)
{
-
if ($order_line->receive_qty != 0 && $order_line->receive_qty != "" && isset($order_line->receive_qty))
{
+ $stock_gl_code = get_stock_gl_code($order_line->stock_id);
+
+ if($clearing_act) {
+ $inv_act = (is_inventory_item($order_line->stock_id) ? $stock_gl_code["inventory_account"] :
+ ($supplier_accounts["purchase_account"] ? $supplier_accounts["purchase_account"] : $stock_gl_code["cogs_account"]));
+ $total += add_gl_trans_supplier(ST_SUPPRECEIVE, $grn, $date_, $inv_act,
+ $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'],
+ $order_line->receive_qty * $order_line->taxfree_charge_price($po), $po->supplier_id);
+ }
/*Update sales_order_details for the new quantity received and the standard cost used for postings to GL and recorded in the stock movements for FIFO/LIFO stocks valuations*/
//------------------- update average material cost ------------------------------------------ Joe Hunt Mar-03-2008
if (is_inventory_item($order_line->stock_id))
} /*quantity received is != 0 */
} /*end of order_line loop */
+ if ($clearing_act) {
+ $total += add_gl_trans_supplier(ST_SUPPRECEIVE, $grn, $date_, $clearing_act,
+ 0, 0, -$total, $po->supplier_id);
+ }
$Refs->save(ST_SUPPRECEIVE, $grn, $po->reference);
add_audit_trail(ST_SUPPRECEIVE, $grn, $date_);
$trans_type, $invoice_id, $entered_gl_code->amount,
$ex_rate, $date_, $supp_trans->supp_reference, $supp_trans->tax_included);
}
+
+ $clearing_act = get_company_pref('grn_clearing_act');
foreach ($supp_trans->grn_items as $line_no => $entered_grn)
{
$line_taxfree = $entered_grn->taxfree_charge_price($supp_trans->tax_group_id);
$line_tax = $entered_grn->full_charge_price($supp_trans->tax_group_id) - $line_taxfree;
$stock_gl_code = get_stock_gl_code($entered_grn->item_code);
- $iv_act = (is_inventory_item($entered_grn->item_code) ? $stock_gl_code["inventory_account"] :
- ($supplier_accounts["purchase_account"] ? $supplier_accounts["purchase_account"] : $stock_gl_code["cogs_account"]));
+
+ $iv_act = $clearing_act ? $clearing_act : (is_inventory_item($entered_grn->item_code) ? $stock_gl_code["inventory_account"] :
+ ($supplier_accounts["purchase_account"] ? $supplier_accounts["purchase_account"] : $stock_gl_code["cogs_account"]));
+
$total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $iv_act,
$stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'],
$entered_grn->this_quantity_inv * $line_taxfree, $supp_trans->supplier_id);
- /*$total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $iv_act,
- $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'],
- $entered_grn->this_quantity_inv * $line_taxfree, $supp_trans->supplier_id);*/
+
// -------------- if price changed since po received. 16 Aug 2008 Joe Hunt
if ($trans_type == ST_SUPPINVOICE)
{
$this->standard_cost =0;
$this->grn_item_id = $grn_item_id;
}
+
+ function taxfree_charge_price($po)
+ {
+ return get_tax_free_price_for_item($this->stock_id, $this->price,
+ $po->tax_group_id, $po->tax_included, $po->tax_group_array);
+ }
}
?>
INSERT INTO `0_sys_prefs` VALUES('default_workorder_required', 'glsetup.manuf', 'int', 11, '20');
INSERT INTO `0_sys_prefs` VALUES('version_id', 'system', 'varchar', 11, '2.3rc');
INSERT INTO `0_sys_prefs` VALUES('auto_curr_reval', 'setup.company', 'smallint', 6, '1');
+INSERT INTO `0_sys_prefs` VALUES('grn_clearing_act', 'glsetup.purchase', 'varchar', 15, '1550');
-- --------------------------------------------------------
INSERT INTO `0_sys_prefs` VALUES('default_workorder_required', 'glsetup.manuf', 'int', 11, '20');
INSERT INTO `0_sys_prefs` VALUES('version_id', 'system', 'varchar', 11, '2.3rc');
INSERT INTO `0_sys_prefs` VALUES('auto_curr_reval', 'setup.company', 'smallint', 6, '1');
+INSERT INTO `0_sys_prefs` VALUES('grn_clearing_act', 'glsetup.purchase', 'varchar', 15, '1550');
-- --------------------------------------------------------