/** * Set Order - no discount * @param order order * @param trxName transaction */ public void SetOrder(MOrder order, Trx trxName) { SetCashType(CASHTYPE_Invoice); SetC_Currency_ID(order.GetC_Currency_ID()); // Amount Decimal amt = order.GetGrandTotal(); SetAmount(amt); SetDiscountAmt(Env.ZERO); SetWriteOffAmt(Env.ZERO); SetIsGenerated(true); // if (MOrder.DOCSTATUS_WaitingPayment.Equals(order.GetDocStatus())) { Save(trxName); order.SetC_CashLine_ID(GetC_CashLine_ID()); //order.ProcessIt(MOrder.ACTION_WaitComplete); order.ProcessIt(DocActionVariables.ACTION_WAITCOMPLETE); order.Save(trxName); // Set Invoice MInvoice[] invoices = order.GetInvoices(true); int length = invoices.Length; if (length > 0) // get last invoice { _invoice = invoices[length - 1]; SetC_Invoice_ID(_invoice.GetC_Invoice_ID()); } } }
public string GetPaymentUrl(MOrder order, string baseUrl) { var dict = new Dictionary <string, string>() { { "cmd", "_cart" }, { "upload", "1" }, { "business", order.PaymentReceiver }, { "custom", order.Id.ToString() }, { "currency_code", order.Currency }, { "no_shipping", "1" }, { "no_note", "1" }, { "notify_url", PaymentConstants.Providers.PayPal.GetNotifyUrl(baseUrl) }, { "return", baseUrl }, { "cancel_return", baseUrl }, { "image_url", PaymentConstants.GetLogoUrl(baseUrl) } }; for (int i = 1; i <= order.Items.Count; i++) { var item = order.Items[i - 1]; dict.Add("item_name_" + i, item.ProductName); dict.Add("item_number_" + i, item.ProductId.ToString()); dict.Add("amount_" + i, item.Price.ToString()); } return(QueryHelpers.AddQueryString(PayPalUrl, dict)); }
public ActionResult CheckOut() { if (ModelState.IsValid) { if (Session["UserName"] == null) { return(RedirectToAction("Login", "Home")); } else { List <Item> cart = (List <Item>)Session["cart"]; //Save Order MOrder order = new MOrder(); foreach (var item in cart) { order.OProductID = item.Product.ProductID; order.OrderDate = item.Product.ProductDate; order.OUserID = 1;//(int)Session["UserID"]; //(int)item.Product.UserID; order.OrderName = item.Product.ProductName; order.OrderQuantity = item.Product.ProdcutQuantity; order.OrderShipment = null; order.OrderIamge = item.Product.ProductIamge; db.MOrders.Add(order); db.SaveChanges(); } Session.Remove("cart"); Session["CountItems"] = (int)Session["CountItems"] * 0; } } return(View()); }
protected override string DoIt() { order = new MOrder(GetCtx(), GetRecord_ID(), Get_TrxName()); pt = new MPaymentTerm(GetCtx(), order.GetC_PaymentTerm_ID(), Get_TrxName()); CreateOrderPaySchedule(); return(" "); }
public JsonResult Payment(String Address, String FullName, String Phone, String Email) { var order = new MOrder(); int user_id = Convert.ToInt32(Session["User_ID"]); order.Code = DateTime.Now.ToString("yyyyMMddhhMMss"); // yyyy-MM-dd hh:MM:ss order.UserID = user_id; order.CreateDate = DateTime.Now; order.DeliveryAddress = Address; order.DeliveryEmail = Email; order.DeliveryPhone = Phone; order.DeliveryName = FullName; order.Status = 1; db.Order.Add(order); db.SaveChanges(); var OrderID = order.ID; foreach (var c in (List <ModelCart>)Session["Cart"]) { var orderdetails = new MOrderDetail(); orderdetails.OrderID = OrderID; orderdetails.ProductID = c.ProductID; orderdetails.Price = c.Price; orderdetails.Quantity = c.Quantity; orderdetails.Amount = c.Price * c.Quantity; db.OrderDetail.Add(orderdetails); } db.SaveChanges(); Session.Remove("Cart"); Thongbao.set_flash("Bạn đã đặt hàng thành công!", "success"); return(Json(true)); }
public async Task UpdateOrderAsync(Guid paymentId) { MOrder order = await ordersRepository.GetOrderAsync(paymentId); if (order == null) { logger.LogWarning("Order for payment id {0} not found", paymentId); return; } if (order.Status == OrderConstants.Status.Completed) { logger.LogWarning("Order #{0} was already completed", order.Id); return; } order.Status = OrderConstants.Status.Completed; order.LastUpdate = DateTime.Now; await ordersRepository.UpdateOrderAsync(order); foreach (MOrderItem item in order.Items) { await productsRepository.AddProductCustomerAsync(new MProductCustomer() { UserId = order.BuyerId, ProductId = item.ProductId }); } discordService.SendPurchaseNotification(order); logger.LogInformation($"Successfully finished the order #{order.Id}"); }
/************************************************************************** * Create Invoice Line from Order Line * @param order order * @param orderLine line * @param qtyInvoiced qty * @param qtyEntered qty */ private void CreateLine(MOrder order, MOrderLine orderLine, Decimal qtyInvoiced, Decimal qtyEntered) { if (_invoice == null) { _invoice = new MInvoice(order, 0, _DateInvoiced); if (!_invoice.Save()) { throw new Exception("Could not create Invoice (o)"); } } // MInvoiceLine line = new MInvoiceLine(_invoice); line.SetOrderLine(orderLine); line.SetQtyInvoiced(qtyInvoiced); log.Info("Qty Invoiced" + line.GetQtyInvoiced()); line.SetQtyEntered(qtyEntered); line.SetLine(_line + orderLine.GetLine()); if (!line.Save()) { throw new Exception("Could not create Invoice Line (o)"); } log.Fine(line.ToString()); }
/// <summary> /// /// </summary> private static void Run() { IRepository repository = Dependencies.CreateRepository(); MCustomer CurrentCustomer; MOrder PizzaOrder = new MOrder(); PizzaOrder.OrderID = repository.GetOrderCount() + 1; Console.WriteLine("Welcome to PizzaBox!"); Console.WriteLine("Are you a new or returning customer?\n1 - New customer (create new login)\n2 - Returning (sign in)\n3 - Sign in as Guest"); var LoginInput = Console.ReadLine(); if (Int32.Parse(LoginInput) == 1) { CurrentCustomer = CreateNewCustomer(); var customers = repository.GetCustomers(); int TotalCustomers = customers.Count(); CurrentCustomer.CustomerID = TotalCustomers; repository.AddCustomer(CurrentCustomer); Console.WriteLine("You're account has successfully been created!"); //AddCustomer(repository, CurrentCustomer); } else if (Int32.Parse(LoginInput) == 2) { PizzaOrder.Customer.username = UserLogin(); } else { CurrentCustomer = GuestLogin(); } Console.WriteLine($"{PizzaOrder.Customer.username} is logged in!"); SelectStore(PizzaOrder); SelectPizza(PizzaOrder); DisplayOrder(PizzaOrder); // CustomPizza test = PizzaOrder.ListOfPizzas.First(); //Console.WriteLine(PizzaOrder.OrderID); repository.AddOrder(PizzaOrder); int count = repository.GetPizzaCount(); int toppingscount; foreach (CustomPizza item in PizzaOrder.ListOfPizzas) { //int i = 0; toppingscount = repository.GetPizzaToppingCount(); item.OrderId = PizzaOrder.OrderID; item.PizzaId = count + 1; item.PizzaId = repository.GetPizzaCount() + 1; repository.AddPizza(item); //Console.WriteLine($"{item.PizzaId} pizza added"); } Console.WriteLine("Order placed!"); }
/// <summary> /// Complete Shipment /// </summary> private void CompleteShipment() { if (_shipment != null) { // Fails if there is a confirmation if (!_shipment.ProcessIt(_docAction)) { _shipment.Get_TrxName().Rollback(); log.Warning("Failed: " + _shipment); } _shipment.Save(); // if (_msg != null) { MOrder OrderDoc = new MOrder(GetCtx(), _shipment.GetC_Order_ID(), _shipment.Get_TrxName()); AddLog(_shipment.GetM_InOut_ID(), _shipment.GetMovementDate(), null, (_msg + " " + (_shipment.GetProcessMsg() != "" ? (_shipment.GetProcessMsg() + " " + (!_consolidateDocument ? OrderDoc.GetDocumentNo() : " ")) : _shipment.GetDocumentNo()))); } else { AddLog(_shipment.GetM_InOut_ID(), _shipment.GetMovementDate(), null, _shipment.GetDocumentNo()); } _created++; _map = new Dictionary <SParameter, MStorage[]>(); if (_lastPP != null && _lastStorages != null) { _map.Add(_lastPP, _lastStorages); } _shipment.Get_TrxName().Commit(); } _shipment = null; _line = 0; }
public void Test_PizzaCustomer() { var sut = new MOrder(); var actual = sut.Customer.username; Assert.Null(actual); }
public void Test_PizzaList() { var sut = new MOrder(); var actual = sut.ListOfPizzas; Assert.Empty(actual); }
public void Test_PizzaOrderId() { var sut = new MOrder(); var actual = sut.OrderID; Assert.NotEmpty(actual.ToString()); }
public void Test_PizzaOrderToppingsList() { var sut = new MOrder(); var actual = sut.ListOfToppings; Assert.Empty(actual); }
// Added by Bharat on 30 Jan 2018 to Get Inco Term public int GetIncoTerm(Ctx ctx, string fields) { string[] paramValue = fields.Split(','); bool isSOTrx = false; int incoTerm_ID = 0, referenceID = 0; string tableName = "", refColumn = "", qry = ""; isSOTrx = Util.GetValueOfBool(paramValue[0]); tableName = Util.GetValueOfString(paramValue[1]); refColumn = Util.GetValueOfString(paramValue[2]); referenceID = Util.GetValueOfInt(paramValue[3]); if (tableName == "C_Order") { if (referenceID > 0) { MOrder ord = new MOrder(ctx, referenceID, null); incoTerm_ID = ord.GetC_IncoTerm_ID(); } } else if (tableName == "C_Invoice") { if (isSOTrx && referenceID > 0) { MOrder ord = new MOrder(ctx, referenceID, null); incoTerm_ID = ord.GetC_IncoTerm_ID(); } else if (!isSOTrx && referenceID > 0 && refColumn == "C_Order_ID") { MOrder ord = new MOrder(ctx, referenceID, null); incoTerm_ID = ord.GetC_IncoTerm_ID(); } else if (!isSOTrx && referenceID > 0 && refColumn == "M_InOut_ID") { MInOut inOut = new MInOut(ctx, referenceID, null); incoTerm_ID = inOut.GetC_IncoTerm_ID(); } } else if (tableName == "M_InOut") { if (isSOTrx && referenceID > 0) { MOrder ord = new MOrder(ctx, referenceID, null); incoTerm_ID = ord.GetC_IncoTerm_ID(); } else if (!isSOTrx && referenceID > 0 && refColumn == "C_Order_ID") { MOrder ord = new MOrder(ctx, referenceID, null); incoTerm_ID = ord.GetC_IncoTerm_ID(); } else if (!isSOTrx && referenceID > 0 && refColumn == "C_Invoice_ID") { MInvoice inv = new MInvoice(ctx, referenceID, null); incoTerm_ID = inv.GetC_IncoTerm_ID(); } } return(incoTerm_ID); }
public ActionResult DeleteConfirmed(int id) { MOrder mOrder = db.Order.Find(id); db.Order.Remove(mOrder); db.SaveChanges(); Thongbao.set_flash("Đã xóa đơn hàng!", "success"); return(RedirectToAction("Trash")); }
/// <summary> /// /// </summary> /// <returns></returns> private static void SelectStore(MOrder order) { DisplayStoreMenu(); var StoreLocation = Console.ReadLine(); IRepository repository = Dependencies.CreateRepository(); var holder = repository.GetStoreByIndex(int.Parse(StoreLocation)); order.Store.StoreLocation = holder.StoreLocation; order.Store.StoreID = holder.StoreID; }
public int GetC_Currency_ID(Ctx ctx, string fields) { string[] paramValue = fields.Split(','); int C_Order_ID; C_Order_ID = Util.GetValueOfInt(paramValue[0].ToString()); MOrder order = new MOrder(ctx, C_Order_ID, null); return(order.GetC_Currency_ID()); }
} // toString /// <summary> /// Execute Run. /// </summary> /// <returns>clear text info</returns> public String ExecuteRun() { DateTime?dateDoc = GetDateNextRun(); if (!CalculateRuns()) { throw new Exception("No Runs Left"); } // log MRecurringRun run = new MRecurringRun(GetCtx(), this); String msg = "@Created@ "; // Copy if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Order)) { MOrder from = new MOrder(GetCtx(), GetC_Order_ID(), Get_TrxName()); MOrder order = MOrder.CopyFrom(from, dateDoc, from.GetC_DocType_ID(), false, false, Get_TrxName()); run.SetC_Order_ID(order.GetC_Order_ID()); msg += order.GetDocumentNo(); } else if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Invoice)) { MInvoice from = new MInvoice(GetCtx(), GetC_Invoice_ID(), Get_TrxName()); MInvoice invoice = MInvoice.CopyFrom(from, dateDoc, from.GetC_DocType_ID(), false, Get_TrxName(), false); run.SetC_Invoice_ID(invoice.GetC_Invoice_ID()); msg += invoice.GetDocumentNo(); } else if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Project)) { MProject project = MProject.CopyFrom(GetCtx(), GetC_Project_ID(), dateDoc, Get_TrxName()); run.SetC_Project_ID(project.GetC_Project_ID()); msg += project.GetValue(); } else if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_GLJournal)) { MJournalBatch journal = MJournalBatch.CopyFrom(GetCtx(), GetGL_JournalBatch_ID(), dateDoc, Get_TrxName()); run.SetGL_JournalBatch_ID(journal.GetGL_JournalBatch_ID()); msg += journal.GetDocumentNo(); } else { return("Invalid @RecurringType@ = " + GetRecurringType()); } run.Save(Get_TrxName()); // SetDateLastRun(run.GetUpdated()); SetRunsRemaining(GetRunsRemaining() - 1); SetDateNextRun(); Save(Get_TrxName()); return(msg); } // execureRun
/************************************************************************** * Create Invoice Line from Order Line * @param order order * @param orderLine line * @param qtyInvoiced qty * @param qtyEntered qty */ private void CreateLine(MOrder order, MOrderLine orderLine, Decimal qtyInvoiced, Decimal qtyEntered) { if (_invoice == null) { _invoice = new MInvoice(order, 0, _DateInvoiced); //-----------------Column Added by Anuj------------------ int _CountVA009 = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VA009_' AND IsActive = 'Y'")); if (_CountVA009 > 0) { int _PaymentMethod_ID = order.GetVA009_PaymentMethod_ID(); if (_PaymentMethod_ID > 0) { _invoice.SetVA009_PaymentMethod_ID(_PaymentMethod_ID); } } //-----------------Column Added by Anuj------------------ int _CountVA026 = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VA026_' AND IsActive = 'Y'")); if (_CountVA026 > 0) { _invoice.SetVA026_LCDetail_ID(order.GetVA026_LCDetail_ID()); } // Added by Bharat on 29 Jan 2018 to set Inco Term from Order if (_invoice.Get_ColumnIndex("C_IncoTerm_ID") > 0) { _invoice.SetC_IncoTerm_ID(order.GetC_IncoTerm_ID()); } if (!_invoice.Save()) { throw new Exception("Could not create Invoice (o)"); } } // MInvoiceLine line = new MInvoiceLine(_invoice); line.SetOrderLine(orderLine); line.SetQtyInvoiced(qtyInvoiced); // if drop ship line true line.SetIsDropShip(orderLine.IsDropShip()); log.Info("Qty Invoiced" + line.GetQtyInvoiced()); line.SetQtyEntered(qtyEntered); line.SetLine(_line + orderLine.GetLine()); if (!line.Save()) { throw new Exception("Could not create Invoice Line (o)"); } log.Fine(line.ToString()); }
/// <summary> /// Get Due Date based on the settings on Payment Term. /// </summary> /// <param name="order">Order</param> /// <returns>Datetime, Due Date</returns> private DateTime?GetDueDate(MOrder order) { MPaymentTerm payterm = new MPaymentTerm(GetCtx(), order.GetC_PaymentTerm_ID(), Get_TrxName()); String _sql = "SELECT PAYMENTTERMDUEDATE (C_PaymentTerm_ID, DateOrdered) AS DueDate FROM C_Order WHERE C_Order_ID=" + order.GetC_Order_ID(); DateTime? _dueDate = Util.GetValueOfDateTime(DB.ExecuteScalar(_sql.ToString(), null, Get_TrxName())); if (_dueDate == Util.GetValueOfDateTime("1/1/0001 12:00:00 AM")) { _dueDate = DateTime.Now; } return(_dueDate); }
/// <summary> /// GetOrder /// </summary> /// <param name="ctx"></param> /// <param name="fields"></param> /// <returns></returns> public Dictionary <String, String> GetOrder(Ctx ctx, string fields) { string[] paramValue = fields.ToString().Split(','); int C_Order_ID; //Assign parameter value C_Order_ID = Util.GetValueOfInt(paramValue[0].ToString()); MOrder order = new MOrder(ctx, C_Order_ID, null); // End Assign parameter value Dictionary <String, String> retDic = new Dictionary <string, string>(); // Reset Orig Shipment retDic["C_BPartner_ID"] = Util.GetValueOfString(order.GetC_BPartner_ID()); retDic["C_BPartner_Location_ID"] = Util.GetValueOfString(order.GetC_BPartner_Location_ID()); retDic["Bill_BPartner_ID"] = Util.GetValueOfString(order.GetBill_BPartner_ID()); retDic["Bill_Location_ID"] = Util.GetValueOfString(order.GetBill_Location_ID()); if (order.GetAD_User_ID() != 0) { retDic["AD_User_ID"] = Util.GetValueOfString(order.GetAD_User_ID()); } if (order.GetBill_User_ID() != 0) { retDic["Bill_User_ID"] = Util.GetValueOfString(order.GetBill_User_ID()); } retDic["M_PriceList_ID"] = Util.GetValueOfString(order.GetM_PriceList_ID()); retDic["PaymentRule"] = order.GetPaymentRule(); retDic["C_PaymentTerm_ID"] = Util.GetValueOfString(order.GetC_PaymentTerm_ID()); //mTab.setValue ("DeliveryRule", X_C_Order.DELIVERYRULE_Manual); retDic["Bill_Location_ID"] = Util.GetValueOfString(order.GetBill_Location_ID()); retDic["InvoiceRule"] = order.GetInvoiceRule(); retDic["PaymentRule"] = order.GetPaymentRule(); retDic["DeliveryViaRule"] = order.GetDeliveryViaRule(); retDic["FreightCostRule"] = order.GetFreightCostRule(); retDic["ID"] = Util.GetValueOfString(order.Get_ID()); retDic["DateOrdered"] = Util.GetValueOfString(order.GetDateOrdered()); retDic["POReference"] = order.GetPOReference(); retDic["AD_Org_ID"] = Util.GetValueOfString(order.GetAD_Org_ID()); retDic["DeliveryRule"] = order.GetDeliveryRule(); retDic["DeliveryViaRule"] = order.GetDeliveryViaRule(); retDic["M_Shipper_ID"] = Util.GetValueOfString(order.GetM_Shipper_ID()); retDic["FreightAmt"] = Util.GetValueOfString(order.GetFreightAmt()); retDic["AD_OrgTrx_ID"] = Util.GetValueOfString(order.GetAD_OrgTrx_ID()); retDic["C_Activity_ID"] = Util.GetValueOfString(order.GetC_Activity_ID()); retDic["C_Campaign_ID"] = Util.GetValueOfString(order.GetC_Campaign_ID()); retDic["C_Project_ID"] = Util.GetValueOfString(order.GetC_Project_ID()); retDic["User1_ID"] = Util.GetValueOfString(order.GetUser1_ID()); retDic["User2_ID"] = Util.GetValueOfString(order.GetUser2_ID()); retDic["M_Warehouse_ID"] = Util.GetValueOfString(order.GetM_Warehouse_ID()); retDic["Orig_Order_ID"] = Util.GetValueOfString(order.GetOrig_Order_ID()); retDic["Orig_InOut_ID"] = Util.GetValueOfString(order.GetOrig_InOut_ID()); return(retDic); }
public LcDetails GetLcDetail(int Invoice_ID, Ctx ctx) { LcDetails lc = new LcDetails(); MInvoice inv = new MInvoice(ctx, Invoice_ID, null); if (inv.GetC_Order_ID() > 0) { MOrder order = new MOrder(ctx, inv.GetC_Order_ID(), null); try { lc.paymethod = order.GetVA009_PaymentMethod_ID(); if (Util.GetValueOfString(DB.ExecuteScalar("SELECT VA009_PaymentBaseType FROM VA009_PaymentMethod WHERE VA009_PaymentMethod_ID=" + order.GetVA009_PaymentMethod_ID(), null, null)) == "L") { lc.lcno = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT MIN(VA026_LCDetail_ID) FROM VA026_LCDetail WHERE IsActive = 'Y' AND DocStatus IN ('CO' , 'CL') AND c_order_id =" + order.GetC_Order_ID(), null, null)); // Check PO Detail tab of Letter of Credit if (lc.lcno == 0) { lc.lcno = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT MIN(lc.VA026_LCDetail_ID) FROM VA026_LCDetail lc INNER JOIN VA026_PODetail sod ON sod.VA026_LCDetail_ID = lc.VA026_LCDetail_ID WHERE sod.IsActive = 'Y' AND lc.IsActive = 'Y' AND lc.DocStatus IN ('CO' , 'CL') AND sod.C_Order_ID =" + order.GetC_Order_ID(), null, null)); if (lc.lcno != 0) { if (Util.GetValueOfString(DB.ExecuteScalar("SELECT VA026_IsLoanRequired FROM VA026_LCDetail WHERE VA026_LCDetail_ID=" + lc.lcno, null, null)) == "Y") { lc.trloan_id = Util.GetValueOfInt(DB.ExecuteScalar("SELECT VA026_TRLoanApplication_ID FROM VA026_TRLoanApplication WHERE IsActive='Y' AND DOCSTATUS='CO' AND VA026_LCDetail_ID= " + lc.lcno, null, null)); } } } else { if (Util.GetValueOfString(DB.ExecuteScalar("SELECT VA026_IsLoanRequired FROM VA026_LCDetail WHERE VA026_LCDetail_ID=" + lc.lcno, null, null)) == "Y") { lc.trloan_id = Util.GetValueOfInt(DB.ExecuteScalar("SELECT VA026_TRLoanApplication_ID FROM VA026_TRLoanApplication WHERE IsActive='Y' AND DOCSTATUS='CO' AND VA026_LCDetail_ID= " + lc.lcno, null, null)); } } } else { lc.lcno = 0; lc.trloan_id = 0; } } catch (Exception e) { } } return(lc); }
private DateTime?GetDueDate(MOrder Order) { MPaymentTerm payterm = new MPaymentTerm(GetCtx(), Order.GetC_PaymentTerm_ID(), Get_TrxName()); String _sql = "Select PAYMENTTERMDUEDATE (C_PaymentTerm_ID, DATEOrderD) as DueDate from C_Order where C_Order_ID=" + Order.GetC_Order_ID(); DateTime? _dueDate = Util.GetValueOfDateTime(DB.ExecuteScalar(_sql.ToString(), null, Get_TrxName())); if (_dueDate == Util.GetValueOfDateTime("1/1/0001 12:00:00 AM")) { _dueDate = DateTime.Now; } return(_dueDate); }
public async Task <MOrder> CreateOrderAsync(OrderParams orderParams) { MOrder order = MOrder.FromParams(orderParams); order.Seller = await usersRepository.GetUserAsync <Seller>(order.SellerId); order.Status = OrderConstants.Status.Pending; order.Currency = "USD"; order.PaymentMethod = orderParams.PaymentMethod; order.PaymentReceiver = order.GetReceiver(order.PaymentMethod); foreach (var itemParams in orderParams.Items) { MOrderItem item = MOrderItem.FromParams(itemParams); item.Product = await productsRepository.GetProductAsync(item.ProductId, order.BuyerId); if (item.Product == null) { return(null); } if (order.SellerId != item.Product.SellerId) { return(null); } if (item.Product.Customer != null) { return(null); } item.ProductName = item.Product.Name; item.Price = item.Product.Price; order.TotalPrice += item.Price; order.Items.Add(item); } Payment payment = Payment.Create(order.PaymentMethod, string.Empty, order.GetReceiver(order.PaymentMethod), order.Currency, order.TotalPrice); foreach (MOrderItem item in order.Items) { payment.AddItem(item.ProductName, 1, item.Price); } order.PaymentId = await PaymentGatewayClient.CreatePaymentAsync(payment); return(await ordersRepository.AddOrderAsync(order)); }
public ActionResult Undo(int?id) { MOrder mOrder = db.Order.Find(id); mOrder.Trash = 0; mOrder.Updated_at = DateTime.Now; mOrder.Updated_by = int.Parse(Session["Admin_ID"].ToString()); db.Entry(mOrder).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Khôi phục thành công!" + " ID = " + id, "success"); return(RedirectToAction("Trash")); }
public ActionResult DelTrash(int?id) { MOrder mOrder = db.Order.Find(id); mOrder.Trash = 1; mOrder.Updated_at = DateTime.Now; mOrder.Updated_by = 1; db.Entry(mOrder).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Đã hủy đơn hàng!" + " ID = " + id, "success"); return(RedirectToAction("Index")); }
protected override string DoIt() { try { if (C_Order_ID < 1) { return("Failed"); } //int c_Order_ID = Util.GetValueOfInt(DB.ExecuteScalar("SELECT C_Order_ID From C_Order WHERE DocumentNo=" + salesOrderNo)); MOrder order = new MOrder(GetCtx(), C_Order_ID, null); int C_DocType_ID = order.GetC_DocTypeTarget_ID(); string baseType = DB.ExecuteScalar("SELECT DocSubTypeSO From C_DocType WHERE isactive='Y' AND C_DocType_ID=" + C_DocType_ID).ToString(); if (!(baseType.Equals("PR") || baseType.Equals("WI"))) { return("Failed"); } MPayment payment = new MPayment(GetCtx(), 0, null); payment.SetAD_Client_ID(GetCtx().GetAD_Client_ID()); payment.SetAD_Org_ID(GetCtx().GetAD_Org_ID()); //payment.SetDocumentNo(MS payment.SetC_BankAccount_ID(Util.GetValueOfInt( DB.ExecuteScalar("Select c_bankAccount_ID from c_bankaccount where isdefault='Y' and isactive='Y'"))); payment.SetDateTrx(DateTime.Now); payment.SetDateAcct(DateTime.Now); payment.SetC_BPartner_ID(order.GetC_BPartner_ID()); payment.SetPayAmt(order.GetGrandTotal()); payment.SetC_Currency_ID(order.GetC_Currency_ID()); payment.SetTenderType("K"); payment.SetDocStatus("IP"); if (baseType.Equals("PR")) //prepay Order { payment.SetC_Order_ID(order.GetC_Order_ID()); payment.SetIsPrepayment(true); } else if (baseType.Equals("WI"))//OnCreditOrder { payment.SetC_Invoice_ID(order.GetC_Invoice_ID()); } payment.Save(); return(payment.GetDocumentNo().ToString()); } catch { return("Failed"); } }
public async Task <IActionResult> PostOrderAsync([FromBody] OrderParams orderParams) { orderParams.BaseUrl = Request.Headers["Origin"]; orderParams.BuyerId = User.Id(); MOrder order = await orderService.CreateOrderAsync(orderParams); if (order == null) { return(BadRequest()); } return(Ok(order)); }
/// <summary> /// Process Order /// </summary> /// <param name="order">order</param> /// <returns>true if ok</returns> private bool Process(MOrder order) { log.Info(order.ToString()); // order.SetDocAction(_DocAction); if (order.ProcessIt(_DocAction)) { order.Save(); AddLog(0, null, null, order.GetDocumentNo() + ": OK"); return(true); } AddLog(0, null, null, order.GetDocumentNo() + ": Error " + order.GetProcessMsg()); return(false); }
/// <summary> /// Create PO's /// </summary> private void CreatePO() { int noOrders = 0; String info = ""; // MOrder order = null; MWarehouse wh = null; X_T_Replenish[] replenishs = GetReplenish(_M_WareSource); for (int i = 0; i < replenishs.Length; i++) { X_T_Replenish replenish = replenishs[i]; if (wh == null || wh.GetM_Warehouse_ID() != replenish.GetM_Warehouse_ID()) { wh = MWarehouse.Get(GetCtx(), replenish.GetM_Warehouse_ID()); } // if (order == null || order.GetC_BPartner_ID() != replenish.GetC_BPartner_ID() || order.GetM_Warehouse_ID() != replenish.GetM_Warehouse_ID()) { order = new MOrder(GetCtx(), 0, Get_TrxName()); order.SetIsSOTrx(false); order.SetC_DocTypeTarget_ID(_C_DocType_ID); MBPartner bp = new MBPartner(GetCtx(), replenish.GetC_BPartner_ID(), Get_TrxName()); order.SetBPartner(bp); order.SetSalesRep_ID(GetAD_User_ID()); order.SetDescription(Msg.GetMsg(GetCtx(), "Replenishment")); // Set Org/WH order.SetAD_Org_ID(wh.GetAD_Org_ID()); order.SetM_Warehouse_ID(wh.GetM_Warehouse_ID()); if (!order.Save()) { return; } log.Fine(order.ToString()); noOrders++; info += " - " + order.GetDocumentNo(); } MOrderLine line = new MOrderLine(order); line.SetM_Product_ID(replenish.GetM_Product_ID()); line.SetQty(replenish.GetQtyToOrder()); line.SetPrice(); line.Save(); } _info = "#" + noOrders + info; log.Info(_info); } // createPO