Skip to content

Commit 0dc89a1

Browse files
Merge pull request #898 from bcgov/fix/DSS-1141
DSS-1142 Fix
2 parents 42287c5 + e03f064 commit 0dc89a1

File tree

3 files changed

+176
-19
lines changed

3 files changed

+176
-19
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
-- Rollback script for STR_DSS_Incremental_DB_DDL_Sprint_21.sql
2+
3+
-- Remove columns added to dss_physical_address
4+
ALTER TABLE dss_physical_address DROP COLUMN IF EXISTS reg_rental_unit_no;
5+
ALTER TABLE dss_physical_address DROP COLUMN IF EXISTS reg_rental_street_no;
6+
ALTER TABLE dss_physical_address DROP COLUMN IF EXISTS reg_rental_postal_code;
7+
8+
-- Remove columns added to dss_upload_delivery
9+
ALTER TABLE dss_upload_delivery DROP COLUMN IF EXISTS upload_status;
10+
ALTER TABLE dss_upload_delivery DROP COLUMN IF EXISTS upload_lines_total;
11+
ALTER TABLE dss_upload_delivery DROP COLUMN IF EXISTS upload_lines_success;
12+
ALTER TABLE dss_upload_delivery DROP COLUMN IF EXISTS upload_lines_error;
13+
ALTER TABLE dss_upload_delivery DROP COLUMN IF EXISTS upload_lines_processed;
14+
ALTER TABLE dss_upload_delivery DROP COLUMN IF EXISTS registration_status;
15+
ALTER TABLE dss_upload_delivery DROP COLUMN IF EXISTS registration_lines_failure;
16+
ALTER TABLE dss_upload_delivery DROP COLUMN IF EXISTS registration_lines_success;
17+
ALTER TABLE dss_upload_delivery DROP COLUMN IF EXISTS upload_user_guid;
18+
ALTER TABLE dss_upload_delivery DROP COLUMN IF EXISTS upload_date;
19+
20+
-- Remove columns added to dss_upload_line
21+
ALTER TABLE dss_upload_line DROP COLUMN IF EXISTS is_registration_failure;
22+
ALTER TABLE dss_upload_line DROP COLUMN IF EXISTS registration_text;
23+
24+
-- Drop the updated view dss_rental_upload_history_view
25+
DROP VIEW IF EXISTS dss_rental_upload_history_view;
26+
27+
CREATE OR REPLACE VIEW dss_rental_upload_history_view AS SELECT dud.upload_delivery_id,
28+
dud.upload_delivery_type,
29+
dud.report_period_ym,
30+
dud.providing_organization_id,
31+
do2.organization_nm,
32+
dud.upd_dtm,
33+
dui.given_nm,
34+
dui.family_nm,
35+
count(*) AS total,
36+
sum(
37+
CASE
38+
WHEN (dul.is_processed = true) THEN 1
39+
ELSE 0
40+
END) AS processed,
41+
sum(
42+
CASE
43+
WHEN ((dul.is_validation_failure = true) OR (dul.is_system_failure = true)) THEN 1
44+
ELSE 0
45+
END) AS errors,
46+
sum(
47+
CASE
48+
WHEN ((dul.is_processed = true) AND (dul.is_validation_failure = false) AND (dul.is_system_failure = false)) THEN 1
49+
ELSE 0
50+
END) AS success,
51+
CASE
52+
WHEN ((dud.upload_delivery_type)::text = 'Takedown Data'::text) THEN 'Processed'::text
53+
WHEN (((dud.upload_delivery_type)::text = 'Licence Data'::text) AND (count(*) = sum(
54+
CASE
55+
WHEN (dul.is_processed = true) THEN 1
56+
ELSE 0
57+
END)) AND (count(*) = sum(
58+
CASE
59+
WHEN (dul.is_processed = true) THEN 1
60+
ELSE 0
61+
END)) AND (sum(
62+
CASE
63+
WHEN ((dul.is_validation_failure = true) OR (dul.is_system_failure = true)) THEN 1
64+
ELSE 0
65+
END) = 0)) THEN 'Processed'::text
66+
WHEN (((dud.upload_delivery_type)::text = 'Licence Data'::text) AND (count(*) = sum(
67+
CASE
68+
WHEN (dul.is_processed = true) THEN 1
69+
ELSE 0
70+
END)) AND (count(*) = sum(
71+
CASE
72+
WHEN (dul.is_processed = true) THEN 1
73+
ELSE 0
74+
END)) AND (sum(
75+
CASE
76+
WHEN ((dul.is_validation_failure = true) OR (dul.is_system_failure = true)) THEN 1
77+
ELSE 0
78+
END) > 0)) THEN 'Failed'::text
79+
WHEN (count(*) = sum(
80+
CASE
81+
WHEN (dul.is_processed = true) THEN 1
82+
ELSE 0
83+
END)) THEN 'Processed'::text
84+
ELSE 'Pending'::text
85+
END AS status
86+
FROM (((dss_upload_delivery dud
87+
JOIN dss_upload_line dul ON ((dul.including_upload_delivery_id = dud.upload_delivery_id)))
88+
JOIN dss_user_identity dui ON ((dud.upd_user_guid = dui.user_guid)))
89+
JOIN dss_organization do2 ON ((dud.providing_organization_id = do2.organization_id)))
90+
GROUP BY dud.upload_delivery_id, dud.upload_delivery_type, dud.report_period_ym, dud.providing_organization_id, do2.organization_nm, dud.upd_dtm, dui.given_nm, dui.family_nm;
91+
92+
93+
-- Rollback complete
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
-- public.dss_rental_upload_history_view source
2+
3+
CREATE OR REPLACE VIEW public.dss_rental_upload_history_view
4+
AS SELECT dud.upload_delivery_id,
5+
dud.upload_delivery_type,
6+
dud.report_period_ym,
7+
dud.providing_organization_id,
8+
do2.organization_nm,
9+
dud.upd_dtm,
10+
dui.given_nm,
11+
dui.family_nm,
12+
count(*) AS total,
13+
sum(
14+
CASE
15+
WHEN dul.is_processed = true THEN 1
16+
ELSE 0
17+
END) AS processed,
18+
sum(
19+
CASE
20+
WHEN dul.is_validation_failure = true OR dul.is_system_failure = true THEN 1
21+
ELSE 0
22+
END) AS errors,
23+
sum(
24+
CASE
25+
WHEN dul.is_processed = true AND dul.is_validation_failure = false AND dul.is_system_failure = false THEN 1
26+
ELSE 0
27+
END) AS success,
28+
CASE
29+
WHEN dud.upload_delivery_type::text = 'Takedown Data'::text THEN 'Processed'::text
30+
WHEN dud.upload_delivery_type::text = 'Licence Data'::text AND count(*) = sum(
31+
CASE
32+
WHEN dul.is_processed = true THEN 1
33+
ELSE 0
34+
END) AND count(*) = sum(
35+
CASE
36+
WHEN dul.is_processed = true THEN 1
37+
ELSE 0
38+
END) AND sum(
39+
CASE
40+
WHEN dul.is_validation_failure = true OR dul.is_system_failure = true THEN 1
41+
ELSE 0
42+
END) = 0 THEN 'Processed'::text
43+
WHEN dud.upload_delivery_type::text = 'Licence Data'::text AND count(*) = sum(
44+
CASE
45+
WHEN dul.is_processed = true THEN 1
46+
ELSE 0
47+
END) AND count(*) = sum(
48+
CASE
49+
WHEN dul.is_processed = true THEN 1
50+
ELSE 0
51+
END) AND sum(
52+
CASE
53+
WHEN dul.is_validation_failure = true OR dul.is_system_failure = true THEN 1
54+
ELSE 0
55+
END) > 0 THEN 'Failed'::text
56+
WHEN count(*) = sum(
57+
CASE
58+
WHEN dul.is_processed = true THEN 1
59+
ELSE 0
60+
END) THEN 'Processed'::text
61+
ELSE 'Pending'::text
62+
END AS status
63+
FROM dss_upload_delivery dud
64+
JOIN dss_upload_line dul ON dul.including_upload_delivery_id = dud.upload_delivery_id
65+
JOIN dss_user_identity dui ON dud.upd_user_guid = dui.user_guid
66+
JOIN dss_organization do2 ON dud.providing_organization_id = do2.organization_id
67+
GROUP BY dud.upload_delivery_id, dud.upload_delivery_type, dud.report_period_ym, dud.providing_organization_id, do2.organization_nm, dud.upd_dtm, dui.given_nm, dui.family_nm;

