New stock to be adjusted against office maintenence A/c and not stock adjustment account

There is some office stationery etc. that gets added to our stock. I put the default expense account as "Office Maintenence Expense A/C " in my item master. However, When I see it in accounting ledger, the transaction is adjusted against “Stock Adjustment Account”.

Can someone explain the steps, if I wish to separate accounts of these my main items and my office maintenance items.

Are you entering opening stock from Item master only? Or creating manual Stock Entry document?

@nabinhait

I just created an item master for my office stationary and set in the excel template, set the default expense account as “Office Maintenance Expense Account”.

I make a manual stock entry for “pens” and observe the changes in accounting ledger?

What is going wrong?

In Stock Entry, the default expense account is set based on “Stock Adjustment” account in Company master. If you want to change the expense account, you can change the account manually in Stock Entry Item table.

Apart from Stock Entry, in Delivery Note / Sales Invoice, the default expense account are set based on Item master default.

@nabinhait- Thank you so much

Hello @nabinhait

Is there any code I can put in the default field of the difference account in Stock Entry that will populate this field with the default expense account of the item instead of the company default stock adjustment account?

Hi all,
Not sure if this is the case we had today…
Item to be classified on account (internal) and instead when doing material issue the system uses stock adjustment account…
Temp. Solution was to sent the expense account on item (selling tab) and untick the Is selling item… After a code on stock entry to check if is_sales_item not active and set the expense account = item. Expense_account.

Hope this helps.

1 Like

Hi @Helio_Jesus

Can you share the code ??

Thanks

Not a problem…
First on the item you need to set the Income_account (accounting classification as per the accountant) after you untick the “Is Sales Item”

After you apply this custom script that when doing Stock - Material Issue for all material used by the company not to be set as a Profit (Stock Adjustment).

Custom script for Stock Entry (when Material Issue)

frappe.ui.form.on(“Stock Entry Detail”,“item_code”, function(doc,cdt,cdn) {
var d = locals[cdt][cdn]

if (d.item_code){
	console.log('Item')
	console.log(d.item_code)
	console.log(d.expense_account)
	//verify if Not for sales item and get the Account for Expense to replace the existing expense_account
	
	frappe.model.with_doc("Item", d.item_code, function() { 
		var not_for_sale_item = frappe.model.get_doc("Item",d.item_code)		
		console.log('Not for SALES')
		console.log(not_for_sale_item.is_sales_item)
		console.log(not_for_sale_item.income_account)
		if (not_for_sale_item.is_sales_item == 0) {
				d.expense_account = not_for_sale_item.income_account
		}	
	
	
	});
	

}

});

1 Like

Thanks

But could you help look at the script again? Did you copy it in full? Am getting an error message when I try to open a new stock entry form

Regards

@olamide_shodunke the script is complete…
Create new Custom Script and select the doctype as “Stock Entry” and paste the full code i sent on the previous message…

1 Like

Thanks to @Helio_Jesus, I was able to solve my case:

The account should be pulled from a custom field on the Items table (Called “Manufacturing Account”). And only when making Stock Entries of type Manufacturing.

Here is my script in case it is helpful to someone else:

// Helper to determine if the Stock Entry is of type Manufacture
var temporalIsManufacture = false

// Here we determine the kind of Stock Entry
frappe.ui.form.on('Stock Entry','purpose', function(theObject,cdt,cdn) {
    if(theObject.doc.purpose == 'Manufacture') {
        temporalIsManufacture = true
        console.log('Heads up: Manufacture selected')
    } else {
        console.log('Do not bother')
    }
});

// Here we check on every item entry
frappe.ui.form.on('Stock Entry Detail','item_code', function(doc,cdt,cdn) {
    var d = locals[cdt][cdn]
    
    if(temporalIsManufacture) {

        if (d.item_code){
        	console.log('Selected Item on the Stock Entry')
        	console.log(d.item_code)
    
        	// We'll work with the Item object
        	frappe.model.with_doc("Item", d.item_code, function() { 
        		var temporal_item_selected = frappe.model.get_doc("Item",d.item_code)		
        		if (temporal_item_selected.xmanufacturing_account) {
        		    d.expense_account = temporal_item_selected.xmanufacturing_account
                    console.log('Account changed to the specified on the Item master')
        		} else {
                    frappe.msgprint('IMPORTANTE: El item seleccionado no tiene asignada una Cuenta de Manufactura.\nAsegúrese que la cuenta imputada en el detalle es la correcta.');
                    console.log('Used warned as the item master does not have a Manufacturing Account')
        		}
        	});
        }
    }
});
1 Like