@@ -34,11 +34,12 @@ public class RentalListingReportService : ServiceBase, IRentalListingReportServi
34
34
private IUserRepository _userRepo ;
35
35
private IEmailMessageService _emailService ;
36
36
private IEmailMessageRepository _emailRepo ;
37
+ private IBizLicenseRepository _bizLicRepo ;
37
38
private IConfiguration _config ;
38
39
39
40
public RentalListingReportService ( ICurrentUser currentUser , IFieldValidatorService validator , IUnitOfWork unitOfWork , IMapper mapper , IHttpContextAccessor httpContextAccessor ,
40
41
IOrganizationRepository orgRepo , IUploadDeliveryRepository uploadRepo , IRentalListingReportRepository reportRepo , IPhysicalAddressRepository addressRepo ,
41
- IGeocoderApi geocoder , IUserRepository userRepo , IEmailMessageService emailService , IEmailMessageRepository emailRepo ,
42
+ IGeocoderApi geocoder , IUserRepository userRepo , IEmailMessageService emailService , IEmailMessageRepository emailRepo , IBizLicenseRepository bizLicRepo ,
42
43
IConfiguration config , ILogger < StrDssLogger > logger )
43
44
: base ( currentUser , validator , unitOfWork , mapper , httpContextAccessor , logger )
44
45
{
@@ -50,6 +51,7 @@ public RentalListingReportService(ICurrentUser currentUser, IFieldValidatorServi
50
51
_userRepo = userRepo ;
51
52
_emailService = emailService ;
52
53
_emailRepo = emailRepo ;
54
+ _bizLicRepo = bizLicRepo ;
53
55
_config = config ;
54
56
}
55
57
public async Task ProcessRentalReportUploadAsync ( )
@@ -412,6 +414,30 @@ private async Task<DssRentalListing> CreateOrUpdateRentalListing(DssRentalListin
412
414
masterListing . DerivedFromRentalListingId = listing . RentalListingId ;
413
415
masterListing . LocatingPhysicalAddressId = physicalAddress . PhysicalAddressId ;
414
416
417
+ masterListing . EffectiveHostNm = CommonUtils . SanitizeAndUppercaseString ( row . PropertyHostNm ) ;
418
+
419
+ if ( masterListing . IsChangedBusinessLicence == true )
420
+ {
421
+ // keep the original effective business licence no and id
422
+ }
423
+ else if ( ! string . IsNullOrEmpty ( masterListing . BusinessLicenceNo ) && physicalAddress . ContainingOrganizationId . HasValue )
424
+ {
425
+ var sanitizedBizLicNo = CommonUtils . SanitizeAndUppercaseString ( masterListing . BusinessLicenceNo ) ;
426
+
427
+ var ( businessLicenceId , businessLicenceNo ) = await _bizLicRepo . GetMatchingBusinessLicenseIdAndNo (
428
+ physicalAddress . ContainingOrganizationId . Value ,
429
+ sanitizedBizLicNo
430
+ ) ;
431
+
432
+ masterListing . GoverningBusinessLicenceId = businessLicenceId ;
433
+ masterListing . EffectiveBusinessLicenceNo = businessLicenceNo ?? sanitizedBizLicNo ;
434
+ }
435
+ else
436
+ {
437
+ masterListing . GoverningBusinessLicenceId = null ;
438
+ masterListing . EffectiveBusinessLicenceNo = string . Empty ;
439
+ }
440
+
415
441
( masterListing . NightsBookedQty , masterListing . SeparateReservationsQty ) =
416
442
await _reportRepo . GetYtdValuesOfListingAsync ( reportPeriodYm , offeringOrg . OrganizationId , masterListing . PlatformListingNo ) ;
417
443
0 commit comments