Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-03-03 13:29:17 +03:00
parent 4805216808
commit d355ef7acd
21 changed files with 279 additions and 227 deletions

View File

@@ -13,13 +13,48 @@ import (
func GetAccounts(ctx context.Context) ([]models.Account, error) {
piyasaFilter := authz.BuildMSSQLPiyasaFilter(ctx, "f2.CustomerAtt01")
piyasaFilter := authz.BuildMSSQLPiyasaFilter(
ctx,
"CASE WHEN b.CurrAccTypeCode = 1 THEN vp.VendorAtt01 ELSE f2.CustomerAtt01 END",
)
if strings.TrimSpace(piyasaFilter) == "" {
piyasaFilter = "1=1"
}
query := fmt.Sprintf(`
;WITH VendorPiyasa AS
(
SELECT
Cari8 = LEFT(P.CurrAccCode, 8),
VendorAtt01 = MAX(P.VendorAtt01)
FROM
(
SELECT
CurrAccTypeCode,
CurrAccCode,
VendorAtt01 = MAX(ISNULL([1], ''))
FROM
(
SELECT
c.CurrAccTypeCode,
c.CurrAccCode,
a.AttributeTypeCode,
a.AttributeCode
FROM cdCurrAcc c WITH (NOLOCK)
LEFT JOIN prCurrAccAttribute a WITH (NOLOCK)
ON a.CurrAccTypeCode = c.CurrAccTypeCode
AND a.CurrAccCode = c.CurrAccCode
WHERE c.CurrAccTypeCode = 1
) d
PIVOT
(
MAX(AttributeCode) FOR AttributeTypeCode IN ([1])
) pvt
GROUP BY CurrAccTypeCode, CurrAccCode
) P
GROUP BY LEFT(P.CurrAccCode, 8)
)
SELECT
x.AccountCode,
MAX(x.AccountName) AS AccountName
@@ -29,10 +64,16 @@ func GetAccounts(ctx context.Context) ([]models.Account, error) {
COALESCE(d.CurrAccDescription, '') AS AccountName
FROM trCurrAccBook b
LEFT JOIN cdCurrAccDesc d
ON d.CurrAccCode = b.CurrAccCode
JOIN CustomerAttributesFilter f2
ON f2.CurrAccCode = b.CurrAccCode
WHERE %s
ON d.CurrAccTypeCode = b.CurrAccTypeCode
AND d.CurrAccCode = b.CurrAccCode
AND d.LangCode = 'TR'
LEFT JOIN CustomerAttributesFilter f2
ON f2.CurrAccTypeCode = b.CurrAccTypeCode
AND f2.CurrAccCode = b.CurrAccCode
LEFT JOIN VendorPiyasa vp
ON vp.Cari8 = LEFT(b.CurrAccCode, 8)
WHERE b.CurrAccTypeCode IN (1,3)
AND %s
) x
GROUP BY x.AccountCode
ORDER BY x.AccountCode