sdmx-twg / vtl

This repository is used for maintaining the SDMX-VTL specification
9 stars 8 forks source link

Create datapoint ruleset: make signature optional #386

Closed antonio-olleros closed 5 months ago

antonio-olleros commented 7 months ago

Issue Description

We write very often datapoint rulesets involving severan variables, and in these cases the information in the signature is redundant, and it is time consuming and error prone to synchronize the siganture of the ruleset with its body.

For instance:

define datapoint ruleset derivatives_fx(
        variable  EffectiveStartDate, MaturtityEndDateTerminationDate, SettlementCurrency,
                  SettlementDate,IdentifierOfCounterparty1Type, IdentifierOfCounterparty1,
                  TradingCapacity, BeneficiaryIdType, BeneficiaryId) is
    r500002: EffectiveStartDate <= MaturtityEndDateTerminationDate errorcode "Effective-start-date cannot be higher than maturity date";
    r500005: not isnull(SettlementCurrency) errorcode "Settelment Currency is not reported";
    r500006: not isnull(SettlementDate) errorcode "Settelment Date is not reported";
    r500009L: when IdentifierOfCounterparty1Type = "L" then length(IdentifierOfCounterparty1) = 20 errorcode "IdentifierOfCounterparty1 does not match identifierofcounterparty1type";
    r500009I: when IdentifierOfCounterparty1Type = "I" then length(IdentifierOfCounterparty1) = 9 errorcode "IdentifierOfCounterparty1 does not match identifierofcounterparty1type";
    r500009S: when IdentifierOfCounterparty1Type = "S" then length(IdentifierOfCounterparty1) = 11 errorcode "IdentifierOfCounterparty1 does not match identifierofcounterparty1type";
    r500012: when TradingCapacity = "A" then not (isnull(BeneficiaryIdType) or isnull(BeneficiaryId)) errorcode "Beneficiary must be reported when Trading Capacity - Agent";
    r500013: not( isnull(BeneficiaryIdType) xor isnull(BeneficiaryId)) errorcode "This is an error"
end datapoint ruleset;

The signature in this case is not adding any necessary information, so this could be written as:

define datapoint ruleset derivatives_fx(variable) is
    r500002: EffectiveStartDate <= MaturtityEndDateTerminationDate errorcode "Effective-start-date cannot be higher than maturity date";
    r500005: not isnull(SettlementCurrency) errorcode "Settelment Currency is not reported";
    r500006: not isnull(SettlementDate) errorcode "Settelment Date is not reported";
    r500009L: when IdentifierOfCounterparty1Type = "L" then length(IdentifierOfCounterparty1) = 20 errorcode "IdentifierOfCounterparty1 does not match identifierofcounterparty1type";
    r500009I: when IdentifierOfCounterparty1Type = "I" then length(IdentifierOfCounterparty1) = 9 errorcode "IdentifierOfCounterparty1 does not match identifierofcounterparty1type";
    r500009S: when IdentifierOfCounterparty1Type = "S" then length(IdentifierOfCounterparty1) = 11 errorcode "IdentifierOfCounterparty1 does not match identifierofcounterparty1type";
    r500012: when TradingCapacity = "A" then not (isnull(BeneficiaryIdType) or isnull(BeneficiaryId)) errorcode "Beneficiary must be reported when Trading Capacity - Agent";
    r500013: not( isnull(BeneficiaryIdType) xor isnull(BeneficiaryId)) errorcode "This is an error"
end datapoint ruleset;

Which is much more readable and easy to maintin

Proposed Solution

For datapoint rulesets defined on mariables, the list of variables is not mandatory

NicoLaval commented 7 months ago

Agree

vpinna80 commented 7 months ago

Agree

linardian commented 5 months ago

Agreed. Last version of the 2.1 Reference Manual updated.