server/StrDss.Service/RentalListingReportService.cs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -227,41 +227,38 @@ public async Task ProcessRentalReportUploadAsync(DssUploadDelivery upload)
227227
bool isRegistrationValid = false;
228228
string registrationTxt = "";
229229

230+
// Attempt to validate the registration number if it exists, and the user is allowed to do it this weay
231+
if (doValidateRegistration)
232+
{
233+
// either validate the registration number, or check if the property is straa exempt
234+
if (!string.IsNullOrEmpty(row.RegNo) && !string.IsNullOrEmpty(row.RentalPostal))
235+
{
236+
(isRegistrationValid, registrationTxt) = await _permitValidation.ValidateRegistrationPermitAsync(row.RegNo, row.RentalUnit, row.RentalStreet, row.RentalPostal);
237+
}
238+
else if (!isRegistrationValid && string.IsNullOrEmpty(row.RegNo) && !string.IsNullOrEmpty(row.RentalAddress))
239+
{
240+
(isRegistrationValid, registrationTxt) = await _permitValidation.CheckStraaExemptionStatus(row.RentalAddress);
241+
}
242+
}
243+
230244
// Validate of the incoming line
231245
_validator.Validate(Entities.RentalListingRowUntyped, row, errors);
232246
if (errors.Count > 0)
233247
{
234-
SaveUploadLine(uploadLine, errors, true, "", true, errors.ParseError());
248+
SaveUploadLine(uploadLine, errors, true, "", !isRegistrationValid, registrationTxt);
235249
if (isLastLine) await _reportRepo.UpdateInactiveListings(upload.ProvidingOrganizationId);
236250
_unitOfWork.Commit();
237251
return (false, isRegistrationValid);
238252
}
239-
240-
// Attempt to validate the registration number if it exists, and the user is allowed to do it this weay
241-
if (doValidateRegistration)
242-
{
243-
// Do we have what we need to validate the registration?
244-
if (!string.IsNullOrEmpty(row.RegNo) && !string.IsNullOrEmpty(row.RentalPostal))
245-
{
246-
(isRegistrationValid, registrationTxt) = await _permitValidation.ValidateRegistrationPermitAsync(row.RegNo, row.RentalUnit, row.RentalStreet, row.RentalPostal);
247-
}
248-
}
249253

