Lesson 04 Livebook: Contractual Loopholes
This notebook keeps chapter 4 focused on the first negotiated GTA rule:
> the normal law is no longer the last law
Mix.install([
{:galactic_trade_authority, path: "../04_contract_loopholes"}
])
Compare Standard And Overridden Outcomes
state = GalacticTradeAuthority.bootstrap_registry!()
%{
standard_tax: state.standard_water_shipment.tax_due,
exempt_tax: state.exempt_water_shipment.tax_due,
restricted_decision: state.permitted_restricted_shipment.route_decision,
restricted_summary: state.permitted_restricted_shipment.override_summary
}
Inspect A Failed Restricted Shipment
try do
GalacticTradeAuthority.Resources.Shipment.register_restricted!(%{
manifest_number: "GTA-4005",
quantity: 6,
declared_value: 16_000,
trader_id: state.syndicate_actor.id,
origin_planet_id: state.origin_planet.id,
destination_planet_id: state.restricted_planet.id,
resource_id: state.restricted_resource.id
}, actor: state.syndicate_actor)
rescue
error in Ash.Error.Invalid ->
error.errors
|> Enum.map(&Exception.message/1)
end
The ledger now has to record not just what rule existed, but what document changed its outcome.