define([ 'ngResource' ], function() {
	angular.module('PurcServices', [ 'ngResource' 
	]).factory('PurcOrder', function($resource) {
		return $resource('sale/orders/:id', {});
	}).factory('PurcOrderItem', function($resource) {
		return $resource('sale/orders/items', {}, {
			getTodo: {
				params: {
					_state: 'todo'
				}
			},
			getDone: {
				params: {
					_state: 'done'
				}
			},
			getEnd: {
				params: {
					_state: 'end'
				}
			},
			replyByBatch: {
				url: 'sale/orders/items/reply',
				method: 'POST'
			}, 
			reply: {
				url: 'sale/orders/items/:orderItemId/reply',
				method: 'POST',
				params: {
					orderItemId: 'orderItemId'
				}
			}, 
			getReply: {
				url: 'sale/orders/items/:orderItemId/reply',
				method: 'GET',
				isArray: true,
				params: {
					orderItemId: 'orderItemId'
				}
			}
		});
	}).factory('PurcChange', function($resource) {
		return $resource('sale/changes/:id', {}, {
			getTodo: {
				params: {
					_state: 'todo'
				}
			},
			getDone: {
				params: {
					_state: 'done'
				}
			},
			reply: {
				url: 'sale/changes/:changeId/reply',
				method: 'POST',
				params: {
					changeId: 'changeId'
				}
			}
		});
	}).factory('PurcInquiry', function($resource) {
		return $resource('sale/inquiry/:id', {}, {
			getTodo: {
				params: {
					_state: 'todo'
				}
			},
			getDone: {
				params: {
					_state: 'done'
				}
			},
			reply: {
				url: 'sale/inquiry/items/:itemId/reply',
				method: 'POST',
				params: {
					itemId: 'itemId'
				}
			}, getItem: {
				url: 'sale/inquiry/items/:itemId',
				method: 'GET',
				params: {
					itemId: 'itemId'
				}
			}, saveItem: {
				url: 'sale/inquiry/items/:itemId',
				method: 'POST',
				params: {
					itemId: 'itemId'
				}
			}, getHistory: {
				url: 'sale/inquiry/items/:itemId/history',
				method: 'GET',
				params: {
					itemId: 'itemId'
				},
				isArray: true
			}
		});
	}).factory('PurcNotice', function($resource) {
		return $resource('sale/notice/:id', {}, {
			getTodo: {
				params: {
					_state: 'todo'
				}
			},
			getDone: {
				params: {
					_state: 'done'
				}
			},
			getEnd: {
				params: {
					_state: 'end'
				}
			},
			getSends: {
				url: 'sale/notice/:id/sendItems',
				method: 'GET',
				isArray: true
			}
		});
	}).factory('PurcForecast', function($resource) {
		return $resource('sale/forecast/:id', {}, {
		});
	}).factory('PurcAccept', function($resource) {
		return $resource('sale/accept/:id', {}, {
		});
	}).factory('PurcReturn', function($resource) {
		return $resource('sale/return/:id', {}, {
		});
	}).factory('PurcBadIn', function($resource) {
		return $resource('sale/badIn/:id', {}, {
		});
	}).factory('PurcBadOut', function($resource) {
		return $resource('sale/badOut/:id', {}, {
		});
	}).factory('PurcMRB', function($resource) {
		return $resource('sale/MRB/:id', {}, {
		});
	}).factory('PurcApBill', function($resource) {
		return $resource('sale/apBill/:id', {}, {
		});
	}).factory('PurcOrderItemHis', function($resource) {
		return $resource('sale/orders/history/items', {}, {
			getTodo: {
				params: {
					_state: 'todo'
				}
			},
			getEnd: {
				params: {
					_state: 'end'
				}
			},
			getReply: {
				url: 'sale/orders/history/items/:orderItemId/reply',
				method: 'GET',
				isArray: true,
				params: {
					orderItemId: 'orderItemId'
				}
			}
		});
	}).factory('PurcChangeHis', function($resource) {
		return $resource('sale/changes/history/:id', {}, {
			getTodo: {
				params: {
					_state: 'todo'
				}
			}
		});
	}).factory('PurcInquiryHis', function($resource) {
		return $resource('sale/inquiry/history/:id', {}, {
			getTodo: {
				params: {
					_state: 'todo'
				}
			},
			getItem: {
				url: 'sale/inquiry/history/items/:itemId',
				method: 'GET',
				params: {
					itemId: 'itemId'
				}
			},
			getHistory: {
				url: 'sale/inquiry/history/items/:itemId/history',
				method: 'GET',
				params: {
					itemId: 'itemId'
				},
				isArray: true
			}
		});
	}).factory('PurcNoticeHis', function($resource) {
		return $resource('sale/notice/history/:id', {}, {
			getTodo: {
				params: {
					_state: 'todo'
				}
			},
			getDone: {
				params: {
					_state: 'done'
				}
			},
			getEnd: {
				params: {
					_state: 'end'
				}
			},
			getSends: {
				url: 'sale/notice/history/:id/sendItems',
				method: 'GET',
				isArray: true
			}
		});
	});
});