From 785eb96fb64fdce4c5ff52539aa5a6525c04f08f Mon Sep 17 00:00:00 2001 From: ychung-mot Date: Thu, 12 Sep 2024 07:33:17 -0700 Subject: [PATCH] feat(dss-805) --- database/ddl/STR_DSS_Views_Sprint_14.sql | 67 +++++++++++++++++++ server/StrDss.Data/Entities/DssDbContext.cs | 4 ++ .../Entities/DssRentalListingVw.cs | 4 ++ .../RentalReportDtos/RentalListingViewDto.cs | 3 + 4 files changed, 78 insertions(+) create mode 100644 database/ddl/STR_DSS_Views_Sprint_14.sql diff --git a/database/ddl/STR_DSS_Views_Sprint_14.sql b/database/ddl/STR_DSS_Views_Sprint_14.sql new file mode 100644 index 00000000..144a4ddb --- /dev/null +++ b/database/ddl/STR_DSS_Views_Sprint_14.sql @@ -0,0 +1,67 @@ +/* Sprint 13 View Changes to STR DSS */ + +drop view if exists dss_rental_listing_vw; + +CREATE OR REPLACE VIEW dss_rental_listing_vw AS select drl.rental_listing_id + , dlst.listing_status_type + , dlst.listing_status_type_nm + , dlst.listing_status_sort_no + , (select max(drlr.report_period_ym) + from dss_rental_listing drl2 + join dss_rental_listing_report drlr on drlr.rental_listing_report_id=drl2.including_rental_listing_report_id + where drl2.offering_organization_id=drl.offering_organization_id and drl2.platform_listing_no=drl.platform_listing_no + ) as latest_report_period_ym + , drl.is_active + , drl.is_new + , drl.is_taken_down + , drl.is_lg_transferred + , drl.is_changed_address + , drl.offering_organization_id + , org.organization_cd as offering_organization_cd + , org.organization_nm as offering_organization_nm + , drl.platform_listing_no + , drl.platform_listing_url + , dpa.original_address_txt + , dpa.is_match_corrected + , dpa.is_match_verified + , dpa.match_score_amt + , dpa.match_address_txt + , dpa.province_cd as address_sort_1_province_cd + , dpa.locality_nm as address_sort_2_locality_nm + , dpa.locality_type_dsc as address_sort_3_locality_type_dsc + , dpa.street_nm as address_sort_4_street_nm + , dpa.street_type_dsc as address_sort_5_street_type_dsc + , dpa.street_direction_dsc as address_sort_6_street_direction_dsc + , dpa.civic_no as address_sort_7_civic_no + , dpa.unit_no as address_sort_8_unit_no + , (select string_agg(full_nm,' ; ') from dss_rental_listing_contact drlc where drlc.contacted_through_rental_listing_id=drl.rental_listing_id) as listing_contact_names_txt + , lg.organization_id as managing_organization_id + , lg.organization_nm as managing_organization_nm + , lgs.economic_region_dsc + , lgs.is_principal_residence_required + , lgs.is_business_licence_required + , drl.is_entire_unit + , drl.available_bedrooms_qty + , drl.nights_booked_qty as nights_booked_ytd_qty + , drl.separate_reservations_qty as separate_reservations_ytd_qty + , drl.business_licence_no + , drl.bc_registry_no + , demt.email_message_type_nm as last_action_nm + , dem.message_delivery_dtm as last_action_dtm + , dbl.business_licence_id + , dbl.business_licence_no as business_licence_no_matched + , dbl.expiry_dt as business_licence_expiry_dt + , dbl.licence_status_type + , drl.effective_business_licence_no + , drl.effective_host_nm + , drl.is_changed_business_licence +FROM dss_rental_listing drl +join dss_organization org on org.organization_id=drl.offering_organization_id +LEFT JOIN dss_listing_status_type dlst on drl.listing_status_type=dlst.listing_status_type +LEFT JOIN dss_physical_address dpa on drl.locating_physical_address_id=dpa.physical_address_id +left join dss_organization lgs on lgs.organization_id=dpa.containing_organization_id and dpa.match_score_amt>1 +left join dss_organization lg on lgs.managing_organization_id=lg.organization_id +LEFT JOIN dss_email_message dem on dem.email_message_id = (select msg.email_message_id from dss_email_message msg where msg.concerned_with_rental_listing_id=drl.rental_listing_id order by msg.message_delivery_dtm desc limit 1) +LEFT JOIN dss_email_message_type demt on dem.email_message_type=demt.email_message_type +LEFT join dss_business_licence dbl on drl.governing_business_licence_id = dbl.business_licence_id +where drl.including_rental_listing_report_id is null; diff --git a/server/StrDss.Data/Entities/DssDbContext.cs b/server/StrDss.Data/Entities/DssDbContext.cs index b3fbbd11..24ee5072 100644 --- a/server/StrDss.Data/Entities/DssDbContext.cs +++ b/server/StrDss.Data/Entities/DssDbContext.cs @@ -956,6 +956,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) entity.Property(e => e.BcRegistryNo) .HasMaxLength(50) .HasColumnName("bc_registry_no"); + entity.Property(e => e.BusinessLicenceExpiryDt).HasColumnName("business_licence_expiry_dt"); entity.Property(e => e.BusinessLicenceId).HasColumnName("business_licence_id"); entity.Property(e => e.BusinessLicenceNo) .HasMaxLength(320) @@ -988,6 +989,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasMaxLength(250) .HasColumnName("last_action_nm"); entity.Property(e => e.LatestReportPeriodYm).HasColumnName("latest_report_period_ym"); + entity.Property(e => e.LicenceStatusType) + .HasMaxLength(25) + .HasColumnName("licence_status_type"); entity.Property(e => e.ListingContactNamesTxt).HasColumnName("listing_contact_names_txt"); entity.Property(e => e.ListingStatusSortNo).HasColumnName("listing_status_sort_no"); entity.Property(e => e.ListingStatusType) diff --git a/server/StrDss.Data/Entities/DssRentalListingVw.cs b/server/StrDss.Data/Entities/DssRentalListingVw.cs index 20794fa4..4b3a9fe7 100644 --- a/server/StrDss.Data/Entities/DssRentalListingVw.cs +++ b/server/StrDss.Data/Entities/DssRentalListingVw.cs @@ -93,6 +93,10 @@ public partial class DssRentalListingVw public string? BusinessLicenceNoMatched { get; set; } + public DateOnly? BusinessLicenceExpiryDt { get; set; } + + public string? LicenceStatusType { get; set; } + public string? EffectiveBusinessLicenceNo { get; set; } public string? EffectiveHostNm { get; set; } diff --git a/server/StrDss.Model/RentalReportDtos/RentalListingViewDto.cs b/server/StrDss.Model/RentalReportDtos/RentalListingViewDto.cs index b63cb329..d7d5b38e 100644 --- a/server/StrDss.Model/RentalReportDtos/RentalListingViewDto.cs +++ b/server/StrDss.Model/RentalReportDtos/RentalListingViewDto.cs @@ -85,6 +85,9 @@ public class RentalListingViewDto public long? BusinessLicenceId { get; set; } public string? BusinessLicenceNoMatched { get; set; } + public DateOnly? BusinessLicenceExpiryDt { get; set; } + + public string? LicenceStatusType { get; set; } public string? EffectiveBusinessLicenceNo { get; set; }