/// <summary> /// Add a line-level Tax Override to the current line. /// - A TaxDate override requires a valid DateTime object to be passed. /// TODO: Verify Tax Override constraints and add exceptions. /// </summary> /// <param name="type">Type of the Tax Override.</param> /// <param name="reason">Reason of the Tax Override.</param> /// <param name="taxAmount">Amount of tax to apply. Required for a TaxAmount Override.</param> /// <param name="taxDate">Date of a Tax Override. Required for a TaxDate Override.</param> /// <returns></returns> public TransactionBuilder WithLineTaxOverride(TaxOverrideType type, string reason, decimal taxAmount = 0, DateTime?taxDate = null) { // Address the DateOverride constraint. if (type.Equals(TaxOverrideType.TaxDate) && taxDate == null) { throw new Exception("A valid date is required for a TaxDate Tax Override."); } var line = GetMostRecentLine("WithLineTaxOverride"); line.taxOverride = new TaxOverrideModel { type = type, reason = reason, taxAmount = taxAmount, taxDate = taxDate }; // Continue building return(this); }