<?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="PaymentPlan"  package="performa.orm">
                
        <IMPORT value="performa.orm.types.*"/>    

        <TABLE  name="tl_payment_plan"  tablePrefix="object"    polymorphic="FALSE">
                        
            <ATTRIB name="StripeReference"      type="String"       dbcol="stripe_reference"    length="100"    mandatory="true"/>
            <ATTRIB name="PlanName"             type="String"       dbcol="plan_name"           />
            <ATTRIB name="Description"          type="String"       dbcol="description"         />
            <ATTRIB name="CurrencyType"         type="CurrencyType" dbcol="currency_type"       mandatory="true"    attribHelper="EnumeratedAttributeHelper"    defaultValue="CurrencyType.AUD"/>
            <ATTRIB name="Amount"               type="Double"       dbcol="amount"              mandatory="true"    SubType="Currency"  Formatter="Currency"    />
            <ATTRIB name="Interval"             type="Interval"     dbcol="interval"            mandatory="true"    attribHelper="EnumeratedAttributeHelper"    />
            <ATTRIB name="IntervalCount"        type="Integer"      dbcol="interval_count"      mandatory="true"/>
            <ATTRIB name="TrialPeriodDays"      type="Integer"      dbcol="trial_period_days"   />
            <ATTRIB name="ActiveJobCount"       type="Integer"      dbcol="active_job_count"    />

        </TABLE>
        
        <SEARCH type="All"  paramFilter="tl_payment_plan.object_id is not null" orderBy="tl_payment_plan.object_id"   />
        
        <SEARCH type="Max"  paramFilter="tl_payment_plan.object_id IS NOT NULL AND active_job_count IS NOT NULL"    orderBy="tl_payment_plan.active_job_count DESC LIMIT 1" singleton="TRUE"    />
            
    </BUSINESSCLASS>
    
</ROOT>