/*<ControllerActionImplementation:PayRestAmount:1/>*/ public ActionResult ExecutePayRestAmount() { ActionResult _result = null; int? i = 0; while (@model.PaymentAmount > 0) { DSS5_SupplyChainFinancialsOptimisation.BO.Transaction tr = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromList(@model.FundedPaidTransactions, i.GetValueOrDefault(0)); if ((@model.PaymentAmount >= (tr?.RestPaymentAmount ?? 0) && (tr?.PaidByBuyer ?? false))) { @model.PaymentAmount = @model.PaymentAmount.GetValueOrDefault(0) - (tr?.RestPaymentAmount ?? 0); tr.RestPaymentAmount = 0; tr.PaymentStatus = "Fully Paid"; } else { if (((tr?.PaidByBuyer ?? false))) { tr.RestPaymentAmount = (tr?.RestPaymentAmount ?? 0) - @model.PaymentAmount.GetValueOrDefault(0); @model.PaymentAmount = 0; tr.PaymentStatus = "Partially Funded Paid"; } } tr.PaymentDate = @model.PaymentDate; i = i.GetValueOrDefault(0) + 1; if ((i == @model.FundedPaidTransactions?.Count())) { break; } } System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.Transaction> copyFundedPaidTransactions = new System.Collections.Generic.List <DSS5_SupplyChainFinancialsOptimisation.BO.Transaction>(); foreach (var tr in @model.FundedPaidTransactions ?? Enumerable.Empty <DSS5_SupplyChainFinancialsOptimisation.BO.Transaction>()) { copyFundedPaidTransactions?.Add(tr); } foreach (var tr in copyFundedPaidTransactions?.Where((t) => t.PaymentStatus == "Fully Paid").ToList() ?? Enumerable.Empty <DSS5_SupplyChainFinancialsOptimisation.BO.Transaction>()) { @model.FundedPaidTransactions?.Remove(tr); } DSS5_SupplyChainFinancialsOptimisation.BO.TransactionPayment payment = new DSS5_SupplyChainFinancialsOptimisation.BO.TransactionPayment(); payment.PaymentAmount = @model.PaymentAmount; payment.PaymentDate = @model.PaymentDate; payment.Agreement = @model.Agreement; payment?.AddTransactions(@model.FundedPaidTransactions?.Where((t) => t.PaymentStatus == "Fully Paid").ToList()); new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Save <DSS5_SupplyChainFinancialsOptimisation.BO.TransactionPayment>(payment); return(_result); }
/*<ControllerActionImplementation:Pay:1/>*/ public ActionResult ExecutePay() { ActionResult _result = null; int? i = 0; while (@model.PaymentAmount > 0) { DSS5_SupplyChainFinancialsOptimisation.BO.Transaction tr = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromList(@model.Transactions, i.GetValueOrDefault(0)); if ((tr?.ToBePaidAmount != null && tr?.ToBePaidAmount != 0)) { if ((@model.PaymentAmount >= (tr?.ToBePaidAmount ?? 0))) { @model.PaymentAmount = @model.PaymentAmount.GetValueOrDefault(0) - (tr?.ToBePaidAmount ?? 0); tr.ToBePaidAmount = 0; tr.PaymentStatus = "Funded Paid"; try { tr.RestPaymentAmount = (((tr?.FundedAmount ?? 0) * 0.05m) / (365 * 61)); } catch (System.Exception x) { zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Error, "TransactionPaymentsForm", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, x); } } else { tr.ToBePaidAmount = (tr?.ToBePaidAmount ?? 0) - @model.PaymentAmount.GetValueOrDefault(0); @model.PaymentAmount = 0; } } else { if ((@model.PaymentAmount >= (tr?.FundedAmount ?? 0))) { @model.PaymentAmount = @model.PaymentAmount.GetValueOrDefault(0) - (tr?.FundedAmount ?? 0); tr.PaymentStatus = "Funded Paid"; if ((tr?.TransactionStatus == null)) { DSS5_SupplyChainFinancialsOptimisation.BO.TransactionStatus trSt = new DSS5_SupplyChainFinancialsOptimisation.BO.TransactionStatus(); trSt.PaymentStatus = true; tr.TransactionStatus = trSt; } else { tr.TransactionStatus.PaymentStatus = true; } try { tr.RestPaymentAmount = ((tr?.FundedAmount ?? 0) * 0.05m) / (365 * 61); } catch (System.Exception x) { zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Error, "TransactionPaymentsForm", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, x); } } else { tr.ToBePaidAmount = (tr?.FundedAmount ?? 0) - @model.PaymentAmount.GetValueOrDefault(0); @model.PaymentAmount = 0; tr.PaymentStatus = "Partially Paid"; } } tr.PaymentDate = @model.PaymentDate; new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Save <DSS5_SupplyChainFinancialsOptimisation.BO.Transaction>(tr); i = i.GetValueOrDefault(0) + 1; if ((i == @model.Transactions?.Count())) { break; } } DSS5_SupplyChainFinancialsOptimisation.BO.TransactionPayment payment = new DSS5_SupplyChainFinancialsOptimisation.BO.TransactionPayment(); payment.PaymentAmount = @model.PaymentAmount; payment.PaymentDate = @model.PaymentDate; payment.Agreement = @model.Agreement; payment?.AddTransactions(@model.Transactions?.Where((t) => t.PaymentStatus == "Funded Paid").ToList()); @model.FundedPaidTransactions?.AddRange(@model.Transactions?.Where((t) => t.PaymentStatus == "Funded Paid").ToList()); foreach (var tr in @model.Transactions?.Where((t) => t.PaymentStatus == "Funded Paid").ToList() ?? Enumerable.Empty <DSS5_SupplyChainFinancialsOptimisation.BO.Transaction>()) { @model.Transactions?.Remove(tr); } return(_result); }
/// <summary> /// Returns true if self and the provided entity have the same Id values /// and the Ids are not of the default Id value /// </summary> protected bool HasSameNonDefaultIdAs(TransactionPayment compareTo) { return(!this.IsTransient() && !compareTo.IsTransient() && this.Id.Equals(compareTo.Id)); }
/*<ControllerActionImplementation:Pay:1/>*/ public ActionResult ExecutePay() { ActionResult _result = null; int? i = 0; while (@model.PaymentAmount > 0) { DSS5_SupplyChainFinancialsOptimisation.BO.Transaction tr = zAppDev.DotNet.Framework.Utilities.Common.GetItemFromList(@model.Transactions, i.GetValueOrDefault(0)); zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "BuyerPaymentForm", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "i= " + (i?.ToString() ?? "") + "! Model Transaction " + (tr?.Id?.ToString() ?? "") + "Value " + (tr?.TransactionValue?.ToString() ?? ""), true); if ((tr?.ToBePaidAmount != null && tr?.ToBePaidAmount != 0)) { if ((@model.PaymentAmount >= (tr?.ToBePaidAmount ?? 0))) { @model.PaymentAmount = @model.PaymentAmount.GetValueOrDefault(0) - (tr?.ToBePaidAmount ?? 0); tr.ToBePaidAmount = 0; tr.PaymentStatus = "Paid by Buyer"; tr.PaidByBuyer = true; } else { tr.ToBePaidAmount = (tr?.ToBePaidAmount ?? 0) - @model.PaymentAmount.GetValueOrDefault(0); @model.PaymentAmount = 0; } } else { if ((@model.PaymentAmount >= (tr?.TransactionValue ?? 0))) { @model.PaymentAmount = @model.PaymentAmount.GetValueOrDefault(0) - (tr?.TransactionValue ?? 0); tr.PaymentStatus = "Paid by Buyer"; tr.PaidByBuyer = true; if ((tr?.TransactionStatus == null)) { DSS5_SupplyChainFinancialsOptimisation.BO.TransactionStatus trSt = new DSS5_SupplyChainFinancialsOptimisation.BO.TransactionStatus(); trSt.PaymentStatus = true; tr.TransactionStatus = trSt; } else { tr.TransactionStatus.PaymentStatus = true; } } else { zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "BuyerPaymentForm", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "--- Else -----Transaction value: " + (tr?.TransactionValue?.ToString() ?? "")); tr.ToBePaidAmount = (tr?.TransactionValue ?? 0) - @model.PaymentAmount.GetValueOrDefault(0); @model.PaymentAmount = 0; tr.PaymentStatus = "Partially Paid by Buyer"; } } tr.PaymentDate = @model.PaymentDate; new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Save <DSS5_SupplyChainFinancialsOptimisation.BO.Transaction>(tr); i = i.GetValueOrDefault(0) + 1; if ((i == @model.Transactions?.Count())) { break; } } DSS5_SupplyChainFinancialsOptimisation.BO.TransactionPayment payment = new DSS5_SupplyChainFinancialsOptimisation.BO.TransactionPayment(); payment.PaymentAmount = @model.PaymentAmount; payment.PaymentDate = @model.PaymentDate; payment.Agreement = @model.Agreement; payment?.AddTransactions(@model.Transactions?.Where((t) => t.PaymentStatus == "Paid by Buyer").ToList()); foreach (var tr in @model.Transactions?.Where((t) => t.PaymentStatus == "Paid by Buyer").ToList() ?? Enumerable.Empty <DSS5_SupplyChainFinancialsOptimisation.BO.Transaction>()) { @model.Transactions?.Remove(tr); } return(_result); }
/// <summary> /// Copies the current object to a new instance /// </summary> /// <param name="deep">Copy members that refer to objects external to this class (not dependent)</param> /// <param name="copiedObjects">Objects that should be reused</param> /// <param name="asNew">Copy the current object as a new one, ready to be persisted, along all its members.</param> /// <param name="reuseNestedObjects">If asNew is true, this flag if set, forces the reuse of all external objects.</param> /// <param name="copy">Optional - An existing [TransactionPayment] instance to use as the destination.</param> /// <returns>A copy of the object</returns> public virtual TransactionPayment Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, TransactionPayment copy = null) { if (copiedObjects == null) { copiedObjects = new Hashtable(); } if (copy == null && copiedObjects.Contains(this)) { return((TransactionPayment)copiedObjects[this]); } copy = copy ?? new TransactionPayment(); if (!asNew) { copy.TransientId = this.TransientId; copy.Id = this.Id; } copy.PaymentAmount = this.PaymentAmount; copy.Receipt = this.Receipt; copy.PaymentDate = this.PaymentDate; if (!copiedObjects.Contains(this)) { copiedObjects.Add(this, copy); } copy.transactions = new List <Transaction>(); if (deep && this.transactions != null) { foreach (var __item in this.transactions) { if (!copiedObjects.Contains(__item)) { if (asNew && reuseNestedObjects) { copy.AddTransactions(__item); } else { copy.AddTransactions(__item.Copy(deep, copiedObjects, asNew)); } } else { copy.AddTransactions((Transaction)copiedObjects[__item]); } } } if (deep && this.agreement != null) { if (!copiedObjects.Contains(this.agreement)) { if (asNew && reuseNestedObjects) { copy.Agreement = this.Agreement; } else if (asNew) { copy.Agreement = this.Agreement.Copy(deep, copiedObjects, true); } else { copy.agreement = this.agreement.Copy(deep, copiedObjects, false); } } else { if (asNew) { copy.Agreement = (Agreement)copiedObjects[this.Agreement]; } else { copy.agreement = (Agreement)copiedObjects[this.Agreement]; } } } return(copy); }