from typing import List from .legal_disbursements_vat_types import DisbursementFacts, DisbursementTreatment # HMRC VAT Notice 700 section 25.1.1, in HMRC's order. All must be met. _CONDITIONS = ( ("actedAsAgent", "acted_as_agent"), ("clientReceivedAndUsed", "client_received_and_used"), ("clientResponsibleToPay", "client_responsible_to_pay"), ("clientAuthorisedPayment", "client_authorised_payment"), ("clientKnewThirdParty", "client_knew_third_party"), ("separatelyItemised", "separately_itemised"), ("exactAmountRecovered", "exact_amount_recovered"), ("additionalToOwnSupply", "additional_to_own_supply"), ) def disbursement_vat(facts: DisbursementFacts) -> DisbursementTreatment: """Disbursement (outside the scope of your VAT) or recharge (VAT due), and why.""" failed: List[str] = [] for name, attr in _CONDITIONS: value = getattr(facts, attr) if not isinstance(value, bool): raise ValueError("%s must be true or false, received %s" % (name, value)) if not value: failed.append(name) if not failed: return DisbursementTreatment( treatment="disbursement", failed_conditions=[], reason="all eight conditions of VAT Notice 700 section 25.1.1 are met: pass the cost on at the exact amount, " "outside the value of your supply, with no VAT added", ) return DisbursementTreatment( treatment="recharge", failed_conditions=failed, reason="not a disbursement for VAT purposes (%s not met): include the cost in the value of your supply " "and charge VAT on it at the rate of your main supply" % (", ".join(failed),), )