u
This commit is contained in:
100
src/providers/mssql/queries/logistics.js
Normal file
100
src/providers/mssql/queries/logistics.js
Normal file
@@ -0,0 +1,100 @@
|
||||
export const CHECK_ACCOUNT_COMPANY = `
|
||||
SELECT id
|
||||
FROM account
|
||||
WHERE id = @accountId AND company_id = @companyId
|
||||
`;
|
||||
|
||||
export const CHECK_ENTITYADDRESS_COMPANY = `
|
||||
SELECT ea.id
|
||||
FROM entityaddress ea
|
||||
INNER JOIN entity e ON e.id = ea.entity_id
|
||||
INNER JOIN customergroup cg ON cg.id = e.customergroup_id
|
||||
WHERE ea.id = @entityaddressId AND cg.company_id = @companyId
|
||||
`;
|
||||
|
||||
export const CHECK_SHIPPING_COMPANY = `
|
||||
SELECT s.id
|
||||
FROM shipping s
|
||||
INNER JOIN manifest m ON m.id = s.manifest_id
|
||||
WHERE s.id = @shippingId AND m.company_id = @companyId
|
||||
`;
|
||||
|
||||
export const ACCOUNT_CREATE = `
|
||||
INSERT INTO account (company_id, [type], [name])
|
||||
OUTPUT INSERTED.id, INSERTED.company_id, INSERTED.[type], INSERTED.[name]
|
||||
VALUES (@companyId, @type, @name)
|
||||
`;
|
||||
|
||||
export const ACCOUNT_LIST = `
|
||||
SELECT id, company_id, [type], [name]
|
||||
FROM account
|
||||
WHERE company_id = @companyId
|
||||
ORDER BY [name] ASC, id ASC
|
||||
`;
|
||||
|
||||
export const ACCOUNT_DELETE = `
|
||||
DELETE FROM account
|
||||
WHERE id = @id AND company_id = @companyId
|
||||
`;
|
||||
|
||||
export const PAYMENT_CREATE = `
|
||||
INSERT INTO payment (account_id, manifest_id, [type], amount)
|
||||
OUTPUT INSERTED.id, INSERTED.account_id, INSERTED.manifest_id, INSERTED.[type], INSERTED.amount
|
||||
VALUES (@accountId, @manifestId, @type, @amount)
|
||||
`;
|
||||
|
||||
export const PAYMENT_LIST_BY_MANIFEST = `
|
||||
SELECT id, account_id, manifest_id, [type], amount
|
||||
FROM payment
|
||||
WHERE manifest_id = @manifestId
|
||||
ORDER BY id ASC
|
||||
`;
|
||||
|
||||
export const PAYMENT_DELETE = `
|
||||
DELETE FROM payment
|
||||
WHERE id = @id
|
||||
AND manifest_id IN (SELECT m.id FROM manifest m WHERE m.company_id = @companyId)
|
||||
`;
|
||||
|
||||
export const SHIPPING_CREATE = `
|
||||
INSERT INTO shipping (manifest_id, [number], [type], [state])
|
||||
OUTPUT INSERTED.id, INSERTED.manifest_id, INSERTED.[number], INSERTED.[type], INSERTED.[state]
|
||||
VALUES (@manifestId, @number, @type, @state)
|
||||
`;
|
||||
|
||||
export const SHIPPING_LIST_BY_MANIFEST = `
|
||||
SELECT id, manifest_id, [number], [type], [state]
|
||||
FROM shipping
|
||||
WHERE manifest_id = @manifestId
|
||||
ORDER BY id ASC
|
||||
`;
|
||||
|
||||
export const SHIPPING_DELETE = `
|
||||
DELETE FROM shipping
|
||||
WHERE id = @id
|
||||
AND manifest_id IN (SELECT m.id FROM manifest m WHERE m.company_id = @companyId)
|
||||
`;
|
||||
|
||||
export const PACKAGE_CREATE = `
|
||||
INSERT INTO package (shipping_id, entityaddress_id, [number], [type], [state], details)
|
||||
OUTPUT INSERTED.id, INSERTED.shipping_id, INSERTED.entityaddress_id, INSERTED.[number], INSERTED.[type], INSERTED.[state], INSERTED.details
|
||||
VALUES (@shippingId, @entityaddressId, @number, @type, @state, @details)
|
||||
`;
|
||||
|
||||
export const PACKAGE_LIST_BY_SHIPPING = `
|
||||
SELECT id, shipping_id, entityaddress_id, [number], [type], [state], details
|
||||
FROM package
|
||||
WHERE shipping_id = @shippingId
|
||||
ORDER BY id ASC
|
||||
`;
|
||||
|
||||
export const PACKAGE_DELETE = `
|
||||
DELETE FROM package
|
||||
WHERE id = @id
|
||||
AND shipping_id IN (
|
||||
SELECT s.id
|
||||
FROM shipping s
|
||||
INNER JOIN manifest m ON m.id = s.manifest_id
|
||||
WHERE m.company_id = @companyId
|
||||
)
|
||||
`;
|
||||
Reference in New Issue
Block a user