SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Rep_Kala_HesabFO](
    @startDate     NVARCHAR(50),
    @enddate       NVARCHAR(50),
    @IdKala        INT
)
AS
SELECT        [TRANSACTION].TedadFo AS Sadre, [TRANSACTION].AID, [TRANSACTION].Date1, @startDate AS startDate, @enddate AS enddate, @IdKala AS IdKala, FunInfoKalaAll_1.NameKala1, FunInfoKalaAll_1.KalaNumber, 
                         dbo.HesabName([TRANSACTION].KOLID, [TRANSACTION].HESABID, [TRANSACTION].THESABID) AS Namehesab, [TRANSACTION].KALAID, T_Forosh.ForoshNumbr, [TRANSACTION].UnitPriceFo, ROUND(CONVERT(MONEY, 
                         [TRANSACTION].TedadFo * [TRANSACTION].UnitPriceFo), 0) AS Mab, T_Forosh.FOROSHID, [TRANSACTION].Sharh, FunInfoKalaAll_1.NameAnbar
FROM            T_Forosh INNER JOIN
                         [TRANSACTION] ON T_Forosh.FOROSHID = [TRANSACTION].FOROSHID INNER JOIN
                         dbo.FunInfoKalaAll(0) AS FunInfoKalaAll_1 ON [TRANSACTION].KALAID = FunInfoKalaAll_1.ID AND [TRANSACTION].AID = FunInfoKalaAll_1.AID AND [TRANSACTION].GOKID = FunInfoKalaAll_1.GOKID
WHERE        ([TRANSACTION].Date1 BETWEEN @startDate AND @enddate) AND ([TRANSACTION].KALAID = @IdKala)
ORDER BY [TRANSACTION].Date1 DESC




GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Rep_Kala_HesabKH](
    @startDate     NVARCHAR(50),
    @enddate       NVARCHAR(50),
    @IdKala        INT
)
AS
SELECT        [TRANSACTION].TedadKh AS Sadre, [TRANSACTION].AID, [TRANSACTION].Date1, @startDate AS startDate, @enddate AS enddate, @IdKala AS IdKala, FunInfoKalaAll_1.NameKala1, FunInfoKalaAll_1.KalaNumber, 
                         dbo.HesabName([TRANSACTION].KOLID, [TRANSACTION].HESABID, [TRANSACTION].THESABID) AS Namehesab, [TRANSACTION].KALAID, [TRANSACTION].UnitPriceKh, ROUND(CONVERT(MONEY, 
                         [TRANSACTION].TedadKh * [TRANSACTION].UnitPriceKh), 0) AS Mab, T_Kharid.KharidNumbr, T_Kharid.KHARIDID, [TRANSACTION].Sharh, FunInfoKalaAll_1.NameAnbar, 
                         FunInfoKalaAll_1.UnitPrice2 + [TRANSACTION].UnitPriceKh AS UnitPriceKhSF1, ROUND(CONVERT(MONEY, [TRANSACTION].TedadKh * (FunInfoKalaAll_1.UnitPrice2 + [TRANSACTION].UnitPriceKh)), 0) AS MabSF1
FROM            dbo.FunInfoKalaAll(0) AS FunInfoKalaAll_1 INNER JOIN
                         T_Kharid INNER JOIN
                         [TRANSACTION] ON T_Kharid.KHARIDID = [TRANSACTION].KHARIDID ON FunInfoKalaAll_1.ID = [TRANSACTION].KALAID AND FunInfoKalaAll_1.AID = [TRANSACTION].AID AND 
                         FunInfoKalaAll_1.GOKID = [TRANSACTION].GOKID
WHERE        ([TRANSACTION].Date1 BETWEEN @startDate AND @enddate) AND ([TRANSACTION].KALAID = @IdKala)
ORDER BY [TRANSACTION].Date1 DESC
GO