Multiple, shops, employee and branches

You can do setup like below (assuming branch is not a legal entity and not having independent license/registration)

  • Create cost_center/branch wise warehouses.
  • Add Custom Fields
    cost_center/branch in Warehouse Doctype
    default_warehouse in Cost Center/Branch Doctype
  • Add Branch as Accounting Dimension (Cost Center Accounting Dimension is already exists in all the documents by default)
  • Write Custom Script to fetch default warehouse, update warehouse query filter and set parent value in child
  • Setup User Permission to restrict user to access only allowed cost_center/branch

Sample Custom Script for Sales Invoice

frappe.ui.form.on('Sales Invoice', {
	setup: function(frm){
		frm.add_fetch('cost_center', 'default_warehouse', 'warehouse');
		frm.add_fetch('cost_center', 'default_warehouse', 'set_warehouse');	
	},
	cost_center: function(frm){
		cur_frm.cscript.overrides_parent_value_in_all_rows(frm, "items", "cost_center", "cost_center");
		cur_frm.cscript.overrides_parent_value_in_all_rows(frm, "taxes", "cost_center", "cost_center");		
	},
})

cur_frm.cscript.overrides_parent_value_in_all_rows = function(frm, table_fieldname, parent_fieldname, fieldname){
	$.each(frm.doc[table_fieldname] || [], function(i, row) {
		row[fieldname] = frm.doc[parent_fieldname];
	});			
	frm.refresh_field(table_fieldname);
} 

$.extend(erpnext.queries, {
	warehouse: function(doc) {
		return {
			filters: [
				["Warehouse", "company", "in", ["", cstr(doc.company)]],
				["Warehouse", "is_group", "=",0],
				["Warehouse", "cost_center", "=", cstr(doc.cost_center)]				

			]
		};
	},
});

After above setup, you can:

  1. Do inter-branch stock transfer (material transfer from one warehouse to another)
  2. See branch-wise profitability report
  3. Define branch-wise Income/Expense/Stock Account
  4. Maintain branch wise Cash/Bank Accounts (like warehouse, you can add custom fields for default cash/bank account in Cost Center/Branch Doctype.

Note : Instead of Branch you can also use Cost Center which is available by default in all the documents.

Hope this will help you.

1 Like