public SupplierPayment Save(SupplierPayment payment) { var existPayment = erpNodeDBContext.SupplierPayments.Find(payment.Id); if (existPayment == null && payment.LiabilityAccountId != null) { payment.Id = Guid.NewGuid(); payment.AssetAccount = payment.AssetAccount ?? organization.SystemAccounts.Cash; erpNodeDBContext.SupplierPayments.Add(payment); erpNodeDBContext.SaveChanges(); return(payment); } else if (existPayment != null) { if (existPayment.PostStatus == LedgerPostStatus.Posted) { return(existPayment); } existPayment.TransactionDate = payment.TransactionDate; existPayment.LiabilityAccountId = payment.LiabilityAccountId; existPayment.DiscountAmount = payment.DiscountAmount; existPayment.BankFeeAmount = payment.BankFeeAmount; existPayment.AssetAccountId = payment.AssetAccountId; existPayment.UpdateBalance(); erpNodeDBContext.SaveChanges(); } return(existPayment); }
public void UnPostLedger(SupplierPayment payment) { Console.WriteLine("> Un Posting,"); organization.LedgersDal.RemoveTransaction(payment.Id); payment.PostStatus = LedgerPostStatus.ReadyToPost; erpNodeDBContext.SaveChanges(); }
public void Constructor_WhenNoParameters_DefaultsFields() { // Arrange, Act var sp = new SupplierPayment(); // Assert Assert.AreEqual(PayFrom.Account, sp.PayFrom); Assert.AreNotEqual(DateTime.MinValue, sp.Date); }
//Make a payment to supplier public void makePayment(int orderID) { Order order = orderRepo.GetById(orderID); SupplierPayment newPayment = new SupplierPayment(); newPayment.OrderID = order.OrderID; //might have to pass in partial payment newPayment.Total = order.Total; newPayment.ProcessedDate = DateTime.Now; //might need to change the order status if paid. supplierPaymentRepo.Add(newPayment); }
public SupplierPayment CreateNew(Guid?id) { var payment = new SupplierPayment() { Id = Guid.NewGuid(), TransactionDate = DateTime.Today, LiabilityAccountId = id, AssetAccount = organization.SystemAccounts.Cash }; erpNodeDBContext.SupplierPayments.Add(payment); return(payment); }
private void paymentSupplierToolStripMenuItem_Click(object sender, EventArgs e) { //SupplierPayment aForm=new SupplierPayment(); //aForm.ShowDialog(); try { pnlContext.Controls.Clear(); SupplierPayment aRawMaterialsItemDetails = new SupplierPayment(); aRawMaterialsItemDetails.Parent = this; pnlContext.Controls.Add(aRawMaterialsItemDetails); aRawMaterialsItemDetails.Dock = DockStyle.Fill; } catch (Exception exp) { } }
public void AddPayment(Guid id, DateTime payDate) { var purchase = erpNodeDBContext.Purchases.Find(id); var payment = new SupplierPayment() { Id = Guid.NewGuid(), TransactionDate = payDate, AssetAccount = organization.SystemAccounts.Cash, LiabilityAccount = organization.SystemAccounts.AccountPayable, }; purchase.UpdatePayment(); erpNodeDBContext.SaveChanges(); }
public IActionResult Create(SupplierPaymentViewModel model) { SupplierPayment supplierPayment = _mapper.Map <SupplierPayment>(model); supplierPayment.CreatedDate = DateTime.Now; supplierPayment.Status = 1; var supplierPaymentOwnCheques = new List <SupplierPaymentOwnCheque>(); var supplierPaymentThirdPartyCheque = new List <SupplierPaymentThirdPartyCheque>(); model.OwnChequesId.ForEach(item => { supplierPaymentOwnCheques.Add(new SupplierPaymentOwnCheque() { OwnChequeId = item }); }); model.ThirdPartyChequesId.ForEach(item => { supplierPaymentThirdPartyCheque.Add(new SupplierPaymentThirdPartyCheque() { ThirdPartyChequeId = item }); }); supplierPayment.SupplierPaymentOwnCheques = supplierPaymentOwnCheques; supplierPayment.SupplierPaymentThirdPartyCheques = supplierPaymentThirdPartyCheque; _context.SupplierPayments.Add(supplierPayment); var balanceSheets = _context.BalanceSheets.SingleOrDefault(c => c.BalanceSheetId == 1); if (balanceSheets != null) { balanceSheets.InHandCash -= supplierPayment.InHandCash; } var flag = _context.SaveChanges(); var paymentId = supplierPayment.SupplierPaymentId; if (flag > 0) { var single = _context.Suppliers.Single(x => x.SupplierId == model.SupplierId); single.CurrentBalance -= model.TotalAmount; _context.SaveChanges(); } return(Ok(flag > 0)); }
public ActionResult NewPay(SupplierPayment item) { if (!ModelState.IsValid) { return(View(item)); } item.Supplier = Supplier.Find(item.SupplierId); item.Date = DateTime.Now; item.Creator = CurrentUser.Employee; using (var scope = new TransactionScope()) { item.CreateAndFlush(); } return(RedirectToAction("Index")); }
protected override OpResult _Store(SupplierPayment _obj) { if (_obj == null) { return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "SupplierPayment object cannot be created as it is null")); } if (Exists(_obj)) { ExecuteNonQuery(GetQuery_UpdateQuery(_obj)); return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj)); } ExecuteNonQuery(GetQuery_InsertQuery(_obj)); if (_obj.SupplierPaymentID == null) { _obj.SupplierPaymentID = DbMgr.GetLastInsertID(); } _obj.FromDb = true; return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj)); }
public JsonResult duePaidToSupplier(int InvoiceId, int supplierId, decimal payAmount) { if (InvoiceId != 0) { var invoiceExists = db.PurchaseInvoices.FirstOrDefault(i => i.PurchaseInvoiceID == InvoiceId && i.SupplierID == supplierId); if (invoiceExists != null) { if (invoiceExists.DueAmount > payAmount) { invoiceExists.PaidAmount += payAmount; invoiceExists.DueAmount -= payAmount; } else if (invoiceExists.DueAmount == payAmount) { invoiceExists.IsPaid = true; invoiceExists.PaidAmount += payAmount; invoiceExists.DueAmount -= payAmount; } else { ModelState.AddModelError("", "Not more then due amount"); } db.Entry(invoiceExists).State = EntityState.Modified; db.SaveChanges(); SupplierPayment spmnt = new SupplierPayment(); spmnt.PurchaseInvoiceID = InvoiceId; spmnt.PaidAmount = payAmount; spmnt.PaymentDate = DateTime.Now.Date; spmnt.IsDeleted = false; db.SupplierPayments.Add(spmnt); db.SaveChanges(); } return(Json("Saved", JsonRequestBehavior.AllowGet)); } else { return(Json(null, JsonRequestBehavior.AllowGet)); } }
public SupplierPayment Create(Profile profile, Purchase purchase, DateTime WorkingDate) { var payment = new SupplierPayment() { TransactionDate = WorkingDate, Profile = profile, AssetAccount = organization.SystemAccounts.Cash, TransactionType = TransactionTypes.SupplierPayment, No = NextNumber }; erpNodeDBContext.SupplierPayments.Add(payment); if (purchase != null && purchase.CommercialPayment == null) { payment.AddCommercial(purchase); } erpNodeDBContext.SaveChanges(); return(payment); }
public bool Add(SupplierPayment supplierPayment) { return(Connection.Insert(supplierPayment) != 0); }
public ActionResult NewPay(SupplierPayment item) { if (!ModelState.IsValid) return View (item); item.Supplier = Supplier.Find (item.SupplierId); item.Date = DateTime.Now; item.Creator = CurrentUser.Employee; using (var scope = new TransactionScope ()) { item.CreateAndFlush (); } return RedirectToAction ("Index"); }
public SupplierPaymentConfirmation(SupplierPayment supplierPayment) { Title = ""; SupplierPayment = supplierPayment; }
public SupplierPaymentConfirmation(int supplierID) { Title = ""; SupplierPayment = new SupplierPayment(); SupplierPayment.SupplierID = supplierID; }
public bool PostLedger(SupplierPayment tr, bool SaveImmediately = true) { if (tr.PostStatus == LedgerPostStatus.Posted) { return(false); } tr.AssetAccount = tr.AssetAccount ?? organization.SystemAccounts.Cash; tr.LiabilityAccount = tr.LiabilityAccount ?? organization.SystemAccounts.AccountPayable; tr.UpdateBalance(); var trLedger = new Models.Accounting.LedgerGroup() { Id = tr.Id, TransactionDate = tr.TransactionDate, TransactionName = tr.Name, TransactionNo = tr.No, TransactionType = transactionType, ProfileName = tr.Profile.DisplayName, }; tr.LiabilityAccount = organization.SystemAccounts.AccountPayable; trLedger.AddDebit(tr.LiabilityAccount, tr.TotalCommercialAmount); tr.PaymentRetentions.ToList() .ForEach(pr => trLedger.AddCredit(pr.RetentionType.RetentionToAccount, pr.RetentionAmount)); tr.PaymentFromAccounts.ToList() .ForEach(payFrom => trLedger.AddCredit(payFrom.AccountItem, payFrom.PayAmount)); if (tr.DiscountAmount > 0) { trLedger.AddCredit(organization.SystemAccounts.DiscountTaken, tr.DiscountAmount); } trLedger.AddCredit(tr.AssetAccount, tr.AmountBillPayFromPrimaryAcc); if (tr.BankFeeAmount > 0) { trLedger.AddDebit(organization.SystemAccounts.BankFee, tr.BankFeeAmount); trLedger.AddCredit(tr.AssetAccount, tr.BankFeeAmount); } if (trLedger.FinalValidate()) { tr.PostStatus = LedgerPostStatus.Posted; erpNodeDBContext.LedgerGroups.Add(trLedger); } if (SaveImmediately) { erpNodeDBContext.SaveChanges(); } return(true); }
// // GET: /SupplierPayment/Details/5 public ActionResult Details(int id) { var item = SupplierPayment.Find(id); return(View(item)); }
public bool Update(SupplierPayment supplierPayment) { return(Connection.Update(supplierPayment)); }
private DbUpdateStatement GetQuery_UpdateQuery(SupplierPayment _obj) { return(DbMgr.CreateUpdateClause("SupplierPayments", GetFields(_obj), "SupplierPaymentID", _obj.SupplierPaymentID)); }
public bool Delete(SupplierPayment supplierPayment) { return(Connection.Delete(supplierPayment)); }
private DbInsertStatement GetQuery_InsertQuery(SupplierPayment _obj) { Dictionary <string, DbFieldEntry> fields = GetFields(_obj); return(DbMgr.CreateInsertClause("SupplierPayments", fields)); }