- update_average_material_cost(null, $stock_id, $standard_cost, $quantity, $date_);
-
- add_stock_move(systypes::inventory_adjustment(), $stock_id, $adj_id, $location,
- $date_, $reference, $quantity, $standard_cost, $type);
-
- if ($standard_cost > 0)
- {
-
- $stock_gl_codes = get_stock_gl_code($stock_id);
-
- add_gl_trans_std_cost(systypes::inventory_adjustment(), $adj_id, $date_,
- $stock_gl_codes['adjustment_account'], $stock_gl_codes['dimension_id'], $stock_gl_codes['dimension2_id'], $memo_, ($standard_cost * -($quantity)));
-
- add_gl_trans_std_cost(systypes::inventory_adjustment(), $adj_id, $date_, $stock_gl_codes['inventory_account'], 0, 0, $memo_, ($standard_cost * $quantity));
- }
+ add_stock_move(ST_INVADJUST, $stock_id, $adj_id, $location,
+ $date_, $reference, $quantity, $new_cost, $standard_cost);
+
+ $inv_value = $standard_cost * $quantity;
+ $adj_value = $standard_cost * -($quantity);
+
+ if (is_fixed_asset($mb_flag)) {
+ // get the initial value of the fixed assset.
+ $row = get_fixed_asset_move($stock_id, ST_SUPPRECEIVE);
+ $inv_value = $row['price'] * $quantity;
+ $adj_value = (-($row['price']) + $standard_cost) * $quantity;
+ }
+ if ($standard_cost > 0 || is_fixed_asset($mb_flag))
+ {
+ $stock_gl_codes = get_stock_gl_code($stock_id);
+ add_gl_trans_std_cost(ST_INVADJUST, $adj_id, $date_,
+ $stock_gl_codes['adjustment_account'], $stock_gl_codes['dimension_id'], $stock_gl_codes['dimension2_id'], $memo_, $adj_value );
+ add_gl_trans_std_cost(ST_INVADJUST, $adj_id, $date_, $stock_gl_codes['inventory_account'], 0, 0, $memo_, $inv_value);
+ }
+
+ if (is_fixed_asset($mb_flag)) {
+ // Additional gl entry for fixed asset.
+ $grn_act = get_company_pref('default_loss_on_asset_disposal_act');
+ add_gl_trans_std_cost(ST_INVADJUST, $adj_id, $date_, $grn_act, 0, 0, $memo_, ($standard_cost * -($quantity)));
+ }