Esempio n. 1
0
    def __CreateOrUpdateDoingBusinessAs(self, claim: ClaimParser,
                                        verifiableOrg: VerifiableOrg):
        dbaName = claim.getField("doing_business_as_name")
        effectiveDate = self.__ToDate(claim.getField("effective_date"))
        endDate = self.__ToDate(claim.getField("end_date"))

        doingBusinessAs = DoingBusinessAs.objects.filter(
            verifiableOrgId=verifiableOrg, dbaName=dbaName)
        if not doingBusinessAs:
            self.__logger.debug(
                "DoingBusinessAs, {0}, does not exist.  Creating ...".format(
                    dbaName))
            doingBusinessAs = DoingBusinessAs(verifiableOrgId=verifiableOrg,
                                              dbaName=dbaName,
                                              effectiveDate=effectiveDate,
                                              endDate=endDate)
            doingBusinessAs.save()
        else:
            self.__logger.debug(
                "DoingBusinessAs, {0}, exists.  Updating ...".format(dbaName))
            doingBusinessAs = doingBusinessAs[0]
            doingBusinessAs.dbaName = dbaName
            doingBusinessAs.effectiveDate = effectiveDate
            doingBusinessAs.endDate = endDate
            doingBusinessAs.save()

        return doingBusinessAs
Esempio n. 2
0
    def __CreateOrUpdateVerifiableClaim(
            self, claim: ClaimParser, verifiableClaimType: VerifiableClaimType,
            verifiableOrg: VerifiableOrg):
        self.__logger.debug("Creating or updating the verifiable claim ...")

        # We don't have enough information to update an existing claim.
        verifiableClaim = VerifiableClaim.objects.filter(claimJSON=claim.json)
        effectiveDate = self.__ToDate(claim.getField("effective_date"))
        endDate = self.__ToDate(claim.getField("end_date"))

        if not verifiableClaim:
            self.__logger.debug(
                "The verifiable claim does not exist.  Creating ...")
            verifiableClaim = VerifiableClaim(
                verifiableOrgId=verifiableOrg,
                claimType=verifiableClaimType,
                # Sould the claim be base64 encoded? i.e. claimJSON = base64.b64encode(claim.json)
                claimJSON=claim.json,
                effectiveDate=effectiveDate,
                endDate=endDate,
                inactiveClaimReasonId=None,
            )
            verifiableClaim.save()
        else:
            self.__logger.debug("The VerifiableClaim already exists ...")
            verifiableClaim = verifiableClaim[0]

        return verifiableClaim
Esempio n. 3
0
    def __CreateOrUpdateVerifiableOrg(self, claim: ClaimParser,
                                      verifiableOrg: VerifiableOrg):
        organizationId = claim.getField("legal_entity_id")
        name = claim.getField("legal_name")
        effectiveDate = self.__ToDate(claim.getField("effective_date"))
        endDate = endDate = self.__ToDate(claim.getField("end_date"))

        orgType = self.__get_VerifiableOrgType(claim)
        jurisdiction = self.__get_Jurisdiction(claim)

        if not verifiableOrg:
            self.__logger.debug("Registering {0} ...".format(name))
            verifiableOrg = VerifiableOrg(orgId=organizationId,
                                          orgTypeId=orgType,
                                          jurisdictionId=jurisdiction,
                                          legalName=name,
                                          effectiveDate=effectiveDate,
                                          endDate=endDate)
            verifiableOrg.save()
        else:
            self.__logger.debug("Updating records for {0} ... ".format(name))
            verifiableOrg.orgId = organizationId
            verifiableOrg.orgTypeId = orgType
            verifiableOrg.jurisdictionId = jurisdiction
            verifiableOrg.legalName = name
            verifiableOrg.effectiveDate = effectiveDate
            verifiableOrg.endDate = endDate
            verifiableOrg.save()

        return verifiableOrg
