Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -34,10 +34,38 @@ func GetStatements(ctx context.Context, params models.StatementParams) ([]models
|
||||
}
|
||||
}
|
||||
|
||||
piyasaScope, err := buildPiyasaExistsForCariCode(ctx, "b.CurrAccCode")
|
||||
customerPiyasaInClause, err := resolvePiyasaScopeInClause(ctx, "PF.CustomerAtt01")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
vendorPiyasaInClause, err := resolvePiyasaScopeInClause(ctx, "VF.VendorAtt01")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
piyasaScope := fmt.Sprintf(`
|
||||
(
|
||||
(b.CurrAccTypeCode = 3 AND EXISTS (
|
||||
SELECT 1
|
||||
FROM CustomerAttributesFilter PF WITH (NOLOCK)
|
||||
WHERE (PF.CurrAccCode = b.CurrAccCode OR LEFT(PF.CurrAccCode, 8) = LEFT(b.CurrAccCode, 8))
|
||||
AND %s
|
||||
))
|
||||
OR
|
||||
(b.CurrAccTypeCode = 1 AND EXISTS (
|
||||
SELECT 1
|
||||
FROM (
|
||||
SELECT
|
||||
CurrAccCode,
|
||||
VendorAtt01 = MAX(CASE WHEN AttributeTypeCode = 1 THEN AttributeCode END)
|
||||
FROM prCurrAccAttribute WITH (NOLOCK)
|
||||
WHERE CurrAccTypeCode = 1
|
||||
GROUP BY CurrAccCode
|
||||
) VF
|
||||
WHERE (VF.CurrAccCode = b.CurrAccCode OR LEFT(VF.CurrAccCode, 8) = LEFT(b.CurrAccCode, 8))
|
||||
AND %s
|
||||
))
|
||||
)`, customerPiyasaInClause, vendorPiyasaInClause)
|
||||
|
||||
query := fmt.Sprintf(`
|
||||
;WITH CurrDesc AS (
|
||||
@@ -62,7 +90,7 @@ HasMovement AS (
|
||||
INNER JOIN CurrAccBookATAttributesFilter f
|
||||
ON f.CurrAccBookID = b.CurrAccBookID
|
||||
AND f.ATAtt01 IN (%s)
|
||||
WHERE LEFT(REPLACE(b.CurrAccCode, ' ', ''), 7) = REPLACE(@Carikod, ' ', '')
|
||||
WHERE LEFT(REPLACE(b.CurrAccCode, ' ', ''), 7) = LEFT(REPLACE(@Carikod, ' ', ''), 7)
|
||||
AND b.DocumentDate BETWEEN @startdate AND @enddate
|
||||
AND %s
|
||||
) THEN 1 ELSE 0 END AS HasMov
|
||||
@@ -85,7 +113,8 @@ Opening AS (
|
||||
LEFT JOIN trCurrAccBookCurrency c
|
||||
ON c.CurrAccBookID = b.CurrAccBookID
|
||||
AND c.CurrencyCode = b.DocCurrencyCode
|
||||
WHERE LEFT(REPLACE(b.CurrAccCode, ' ', ''), 7) = REPLACE(@Carikod, ' ', '')
|
||||
WHERE LEFT(REPLACE(b.CurrAccCode, ' ', ''), 7) = LEFT(REPLACE(@Carikod, ' ', ''), 7)
|
||||
AND @ExcludeOpening = 0
|
||||
AND %s
|
||||
AND (
|
||||
(hm.HasMov = 1 AND b.DocumentDate < @startdate) -- hareket varsa: klasik devir
|
||||
@@ -142,7 +171,7 @@ Movements AS (
|
||||
ON c.CurrAccBookID = b.CurrAccBookID
|
||||
AND c.CurrencyCode = b.DocCurrencyCode
|
||||
|
||||
WHERE LEFT(REPLACE(b.CurrAccCode, ' ', ''), 7) = REPLACE(@Carikod, ' ', '')
|
||||
WHERE LEFT(REPLACE(b.CurrAccCode, ' ', ''), 7) = LEFT(REPLACE(@Carikod, ' ', ''), 7)
|
||||
AND %s
|
||||
AND b.DocumentDate BETWEEN @startdate AND @enddate
|
||||
)
|
||||
@@ -223,6 +252,7 @@ ORDER BY
|
||||
sql.Named("enddate", params.EndDate),
|
||||
sql.Named("Carikod", params.AccountCode),
|
||||
sql.Named("LangCode", params.LangCode),
|
||||
sql.Named("ExcludeOpening", params.ExcludeOpening),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("MSSQL query error: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user