Salta ai contenuti

@guestcraft/countries

Questi contenuti non sono ancora disponibili nella tua lingua.

The country packs of GuestCraft (ADR 0015, analysis chapter 6). A pack brings the rules of one country as dated data: each version has its sources, the words relied on and the day they were read. Consuming use cases must ask the pack of the property’s country, never test a country code. The contract, and the pure functions that apply it, are in @guestcraft/core/countries.

Subpath Pack Status
@guestcraft/countries/it Italy: cash rounding from 2018 (DL 50/2017, art. 13-quater), consumer prices with taxes from 2007 (Codice del consumo, art. 22) experimental: not yet validated by an Italian professional
@guestcraft/countries/fictitious A country that does not exist, for tests: prices without taxes, a rule that changes, a year when it was repealed, nothing checked before 2020, and retention periods with a register kept for an authority tests only; it covers no country
@guestcraft/countries/conformance checkPack, the kit every pack passes in CI; at startup, countryPackRegistry of the core rechecks the rule values and refuses duplicate packs
import { consumerPriceRule, countryPackRegistry, roundCashTotal } from "@guestcraft/core/countries";
import { italy } from "@guestcraft/countries/it";
const packs = countryPackRegistry([italy]); // once, in the composition root
const policy = packs.ok ? packs.value.forCountry(countryOfTheProperty) : undefined;
const due = policy && roundCashTotal(policy, total, paidOn);
// 10.02 € in cash → 10.00 €; or why not: "none", "other_currency", "not_covered"
const prices = policy && consumerPriceRule(policy, offeredOn); // { includes: ["vat"] }

Cash rounding (payments.cash_rounding) and consumer prices (prices.consumer) are planned: not yet consumed by payment, folio or pricing workflows. Their dated data, pure calculations and startup validation are implemented; these contracts do not yet provide an operator workflow.

Data retention (data.retention, ADR 0052) is consumed: a workspace’s data-protection jurisdiction selects the pack, and DataPolicy.retention(day) of @guestcraft/core/privacy reads the version in force. Each entry is a purpose, whole days or null (keep until erasure) and the instant it counts from, which must be the purpose’s (CORE_RETENTION_STARTS); a pack names the data it collects only for an authority authority.<name>. A purpose a pack leaves out keeps the generic default. The Italian pack has no retention rule yet: it needs a sourced rule and an Italian professional’s review, so Italian workspaces keep the generic defaults.

  1. Find the primary source, such as Normattiva or the official journal, and read its version history.

  2. Add a version of the rule. A version needs:

    • its first day, as the history shows, and its last day if it ends;
    • its sources: the link to each version read, the words relied on and the day you read them;
    • its value, or null when the sources say that no such rule applies, as after a repeal.

    Never guess a date. Where the history cannot be verified, start at the earliest version you verified; the period before stays a gap, which use cases report as not covered.

  3. Add tests on the first and last days, with the examples of the source.

  4. Raise the rulesetVersion (YYYY.MM.N).

The conformance kit checks the rest. The rules are pure: no clock, randomness, locale or I/O, which the linters refuse outside adapters/.

Passing the tests does not make a pack legally correct. A pack becomes validated only when a professional of the country has reviewed it, and the manifest records who and when.

  • Whether the municipal tourist tax and other mandatory charges belong in the total shown to consumers. Art. 22 says “imposte” (taxes), every tax; the pack claims VAT only. Art. 49, comma 1, lettera e (“ogni altro costo”, any other cost) is the candidate source for distance contracts.
  • Whether a cash refund is rounded like a payment.
  • The exact boundary of the 6-hour deadline of Alloggiati Web for stays “up to” or “less than” 24 hours, with tests at 23:59, 24:00 and 24:01.