@prefix : <http://datacenter.app.br/ontology/sales/entity/sales_opportunity/type.ttl#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix funnel: <http://datacenter.app.br/ontology/sales/entity/sales_funnel/type.ttl#> .
@prefix obdc: <http://ontobdc.org/ontology/domain/ns.ttl#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://datacenter.app.br/ontology/sales/entity/sales_opportunity/type.ttl#> .

<http://datacenter.app.br/ontology/sales/entity/sales_opportunity/type.ttl>
    rdf:type owl:Ontology ;
    owl:imports <http://ontobdc.org/ontology/domain/ns.ttl> ,
        <http://datacenter.app.br/ontology/sales/entity/sales_funnel/type.ttl> ;
    dcterms:title "Sales Opportunity Ontology"@en ;
    dcterms:description
        "Concrete identifiable selling possibilities managed through reusable sales funnels."@en .

#################################################################
#    Classes and Datatypes
#################################################################

:SalesOpportunity
    rdf:type owl:Class ,
        obdc:DataEntity ;
    rdfs:label "Sales Opportunity"@en ,
        "Oportunidade de venda"@pt-BR ;
    rdfs:comment
        "A concrete identifiable selling possibility managed through a sales funnel."@en ;
    schema:identifier "sales_opportunity" .

:OpportunityState
    rdf:type owl:Class ;
    rdfs:label "Opportunity State"@en ,
        "Estado da oportunidade"@pt-BR ;
    rdfs:comment
        "Controlled lifecycle state of a sales opportunity, distinct from its current funnel stage."@en .

:ProbabilityValue
    rdf:type rdfs:Datatype ;
    owl:onDatatype xsd:decimal ;
    owl:withRestrictions (
        [ xsd:minInclusive "0"^^xsd:decimal ]
        [ xsd:maxInclusive "1"^^xsd:decimal ]
    ) .

#################################################################
#    Object Properties
#################################################################

:usesFunnel
    rdf:type owl:ObjectProperty ,
        owl:FunctionalProperty ;
    rdfs:domain :SalesOpportunity ;
    rdfs:range funnel:SalesFunnel ;
    rdfs:label "uses funnel"@en ,
        "usa funil"@pt-BR .

:currentStage
    rdf:type owl:ObjectProperty ,
        owl:FunctionalProperty ;
    rdfs:domain :SalesOpportunity ;
    rdfs:range funnel:SalesFunnelStage ;
    rdfs:label "current stage"@en ,
        "etapa atual"@pt-BR .

:opportunityState
    rdf:type owl:ObjectProperty ,
        owl:FunctionalProperty ;
    rdfs:domain :SalesOpportunity ;
    rdfs:range :OpportunityState ;
    rdfs:label "opportunity state"@en ,
        "estado da oportunidade"@pt-BR .

:prospectiveCustomer
    rdf:type owl:ObjectProperty ,
        owl:FunctionalProperty ;
    rdfs:domain :SalesOpportunity ;
    rdfs:range [
        rdf:type owl:Class ;
        owl:unionOf (
            schema:Person
            schema:Organization
        )
    ] ;
    rdfs:label "prospective customer"@en ,
        "cliente potencial"@pt-BR .

:contact
    rdf:type owl:ObjectProperty ;
    rdfs:domain :SalesOpportunity ;
    rdfs:range schema:Person ;
    rdfs:label "contact"@en ,
        "contato"@pt-BR .

:owner
    rdf:type owl:ObjectProperty ,
        owl:FunctionalProperty ;
    rdfs:domain :SalesOpportunity ;
    rdfs:range schema:Person ;
    rdfs:label "owner"@en ,
        "responsável"@pt-BR .

#################################################################
#    Data Properties
#################################################################

:estimatedValue
    rdf:type owl:DatatypeProperty ;
    rdfs:domain :SalesOpportunity ;
    rdfs:range xsd:decimal ;
    rdfs:label "estimated value"@en ,
        "valor estimado"@pt-BR .

:currency
    rdf:type owl:DatatypeProperty ,
        owl:FunctionalProperty ;
    rdfs:domain :SalesOpportunity ;
    rdfs:range xsd:string ;
    rdfs:label "currency"@en ,
        "moeda"@pt-BR ;
    rdfs:comment
        "Three-letter ISO 4217 currency code."@en .

:probability
    rdf:type owl:DatatypeProperty ,
        owl:FunctionalProperty ;
    rdfs:domain :SalesOpportunity ;
    rdfs:range :ProbabilityValue ;
    rdfs:label "probability"@en ,
        "probabilidade"@pt-BR ;
    rdfs:comment
        "Decimal probability from zero to one."@en .

:expectedCloseDate
    rdf:type owl:DatatypeProperty ,
        owl:FunctionalProperty ;
    rdfs:domain :SalesOpportunity ;
    rdfs:range xsd:date ;
    rdfs:label "expected close date"@en ,
        "data esperada de fechamento"@pt-BR .

:closedAt
    rdf:type owl:DatatypeProperty ,
        owl:FunctionalProperty ;
    rdfs:domain :SalesOpportunity ;
    rdfs:range xsd:dateTime ;
    rdfs:label "closed at"@en ,
        "fechada em"@pt-BR .

:closeReason
    rdf:type owl:DatatypeProperty ,
        owl:FunctionalProperty ;
    rdfs:domain :SalesOpportunity ;
    rdfs:range xsd:string ;
    rdfs:label "close reason"@en ,
        "motivo do fechamento"@pt-BR .

#################################################################
#    Opportunity States
#################################################################

:Open
    rdf:type owl:NamedIndividual ,
        :OpportunityState ;
    rdfs:label "Open"@en ,
        "Aberta"@pt-BR ;
    schema:identifier "open" .

:Won
    rdf:type owl:NamedIndividual ,
        :OpportunityState ;
    rdfs:label "Won"@en ,
        "Ganha"@pt-BR ;
    schema:identifier "won" .

:Lost
    rdf:type owl:NamedIndividual ,
        :OpportunityState ;
    rdfs:label "Lost"@en ,
        "Perdida"@pt-BR ;
    schema:identifier "lost" .

:Cancelled
    rdf:type owl:NamedIndividual ,
        :OpportunityState ;
    rdfs:label "Cancelled"@en ,
        "Cancelada"@pt-BR ;
    schema:identifier "cancelled" .