Esempio n. 4
0
    def __CreateOrUpdateLocation(self, claim: ClaimParser, verifiableOrg: VerifiableOrg, doingBusinessAs: DoingBusinessAs, locationTypeName: str):
      locationType = self.__get_LocationType(locationTypeName)
      addressee = claim.getField("addressee")
      addlDeliveryInfo = "{0}\r\n{1}".format(claim.getField("address_line_2"), claim.getField("country"))
      #unitNumber = claim.getField("")
      streetAddress = claim.getField("address_line_1")
      municipality = claim.getField("city")
      province = claim.getField("province")
      postalCode = claim.getField("postal_code")
      #latLong = claim.getField("")
      effectiveDate = self.__ToDate(claim.getField("effective_date"))
      endDate = self.__ToDate(claim.getField("end_date"))

      orgName = verifiableOrg.legalName
      if doingBusinessAs:
        orgName = doingBusinessAs.dbaName

      location = Location.objects.filter(verifiableOrgId=verifiableOrg, postalCode=postalCode)
      if not location:
        self.__logger.debug("Registering new location for {0} ...".format(orgName))
        location = Location(
          verifiableOrgId = verifiableOrg,
          doingBusinessAsId = doingBusinessAs,
          locationTypeId = locationType,
          addressee = addressee,
          addlDeliveryInfo = addlDeliveryInfo,
          #unitNumber = unitNumber,
          streetAddress = streetAddress,
          municipality = municipality,
          province = province,
          postalCode = postalCode,
          #latLong = latLong,
          effectiveDate = effectiveDate,
          endDate = endDate
        )
        location.save()
      else:
        self.__logger.debug("Updating location for {0} ... ".format(orgName))
        location = location[0]
        location.verifiableOrgId = verifiableOrg
        location.doingBusinessAsId = doingBusinessAs
        location.locationTypeId = locationType
        location.addressee = addressee
        location.addlDeliveryInfo = addlDeliveryInfo
        #location.unitNumber = unitNumber
        location.streetAddress = streetAddress
        location.municipality = municipality
        location.province = province
        location.postalCode = postalCode
        #location.latLong = latLong
        location.effectiveDate = effectiveDate
        location.endDate = endDate
        location.save()

      return location
Esempio n. 5
0
    def __get_VerifiableOrg(self, claim: ClaimParser):
      organizationId = claim.getField("legal_entity_id")

      verifiableOrg = VerifiableOrg.objects.filter(orgId=organizationId)
      if not verifiableOrg:
        self.__logger.debug("Organization with business id {0} does not exist.".format(organizationId))
      else:
        self.__logger.debug("Organization with business id {0} exists.".format(organizationId))
        verifiableOrg = verifiableOrg[0]

      return verifiableOrg
Esempio n. 6
0
 def __get_VerifiableOrgType(self, claim: ClaimParser):
   orgTypeCode = claim.getField("org_type")
   
   verifiableOrgType = VerifiableOrgType.objects.filter(orgType=orgTypeCode)      
   if not verifiableOrgType:
     self.__logger.debug("VerifiableOrgType, {0}, does not exist.  Creating ...".format(orgTypeCode))
     verifiableOrgType = VerifiableOrgType(
       orgType = orgTypeCode,
       description = orgTypeCode,
       displayOrder = 0          
     )
     verifiableOrgType.save()
   else:
     self.__logger.debug("VerifiableOrgType, {0}, exists ...".format(orgTypeCode))
     verifiableOrgType = verifiableOrgType[0]
   
   return verifiableOrgType
Esempio n. 7
0
 def __get_Jurisdiction(self, claim: ClaimParser):
   jurisdictionName = claim.getField("city")
   
   jurisdiction = Jurisdiction.objects.filter(name=jurisdictionName)
   if not jurisdiction:
     self.__logger.debug("Jurisdiction, {0}, does not exist.  Creating ...".format(jurisdictionName))
     jurisdiction = Jurisdiction(
       abbrv = jurisdictionName,
       name = jurisdictionName,
       displayOrder = 0,
       isOnCommonList = True
     )
     jurisdiction.save()
   else:
     self.__logger.debug("Jurisdiction, {0}, exists ...".format(jurisdictionName))
     jurisdiction = jurisdiction[0]
   
   return jurisdiction