Thursday, August 1, 2013

COST Calculation + Cost Account customization

PAckages

CSTPACDP.insert_account  - this will store data in mtl_transaction_accounts.

For customization

           if (l_std_from_org <> 0) then    -- To see if there is COGS account from Hook
               l_acct := CSTPSCHK.std_get_account_id(l_from_org, p_txn_id, -1*sign(l_snd_qty), 2,
                                  l_cost_element, null, l_from_subinv, l_from_cg,
                                  0, 1, l_err_num, l_err_code, l_err_msg);
            else
      /*BUG 8206088 ADDED 'l_from_cg' */
               l_acct := CSTPACHK.get_account_id(l_from_org, p_txn_id, -1*sign(l_snd_qty), 2,
                                  l_cost_element, null, l_from_subinv,
                                  0, 1, l_err_num, l_err_code, l_err_msg,l_from_cg);
            end if;



DEFAULT COGS ACCOUNT

        SELECT nvl(MSI.cost_of_sales_account, MP.cost_of_sales_account)
        INTO l_om_ccid
        FROM mtl_system_items MSI, mtl_parameters MP
        WHERE MSI.organization_id = l_from_org
        AND   MSI.inventory_item_id = p_item_id
        AND   MP.organization_id = MSI.organization_id;

        INV_WORKFLOW.call_generate_cogs(l_rcv_coa_id, l_cust_id, p_item_id, l_header_id, l_line_id,
                     l_order_type, l_to_ou, l_inv_ccid, l_concat_seg, l_msg_data, l_to_org)



Check if item is ASSET or EXPENSE ITEM
     SELECT decode(inventory_asset_flag, 'Y', 0, 1)
     INTO l_from_exp_item
     FROM mtl_system_items_b
     WHERE organization_id = l_from_org
     AND inventory_item_id = p_item_id;


-------------------------------------------------------------------------------------------------------

CSTPACHK, procedure actual_cost_hook is function called from Oracle standard package CSTPAVCP which use to process all material transactions.

         -- If the sending org is standard costing, get costs from CIC, otherwise from MCACD
         if (l_std_from_org <> 0) then
            l_stmt_num := 190;

            /* Bug 3239084: use cst_item_cost_details from the costing org to support cost sharing */
            SELECT sum(item_cost)
            INTO l_elem_cost
            FROM cst_item_cost_details
            WHERE inventory_item_id = p_item_id
            AND   cost_element_id = l_cost_element
            AND   cost_type_id = 1
            AND   organization_id =
                  (select cost_organization_id
                   from mtl_parameters
                   where organization_id = l_from_org);
         else
            l_stmt_num := 200;

            SELECT layer_id
            INTO l_from_layer
            FROM cst_quantity_layers
            WHERE inventory_item_id = p_item_id
            AND organization_id = l_from_org
            AND cost_group_id = l_from_cg;

            l_stmt_num := 210;

            SELECT sum(actual_cost)
            INTO l_elem_cost
            FROM mtl_cst_actual_cost_details
            WHERE transaction_id = p_txn_id
            AND organization_id = l_from_org
            AND cost_element_id = l_cost_element
            AND layer_id = l_from_layer;
         end if;

No comments:

Post a Comment