parent
882a1a95a5
commit
3bf232d952
@ -1,7 +1,7 @@
|
||||
CREATE OR REPLACE VIEW
|
||||
public.view_effect_contract_fee_items AS
|
||||
SELECT
|
||||
('C'::TEXT || contract_plan_fee_items.contract_id)::CHARACTER VARYING AS effect_contract_id,
|
||||
('S-'::TEXT || contract_plan_fee_items.contract_id)::CHARACTER VARYING AS effect_contract_id,
|
||||
contract_plan_fee_items.id
|
||||
FROM
|
||||
contract_plan_fee_items
|
||||
@ -11,11 +11,16 @@ WHERE
|
||||
UNION ALL
|
||||
SELECT
|
||||
(
|
||||
'P'::TEXT || contract_plan_fee_items.contract_plan_id
|
||||
(
|
||||
('L-'::TEXT || contract_items.contract_id) || '-'::TEXT
|
||||
) || contract_items.id
|
||||
)::CHARACTER VARYING AS effect_contract_id,
|
||||
contract_plan_fee_items.id
|
||||
FROM
|
||||
contract_plan_fee_items
|
||||
JOIN contract_plans ON contract_plans.id = contract_plan_fee_items.contract_plan_id
|
||||
JOIN contract_items ON contract_items.contract_plan_id = contract_plans.id
|
||||
WHERE
|
||||
contract_plan_fee_items.lease_item_id IS NULL
|
||||
AND contract_plan_fee_items.contract_plan_id IS NOT NULL;
|
||||
AND contract_plan_fee_items.contract_plan_id IS NOT NULL
|
||||
AND contract_items.contract_id IS NOT NULL;
|
||||
|
@ -2,7 +2,7 @@ CREATE OR REPLACE VIEW
|
||||
public.view_effect_contract_lease_items AS
|
||||
SELECT
|
||||
(
|
||||
'C'::TEXT || contract_plan_lease_items.contract_id
|
||||
'S-'::TEXT || contract_plan_lease_items.contract_id
|
||||
)::CHARACTER VARYING AS effect_contract_id,
|
||||
contract_plan_lease_items.id
|
||||
FROM
|
||||
@ -12,10 +12,15 @@ WHERE
|
||||
UNION ALL
|
||||
SELECT
|
||||
(
|
||||
'P'::TEXT || contract_plan_lease_items.contract_plan_id
|
||||
(
|
||||
('L-'::TEXT || contract_items.contract_id) || '-'::TEXT
|
||||
) || contract_items.id
|
||||
)::CHARACTER VARYING AS effect_contract_id,
|
||||
contract_plan_lease_items.id
|
||||
FROM
|
||||
contract_plan_lease_items
|
||||
JOIN contract_plans ON contract_plans.id = contract_plan_lease_items.contract_plan_id
|
||||
JOIN contract_items ON contract_items.contract_plan_id = contract_plans.id
|
||||
WHERE
|
||||
contract_plan_lease_items.contract_plan_id IS NOT NULL;
|
||||
contract_plan_lease_items.contract_plan_id IS NOT NULL
|
||||
AND contract_items.contract_id IS NOT NULL;
|
||||
|
@ -4,7 +4,6 @@ SELECT
|
||||
contracts.name,
|
||||
('S-'::TEXT || contracts.id)::CHARACTER VARYING AS id,
|
||||
contracts.id AS contract_id,
|
||||
('C'::TEXT || contracts.id)::CHARACTER VARYING AS effect_contract_id,
|
||||
contracts.project_id,
|
||||
contracts.tax_rate,
|
||||
contracts.calc_type,
|
||||
@ -26,10 +25,9 @@ SELECT
|
||||
(contracts.name::TEXT || '-'::TEXT) || contract_plans.name::TEXT
|
||||
)::CHARACTER VARYING AS NAME,
|
||||
(
|
||||
(('L-'::TEXT || contracts.id) || '-'::TEXT) || contract_plans.id
|
||||
(('L-'::TEXT || contracts.id) || '-'::TEXT) || contract_items.id
|
||||
)::CHARACTER VARYING AS id,
|
||||
contracts.id AS contract_id,
|
||||
('P'::TEXT || contract_plans.id)::CHARACTER VARYING AS effect_contract_id,
|
||||
contracts.project_id,
|
||||
contracts.tax_rate,
|
||||
contracts.calc_type,
|
||||
@ -43,7 +41,7 @@ SELECT
|
||||
UPPER(contract_items.date_range) - '1 day'::INTERVAL AS end_date
|
||||
FROM
|
||||
contracts
|
||||
JOIN contract_items ON contracts.id = contract_items.id
|
||||
JOIN contract_items ON contracts.id = contract_items.contract_id
|
||||
JOIN contract_plans ON contract_plans.id = contract_items.contract_plan_id
|
||||
WHERE
|
||||
contracts.effectiveness::TEXT = '0'::TEXT;
|
||||
|
Loading…
Reference in New Issue
Block a user