u
This commit is contained in:
@@ -189,10 +189,11 @@ SELECT COUNT(*) AS count
|
||||
FROM entity e
|
||||
INNER JOIN customergroup cg ON cg.id = e.customergroup_id
|
||||
INNER JOIN posterminal pt ON pt.id = @posterminalId AND pt.company_id = cg.company_id
|
||||
WHERE cg.name NOT IN ('Lieferanten', 'POS')
|
||||
WHERE cg.name <> 'Lieferanten'
|
||||
AND DATEDIFF_BIG(second, '1970-01-01', e.updated_at) > @cursor
|
||||
`;
|
||||
|
||||
|
||||
export const COUNT_CUSTOMER_GROUPS = `
|
||||
SELECT COUNT(*) AS count
|
||||
FROM customergroup cg
|
||||
@@ -387,6 +388,80 @@ WHERE pc.posterminal_id = @posterminalId
|
||||
ORDER BY ca.article_id ASC, ca.category_id ASC
|
||||
`;
|
||||
|
||||
export const LIST_POS_CUSTOMER_GROUPS = `
|
||||
SELECT TOP (@limit)
|
||||
cg.id,
|
||||
cg.name,
|
||||
CASE WHEN cg.id = co.poscustomergroup_id THEN '1' ELSE '0' END AS standard,
|
||||
'0.000000' AS discountPercent,
|
||||
DATEDIFF_BIG(second, '1970-01-01', cg.updated_at) AS lastChanged
|
||||
FROM customergroup cg
|
||||
INNER JOIN posterminal pt ON pt.id = @posterminalId AND pt.company_id = cg.company_id
|
||||
INNER JOIN company co ON co.id = pt.company_id
|
||||
WHERE cg.name <> 'Lieferanten'
|
||||
AND DATEDIFF_BIG(second, '1970-01-01', cg.updated_at) > @cursor
|
||||
ORDER BY DATEDIFF_BIG(second, '1970-01-01', cg.updated_at) ASC, cg.id ASC
|
||||
`;
|
||||
|
||||
export const LIST_POS_CUSTOMERS = `
|
||||
SELECT TOP (@limit)
|
||||
e.id,
|
||||
e.customergroup_id AS customergroupId,
|
||||
e.first_name AS firstName,
|
||||
e.name AS lastName,
|
||||
e.[number] AS customerNumber,
|
||||
(
|
||||
SELECT TOP 1 ea.street
|
||||
FROM entityaddress ea
|
||||
WHERE ea.entity_id = e.id
|
||||
ORDER BY CASE WHEN ea.addresstype = 'billing' THEN 0 ELSE 1 END, ea.sort ASC, ea.id ASC
|
||||
) AS street,
|
||||
(
|
||||
SELECT TOP 1 ea.streetnumber
|
||||
FROM entityaddress ea
|
||||
WHERE ea.entity_id = e.id
|
||||
ORDER BY CASE WHEN ea.addresstype = 'billing' THEN 0 ELSE 1 END, ea.sort ASC, ea.id ASC
|
||||
) AS streetNumber,
|
||||
(
|
||||
SELECT TOP 1 ea.city
|
||||
FROM entityaddress ea
|
||||
WHERE ea.entity_id = e.id
|
||||
ORDER BY CASE WHEN ea.addresstype = 'billing' THEN 0 ELSE 1 END, ea.sort ASC, ea.id ASC
|
||||
) AS city,
|
||||
(
|
||||
SELECT TOP 1 ea.zip
|
||||
FROM entityaddress ea
|
||||
WHERE ea.entity_id = e.id
|
||||
ORDER BY CASE WHEN ea.addresstype = 'billing' THEN 0 ELSE 1 END, ea.sort ASC, ea.id ASC
|
||||
) AS postalCode,
|
||||
(
|
||||
SELECT TOP 1 ea.county
|
||||
FROM entityaddress ea
|
||||
WHERE ea.entity_id = e.id
|
||||
ORDER BY CASE WHEN ea.addresstype = 'billing' THEN 0 ELSE 1 END, ea.sort ASC, ea.id ASC
|
||||
) AS [state],
|
||||
(
|
||||
SELECT TOP 1 ec.contact
|
||||
FROM entitycontact ec
|
||||
WHERE ec.entity_id = e.id AND ec.contacttype IN ('phone', 'mobile', 'tel')
|
||||
ORDER BY ec.sort ASC, ec.id ASC
|
||||
) AS phone,
|
||||
(
|
||||
SELECT TOP 1 ec.contact
|
||||
FROM entitycontact ec
|
||||
WHERE ec.entity_id = e.id AND ec.contacttype IN ('email', 'mail')
|
||||
ORDER BY ec.sort ASC, ec.id ASC
|
||||
) AS email,
|
||||
DATEDIFF_BIG(second, '1970-01-01', e.updated_at) AS lastChanged
|
||||
FROM entity e
|
||||
INNER JOIN customergroup cg ON cg.id = e.customergroup_id
|
||||
INNER JOIN posterminal pt ON pt.id = @posterminalId AND pt.company_id = cg.company_id
|
||||
WHERE cg.name <> 'Lieferanten'
|
||||
AND DATEDIFF_BIG(second, '1970-01-01', e.updated_at) > @cursor
|
||||
ORDER BY DATEDIFF_BIG(second, '1970-01-01', e.updated_at) ASC, e.id ASC
|
||||
`;
|
||||
|
||||
|
||||
export const LIST_POS_CUSTOMER_GROUP_IDS = `
|
||||
SELECT cg.id
|
||||
FROM customergroup cg
|
||||
@@ -395,6 +470,7 @@ WHERE cg.name <> 'Lieferanten'
|
||||
ORDER BY cg.id ASC
|
||||
`;
|
||||
|
||||
|
||||
export const LIST_POS_PRODUCT_PRICES = `
|
||||
SELECT
|
||||
pr.article_id AS articleId,
|
||||
|
||||
@@ -29,6 +29,88 @@ SELECT @posterminalId, id FROM cats WHERE 1
|
||||
ON CONFLICT (posterminal_id, category_id) DO NOTHING
|
||||
`;
|
||||
|
||||
export const LIST_POS_CUSTOMER_GROUPS = `
|
||||
SELECT
|
||||
cg.id,
|
||||
cg.name,
|
||||
CASE WHEN cg.id = co.poscustomergroup_id THEN '1' ELSE '0' END AS standard,
|
||||
'0.000000' AS discountPercent,
|
||||
CAST(strftime('%s', cg.updated_at) AS INTEGER) AS lastChanged
|
||||
FROM customergroup cg
|
||||
INNER JOIN posterminal pt ON pt.id = @posterminalId AND pt.company_id = cg.company_id
|
||||
INNER JOIN company co ON co.id = pt.company_id
|
||||
WHERE cg.name <> 'Lieferanten'
|
||||
AND CAST(strftime('%s', cg.updated_at) AS INTEGER) > @cursor
|
||||
ORDER BY lastChanged ASC, cg.id ASC
|
||||
LIMIT @limit
|
||||
`;
|
||||
|
||||
export const LIST_POS_CUSTOMERS = `
|
||||
SELECT
|
||||
e.id,
|
||||
e.customergroup_id AS customergroupId,
|
||||
e.first_name AS firstName,
|
||||
e.name AS lastName,
|
||||
e."number" AS customerNumber,
|
||||
(
|
||||
SELECT ea.street
|
||||
FROM entityaddress ea
|
||||
WHERE ea.entity_id = e.id
|
||||
ORDER BY CASE WHEN ea.addresstype = 'billing' THEN 0 ELSE 1 END, ea.sort ASC, ea.id ASC
|
||||
LIMIT 1
|
||||
) AS street,
|
||||
(
|
||||
SELECT ea.streetnumber
|
||||
FROM entityaddress ea
|
||||
WHERE ea.entity_id = e.id
|
||||
ORDER BY CASE WHEN ea.addresstype = 'billing' THEN 0 ELSE 1 END, ea.sort ASC, ea.id ASC
|
||||
LIMIT 1
|
||||
) AS streetNumber,
|
||||
(
|
||||
SELECT ea.city
|
||||
FROM entityaddress ea
|
||||
WHERE ea.entity_id = e.id
|
||||
ORDER BY CASE WHEN ea.addresstype = 'billing' THEN 0 ELSE 1 END, ea.sort ASC, ea.id ASC
|
||||
LIMIT 1
|
||||
) AS city,
|
||||
(
|
||||
SELECT ea.zip
|
||||
FROM entityaddress ea
|
||||
WHERE ea.entity_id = e.id
|
||||
ORDER BY CASE WHEN ea.addresstype = 'billing' THEN 0 ELSE 1 END, ea.sort ASC, ea.id ASC
|
||||
LIMIT 1
|
||||
) AS postalCode,
|
||||
(
|
||||
SELECT ea.county
|
||||
FROM entityaddress ea
|
||||
WHERE ea.entity_id = e.id
|
||||
ORDER BY CASE WHEN ea.addresstype = 'billing' THEN 0 ELSE 1 END, ea.sort ASC, ea.id ASC
|
||||
LIMIT 1
|
||||
) AS "state",
|
||||
(
|
||||
SELECT ec.contact
|
||||
FROM entitycontact ec
|
||||
WHERE ec.entity_id = e.id AND ec.contacttype IN ('phone', 'mobile', 'tel')
|
||||
ORDER BY ec.sort ASC, ec.id ASC
|
||||
LIMIT 1
|
||||
) AS phone,
|
||||
(
|
||||
SELECT ec.contact
|
||||
FROM entitycontact ec
|
||||
WHERE ec.entity_id = e.id AND ec.contacttype IN ('email', 'mail')
|
||||
ORDER BY ec.sort ASC, ec.id ASC
|
||||
LIMIT 1
|
||||
) AS email,
|
||||
CAST(strftime('%s', e.updated_at) AS INTEGER) AS lastChanged
|
||||
FROM entity e
|
||||
INNER JOIN customergroup cg ON cg.id = e.customergroup_id
|
||||
INNER JOIN posterminal pt ON pt.id = @posterminalId AND pt.company_id = cg.company_id
|
||||
WHERE cg.name <> 'Lieferanten'
|
||||
AND CAST(strftime('%s', e.updated_at) AS INTEGER) > @cursor
|
||||
ORDER BY lastChanged ASC, e.id ASC
|
||||
LIMIT @limit
|
||||
`;
|
||||
|
||||
export const LIST_POS_CATEGORIES = `
|
||||
SELECT
|
||||
c.id,
|
||||
|
||||
Reference in New Issue
Block a user