// <#-- Part Store -->
Ext.define('App.store.PartStore', {
	extend: 'Ext.data.Store',

	constructor: function(cfg) {
		var me = this;
		cfg = cfg || {};
		me.callParent([Ext.apply({
			proxy: {
				type: 'ajax',
				url: App.url('/common/part/list.json'),
				extraParams: cfg.extraParams || {},
				reader: {
					type: 'json',
					root: 'records',
					idProperty: 'id'
				}
			},
			fields: [
				{
					name: 'id',
					type: 'int',
					useNull: true
				},
				{
					name: 'code',
					type: 'string'
				},
				{
					name: 'name',
					type: 'string'
				},
				{
					name: 'unit',
					type: 'string'
				},
				{
					name: 'balance',
					type: "number"
				},
				{
					name: 'averageCost',
					type: 'number'
				},
				{
					name: 'description',
					type: 'string'
				}
			],
			// data:[
			// 	{id: 1, code: '0001', name:'A Company'},
			// 	{id: 2,code: '0002', name:'B Company'},
			// 	{id: 3,code: '0003', name:'C Company'},
			// 	{id: 4,code: '0004', name:'D Company'},
			// ]
		},
		cfg)]);
	}
});

// <#-- Part Combo Store -->
Ext.define('App.store.PartComboStore', {
	extend: 'Ext.data.Store',
	autoLoad: true,

	constructor: function(cfg) {
		var me = this;
		cfg = cfg || {};
		me.callParent([Ext.apply({
			proxy: {
				type: 'ajax',
				url: App.url('/common/part/combo.json'),
				extraParams: cfg.extraParams || {},
				reader: {
					type: 'json',
					root: 'records',
					idProperty: 'partId'
				}
			},
			fields: [
				{
					name: 'partId',
					type: 'int',
					useNull: true
				},
				{
					name: 'partCode',
					type: 'string'
				},
				{
					name: 'partName',
					type: 'string'
				},
				{
					name: 'partUnit',
					type: 'string'
				},
				{
					name: 'equipmentPartQty',
				 	type: 'float'
				},
				{
					name: 'balance',
					type: 'float'
				},
				{
					name: 'balanceStr',
					convert: function(value, record) {
						return App.numberFormat(record.data.balance, '0,000.####');
					}
				}
			],
		},
		cfg)]);
	}
});