<?xml version="1.0" encoding="UTF-8"?>

<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>

    <BUSINESSCLASS  name="Company"    package="performa.orm">
        
        <IMPORT value="performa.orm.types.*"/>
        <IMPORT value="performa.orm.types.TimeZone"/>
        
        <MULTIPLEREFERENCE  name="Users"        type="CompanyUser"  backreferenceName="Company" />
        <MULTIPLEREFERENCE  name="Clients"      type="Client"       backreferenceName="Company" />
        <MULTIPLEREFERENCE  name="HiringTeams"  type="HiringTeam"   backreferenceName="Company" />

        <TRANSIENT  name="HiringTeamName"   type="String"   />
        <TRANSIENT  name="ManageOwnBilling" type="Boolean"      defaultValue="Boolean.FALSE"/>
        <TRANSIENT  name="HTCountry"        type="Countries"    attribHelper="EnumeratedAttributeHelper"/>
        <TRANSIENT  name="IsLogoDeleted"    type="Boolean"      defaultValue="Boolean.FALSE"/>
        <TRANSIENT  name="CompletedProfile" type="Boolean"      defaultValue="Boolean.FALSE"/>
        <TRANSIENT  name="PaymentJobCount"  type="Integer"  />
        <TRANSIENT  name="StripeLast4"      type="String"   />
        <TRANSIENT  name="StripeBrand"      type="String"   />
        
        <TRANSIENTSINGLE name="Owner"       type="CompanyUser"  />
        <TRANSIENTSINGLE name="BillingTeam" type="HiringTeam"   />


        <TABLE  name="tl_company" tablePrefix="object">
            
            <ATTRIB name="CompanyName"          type="String"           dbcol="company_name"        mandatory="true"    length="100"    />
            <ATTRIB name="CompanyLogo"          type="BinaryContent"    dbcol="company_logo"        mandatory="false"   binaryHandler="loggedin"    attribHelper="BLOBAttributeHelper"  attribHelperInstance="BLOBAttributeHelper.INSTANCE" />
            <ATTRIB name="HiringTeamType"       type="HiringTeamType"   dbcol="hiring_team_type"    mandatory="false"   attribHelper="EnumeratedAttributeHelper"/>
            <ATTRIB name="Industry"             type="Industry"         dbcol="industry"            mandatory="false"   attribHelper="EnumeratedAttributeHelper"/>
            <ATTRIB name="TimeZone"             type="TimeZone"         dbcol="time_zone"           mandatory="false"   attribHelper="EnumeratedAttributeHelper"/>
            <ATTRIB name="IsVerified"           type="Boolean"          dbcol="is_verified"         defaultValue="Boolean.FALSE"/>
            <ATTRIB name="State"                type="State"            dbcol="state"               mandatory="false"   defaultValue="State.WA"     attribHelper="EnumeratedAttributeHelper"/>
            <ATTRIB name="Country"              type="Countries"        dbcol="country"             mandatory="false"   defaultValue="Countries.AU" attribHelper="EnumeratedAttributeHelper"/>
            <ATTRIB name="PostCode"             type="String"           dbcol="post_code"           mandatory="false"   length="10"/>
            <ATTRIB name="City"                 type="String"           dbcol="city"                mandatory="false"   length="100"/>
            <ATTRIB name="HasClientSupport"     type="Boolean"          dbcol="has_client_support"  mandatory="false"   defaultValue="Boolean.FALSE"/>
            <ATTRIB name="StripeReference"      type="String"           dbcol="stripe_reference"    length="100"        />
            <ATTRIB name="StripeSubscription"   type="String"           dbcol="stripe_subscription" length="100"        />
            <ATTRIB name="NameOnCard"           type="String"           dbcol="name_on_card"        length="100"        />
            <ATTRIB name="CardPostCode"         type="String"           dbcol="card_post_code"      length="10"         />
            <ATTRIB name="CardID"               type="String"           dbcol="card_id"             length="100"        />
            <ATTRIB name="PlanRenewedOn"        type="Date"             dbcol="plan_renewed_on"     mandatory="false"   />
            <ATTRIB name="UsedCredits"          type="Integer"          dbcol="used_credits"        />
            <ATTRIB name="CompanyStatus"        type="CompanyStatus"    dbcol="company_status"      mandatory="true"    attribHelper="EnumeratedAttributeHelper"    defaultValue="CompanyStatus.ACTIVE" />

            <SINGLEREFERENCE    name="AddedByUser"          type="CompanyUser"  dbcol="added_by_user_id"        mandatory="true"    />
            <SINGLEREFERENCE    name="PaymentPlan"          type="PaymentPlan"  dbcol="payment_plan_id"         mandatory="false"   />
            
        </TABLE>
        
        <SEARCH type="All"  paramFilter="tl_company.object_id is not null"    >
        </SEARCH>
        
    </BUSINESSCLASS>
    
</ROOT>