{"action":"created","issue":{"url":"https://api.github.com/repos/trung85/warehouse/issues/238","repository_url":"https://api.github.com/repos/trung85/warehouse","labels_url":"https://api.github.com/repos/trung85/warehouse/issues/238/labels{/name}","comments_url":"https://api.github.com/repos/trung85/warehouse/issues/238/comments","events_url":"https://api.github.com/repos/trung85/warehouse/issues/238/events","html_url":"https://github.com/trung85/warehouse/issues/238","id":322231318,"number":238,"title":"[hotfix] cap nhat lay du lieu output va return theo customers, items trong store","user":{"login":"trung85","id":3256362,"avatar_url":"https://avatars3.githubusercontent.com/u/3256362?v=4","gravatar_id":"","url":"https://api.github.com/users/trung85","html_url":"https://github.com/trung85","followers_url":"https://api.github.com/users/trung85/followers","following_url":"https://api.github.com/users/trung85/following{/other_user}","gists_url":"https://api.github.com/users/trung85/gists{/gist_id}","starred_url":"https://api.github.com/users/trung85/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trung85/subscriptions","organizations_url":"https://api.github.com/users/trung85/orgs","repos_url":"https://api.github.com/users/trung85/repos","events_url":"https://api.github.com/users/trung85/events{/privacy}","received_events_url":"https://api.github.com/users/trung85/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-11T09:33:21Z","updated_at":"2018-05-11T09:34:02Z","closed_at":null,"author_association":"OWNER","body":"\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/trung85/warehouse/issues/comments/388313500","html_url":"https://github.com/trung85/warehouse/issues/238#issuecomment-388313500","issue_url":"https://api.github.com/repos/trung85/warehouse/issues/238","id":388313500,"user":{"login":"trung85","id":3256362,"avatar_url":"https://avatars3.githubusercontent.com/u/3256362?v=4","gravatar_id":"","url":"https://api.github.com/users/trung85","html_url":"https://github.com/trung85","followers_url":"https://api.github.com/users/trung85/followers","following_url":"https://api.github.com/users/trung85/following{/other_user}","gists_url":"https://api.github.com/users/trung85/gists{/gist_id}","starred_url":"https://api.github.com/users/trung85/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trung85/subscriptions","organizations_url":"https://api.github.com/users/trung85/orgs","repos_url":"https://api.github.com/users/trung85/repos","events_url":"https://api.github.com/users/trung85/events{/privacy}","received_events_url":"https://api.github.com/users/trung85/received_events","type":"User","site_admin":false},"created_at":"2018-05-11T09:34:02Z","updated_at":"2018-05-11T09:34:02Z","author_association":"OWNER","body":"USE [Nhanh_Nhanh]\r\nGO\r\n/****** Object:  StoredProcedure [dbo].[TESTING_uspReports_Sale_OutputedItems]    Script Date: 5/11/2018 3:54:03 PM ******/\r\nSET ANSI_NULLS ON\r\nGO\r\nSET QUOTED_IDENTIFIER ON\r\nGO\r\n\r\n\r\nALTER PROCEDURE [dbo].[TESTING_uspReports_Sale_OutputedItems]\r\n(\r\n\t@DimStartDate int,\r\n\t@DimEndDate int,\r\n\t@CustomerCodes nvarchar(max),\r\n\t@ItemCodes nvarchar(max)\r\n)\r\nAS\r\n\r\ndeclare @countCustomer int\r\ndeclare @countItem int\r\n\r\nIF OBJECT_ID('tempdb.dbo.#TableCustomerCodes', 'U') IS NOT NULL\r\n  DROP TABLE #TableCustomerCodes; \r\n\r\nselect * into #TableCustomerCodes from [dbo].[split_comma](@CustomerCodes)\r\ndelete from #TableCustomerCodes where string = ''\r\nset @countCustomer = (select count(*) from #TableCustomerCodes)\r\n\r\nIF OBJECT_ID('tempdb.dbo.#TableItemCodes', 'U') IS NOT NULL\r\n  DROP TABLE #TableItemCodes; \r\nselect * into #TableItemCodes from [dbo].[split_comma](@ItemCodes)\r\n\r\ndelete from #TableItemCodes where string = ''\r\nset @countItem = (select count(*) from #TableItemCodes)\r\n\r\nIF OBJECT_ID('tempdb.dbo.#TableOutputed', 'U') IS NOT NULL\r\n  DROP TABLE #TableOutputed; \r\n  \r\nselect order_log.ItemId\r\n\t, item.ITEM_NAME_1 as ItemName\r\n\t, unit.UNIT_ITEM_NAME as UnitName\r\n\t, order_log.OrderDate\r\n\t, order_log.RefCode as OutputId\r\n\t, order_log.RefDate as OutputDate\r\n\t, order_log.CustomerId\r\n\t, customer.CUSTOMERNAME as CustomerName\r\n\t, country.COUNTRYNAMEVN as CountryName\r\n\t, city.CITYNAME as CityName\r\n\t, order_log.OrderId\r\n\t, order_log.Vat\r\n\t, order_log.Price\r\n\t, order_log.OrderQuantity\r\n\t, order_log.Quantity * -1 as OutputQuantity\r\n\t, order_log.DiscountPercent\r\n\t, order_log.OutputNumber\r\n\t, order_log.SortNumber\r\n\t, order_log.AreaId\r\n\t, order_log.AreaName\r\n\t, order_log.Department \r\n\t, order_log.DiscountPromotionId\r\n\t, order_log.DonatePromotionId into #TableOutputed\r\nfrom [Transaction.OrderCustomer] order_log \r\ninner join CUSTOMERS customer on customer.CUSTOMERID = order_log.CustomerId\r\ninner join ITEMS item on item.ITEM_ID = order_log.ItemId\r\nleft join CITY city on customer.CITYID = city.CITYID\r\nleft join COUNTRY country on country.COUNTRYID = city.COUNTRYID\r\nleft join UNIT_ITEM unit on unit.UNIT_ITEM_ID = item.UNIT_ITEM_ID\r\nwhere \r\nDimDate >= @DimStartDate and DimDate <= @DimEndDate\r\nand order_log.IssueAction = 'output'\r\nand (\r\n\t(@countCustomer > 1 AND customer.CUSTOMERID in (select string from #TableCustomerCodes))\r\n    OR\r\n    (@countCustomer = 1 AND customer.CUSTOMERID = @CustomerCodes)\r\n\tOR \r\n\t(@countCustomer = 0)\r\n)\r\nand (\r\n\t(@countItem > 1 AND item.ITEM_ID in (select string from #TableItemCodes))\r\n    OR\r\n    (@countItem = 1 AND item.ITEM_ID = @ItemCodes)\r\n\tOR \r\n\t(@countItem = 0)\r\n)\r\n\r\nselect *\r\n\t, t.OrderQuantity - (t.OutputQuantity + (select isnull(SUM(t2.OutputQuantity), 0) \r\n\t\t\t\t\t\t\t\t\tfrom #TableOutputed t2  \r\n\t\t\t\t\t\t\t\t\twhere  t2.ItemId = t.ItemId \r\n\t\t\t\t\t\t\t\t\tand t2.OutputId = t.OutputId \r\n\t\t\t\t\t\t\t\t\tand t2.OutputDate < t.OutputDate)) as BacklogQuantity\r\nfrom #TableOutputed t\r\n\r\n\r\ndrop table #TableOutputed\r\ndrop table #TableCustomerCodes\r\ndrop table #TableItemCodes\r\n\r\n\r\n"}}
{"actor":{"display_login":"trung85"}}