public static DateTime GetBillingDueDate(DateTime localNow, DateTime currentBillingCycleStart, AccountContract accountContract, int minDaysBeforeDueDate = 10) { if (accountContract.BillingDueDay == null) throw new ArgumentException("accountContract.BillingDueDay must not be null"); if (accountContract.BillingPeriodIndex == null) throw new ArgumentException("accountContract.BillingPeriodIndex must not be null"); var dueDay = accountContract.BillingDueDay.Value; var index = accountContract.BillingPeriodIndex.Value; if (accountContract.BillingPeriodType == "M") { // getting next day that is the same as the indicated in dueDay var nextDate = currentBillingCycleStart.Date.AddDays(dueDay - currentBillingCycleStart.Day); if (nextDate < currentBillingCycleStart) index++; nextDate = nextDate.AddMonths(index, dueDay); if (localNow <= nextDate && nextDate < localNow.Date.AddDays(minDaysBeforeDueDate)) nextDate = nextDate.AddMonths(1, dueDay); return nextDate; } else { throw new NotImplementedException("Support for this BillingPeriodType is not implemented yet."); } }
public static void FillOperationDetails(PayPalExpressCheckoutOperation operation, Practice practice, AccountContract contractInfo, Billing billing) { operation.DefaultCurrencyCode = CurrencyCode.Brazilian_Real; operation.PaymentRequests = new PayPalList<PayPalPaymentRequest> { new PayPalPaymentRequest { BillingAgreementDescription = "O Cerebello é um software de gerênciamento de consultórios e clínicas médicas.", //BillingType = BillingCode.RecurringPayments, Description = "Cerebello - Plano profissional", InvoiceNum = string.Format("{3}{2}:{0}.{1}", billing.IdentitySetName, billing.IdentitySetNumber, practice.Id, DebugConfig.PayPal.InvoiceIdPrefix), Items = new PayPalList<PayPalPaymentRequestItem> { new PayPalPaymentRequestItem { Amount = contractInfo.BillingAmount, Name = "Cerebello SaaS", Description = "Software de gerenciamento de consultório médico.", Category = ItemCategory.Digital, }, }, }, }; if (contractInfo.BillingDiscountAmount > 0) { operation.PaymentRequests[0].Items.Add(new PayPalPaymentRequestItem { Amount = -contractInfo.BillingDiscountAmount, Name = "Desconto", Category = ItemCategory.Digital, }); } }
/// <summary> /// Create a new AccountContract object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="contractTypeId">Initial value of the ContractTypeId property.</param> /// <param name="practiceId">Initial value of the PracticeId property.</param> /// <param name="issuanceDate">Initial value of the IssuanceDate property.</param> /// <param name="isTrial">Initial value of the IsTrial property.</param> /// <param name="isPartialBillingInfo">Initial value of the IsPartialBillingInfo property.</param> public static AccountContract CreateAccountContract(global::System.Int32 id, global::System.Int32 contractTypeId, global::System.Int32 practiceId, global::System.DateTime issuanceDate, global::System.Boolean isTrial, global::System.Boolean isPartialBillingInfo) { AccountContract accountContract = new AccountContract(); accountContract.Id = id; accountContract.ContractTypeId = contractTypeId; accountContract.PracticeId = practiceId; accountContract.IssuanceDate = issuanceDate; accountContract.IsTrial = isTrial; accountContract.IsPartialBillingInfo = isPartialBillingInfo; return accountContract; }
/// <summary> /// Deprecated Method for adding a new object to the AccountContracts EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToAccountContracts(AccountContract accountContract) { base.AddObject("AccountContracts", accountContract); }
private static IEnumerable<DateTimeInterval> GetAccountContractBillingCycles(AccountContract accountContract) { var start = PracticeController.ConvertToLocalDateTime(accountContract.Practice, accountContract.StartDate); if (start == null) return Enumerable.Empty<DateTimeInterval>(); var startValue = start.Value; var periodType = accountContract.BillingPeriodType; var periodSize = accountContract.BillingPeriodSize ?? 1; var periodCount = accountContract.BillingPeriodCount ?? 7305; // = 365.25 * 20 var mainIntervals = DateTimeHelper.IntervalRange( startValue, periodCount, d => { if (periodType == "M") return d.AddMonths(periodSize, startValue.Day); if (periodType == "d") return d.AddDays(periodSize); if (periodType == "y") return d.AddYears(periodSize); throw new Exception("Unknown period type."); }); return mainIntervals; }