Skip to content

Instantly share code, notes, and snippets.

@nikolasd
Created March 29, 2019 14:57
Show Gist options
  • Save nikolasd/c11d07cb5553de3598028f3debf9c099 to your computer and use it in GitHub Desktop.
Save nikolasd/c11d07cb5553de3598028f3debf9c099 to your computer and use it in GitHub Desktop.
Pylon SQL - Εύρεση ξενοδοχειακών συναλλαγών στο εμπορικό
--Hotel Transcations στο Εμπορικό - Εισπράξεις
SELECT
A.HECSTMID,
hr.heresnum,
doc.hedoccode,
hb.herefnumber billno,
a.hedentid,
a.hefindentid,
a.hedepositdentid,
a.hedepositref,
a.heparenttransid,
a.heid,
a.hetranstype,
a.hestatus,
a.*
FROM hehoteltransactions a
INNER JOIN hehotelbills hb
ON hb.heid = a.hehlblid
LEFT JOIN hereservations hr
ON hr.heid = a.hersrvid
LEFT JOIN hedocentries doc
ON doc.heid = a.HEFINDENTID
WHERE a.hecstmid IN (SELECT
heid
FROM hecustomers
WHERE hecode IN ('CH-005161'))
AND YEAR(a.hetransdate) = 2017
--Hotel Transcations στο Εμπορικό - Πωλήσεις
SELECT
A.HECSTMID,
hr.heresnum,
doc.hedoccode,
hb.herefnumber billno,
a.hedentid,
a.hefindentid,
a.hedepositdentid,
a.hedepositref,
a.heparenttransid,
a.heid,
a.hetranstype,
a.hestatus,
a.*
FROM hehoteltransactions a
INNER JOIN hehotelbills hb
ON hb.heid = a.hehlblid
LEFT JOIN hereservations hr
ON hr.heid = a.hersrvid
LEFT JOIN hedocentries doc
ON doc.heid = a.hedentid
WHERE a.hecstmid IN (SELECT
heid
FROM hecustomers
WHERE hecode IN ('CU-016800'))
AND YEAR(a.hetransdate) = 2017
--Hotel Transcations στο Εμπορικό - Προκαταβολές
SELECT
A.HECSTMID,
hr.heresnum,
doc.hedoccode,
hb.herefnumber billno,
a.hedentid,
a.hefindentid,
a.hedepositdentid,
a.hedepositref,
a.heparenttransid,
a.heid,
a.hetranstype,
a.hestatus,
a.*
FROM hehoteltransactions a
INNER JOIN hehotelbills hb
ON hb.heid = a.hehlblid
LEFT JOIN hereservations hr
ON hr.heid = a.hersrvid
LEFT JOIN hedocentries doc
ON doc.heid = a.HEDEPOSITDENTID
WHERE a.hecstmid IN (SELECT
heid
FROM hecustomers
WHERE hecode IN ('CU-016800'))
AND YEAR(a.hetransdate) = 2017
-- Εύρεση HotelTransaction συγκεκριμένης είσπραξης ή προκαταβολής
SELECT
a.HEID,
b.hecode,
b.HENAME,
a.*
FROM HEHOTELTRANSACTIONS a
INNER JOIN hecustomers b
ON b.heid = a.HECSTMID
WHERE a.HEDEPOSITDENTID IN (SELECT
HEID
FROM HEDOCENTRIES
WHERE HEDOCCODE IN ('Astori-ΕΠρ-0000001369'))
OR a.HEFINDENTID IN (SELECT
HEID
FROM HEDOCENTRIES
WHERE HEDOCCODE IN ('Astori-ΕΠρ-0000001369'))
-- Εύρεση transperdoc συγκεκριμένου πελάτη και για συγκεκριμένο παραστατικό
-- Για όταν θέλουμε να διαγράψουμε κάποιο παραστατικό
SELECT
B.HETRANSTYPE,
A.HEID,
C.HEDOCCODE,
B.HEAMOUNT,
A.*
FROM HETRANSPERDOC A
INNER JOIN HEHOTELTRANSACTIONS B
ON B.HEID = A.HEHLTRID
INNER JOIN HEDOCENTRIES C
ON C.HEID = A.HEDENTID
WHERE B.HECSTMID IN (SELECT
HEID
FROM HECUSTOMERS
WHERE HECODE IN ('CU-012179'))
AND C.HEID IN (SELECT
HEID
FROM HEDOCENTRIES
WHERE HEDOCCODE IN ('Astori-ΕΠρ-0000001369'))
AND YEAR(B.HETRANSDATE) = 2017
-- Allow modification and/or deletion of DocEntry
UPDATE HEDOCENTRIES
SET HEALLOWMODIFICATION = 1
--,HEALLOWDELETION =1
WHERE HEDOCCODE IN ('Astori-ΕΠρ-0000001369')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment