/// <summary> /// Get customer amount due for the <c>month</c> of the <c>year</c> /// </summary> /// <param name="cust">The customer to get amount due</param> /// <param name="month">The month</param> /// <param name="year">The year</param> /// <returns></returns> public decimal?GetAmountDue(Customer cust, int month, int year) { decimal amountDue = 0; // billing service does not support future date if (DateTimeHelper.IsInFuture(month, year)) { throw new InvalidOperationException("Future date is not supported. Please adjust month and year"); } string amountDueRequestPath = AmountDueUrl .Replace("{UUID}", cust.CustomerId) .Replace("{MONTH}", month.ToString()) .Replace("{YEAR}", year.ToString()); try { JObject jsonObj = JObject.Parse(RestClientHelper.GetJson(BaseUrl, amountDueRequestPath)); var amountDueResult = jsonObj[AMOUNT_DUE_FIELD].FirstOrDefault(); if (amountDueResult != null) { amountDue = decimal.Parse(amountDueResult.ToString()); } return(amountDue); } catch (Exception ex) { Logger.Error(ex); Logger.Error($"Unable to get amount due for {cust.CustomerId}:{cust.Name} for {month}-{year}"); throw new Exception(ex.Message); } }