250-
var offeringOrg = await _orgRepo.GetOrganizationByOrgCdAsync(row.OrgCd); //already validated in the file upload
251254

255+
var offeringOrg = await _orgRepo.GetOrganizationByOrgCdAsync(row.OrgCd); //already validated in the file upload
252256
using var tran = _unitOfWork.BeginTransaction();
253-
254257
var listing = await CreateOrUpdateRentalListing(report, offeringOrg, row);
255258
AddContacts(listing, row);
256259
var (physicalAddress, systemError) = await CreateOrGetPhysicalAddress(listing, row, isRegistrationValid);
257260
listing.LocatingPhysicalAddress = physicalAddress;
258261

259-
// Check to see if the registration is valid due to being in a straa exempt jurisdiction
260-
if (doValidateRegistration && !isRegistrationValid && string.IsNullOrEmpty(row.RegNo) && !string.IsNullOrEmpty(row.RentalAddress))
261-
{
262-
(isRegistrationValid, registrationTxt) = await _permitValidation.CheckStraaExemptionStatus(row.RentalAddress);
263-
}
264-
265262
SaveUploadLine(uploadLine, errors, false, systemError, !isRegistrationValid, registrationTxt);
266263

267264
_unitOfWork.Commit();

0 commit comments

Comments
 (0)