public virtual decimal GetTotal(IProductOrder item) { int units = item.GetUnits(); decimal unitPrice = item.GetUnitPrice(); return(units * unitPrice); }
public override void ApplyOffer(IProductOrder order, List <IProductOrder> orders) { if (order == null) { throw new ArgumentNullException("Order object is null"); } if (!IsValid(order)) { throw new OfferNotValidException(string.Format("Offer {0} not valid for this {1} product", Name, order.Product.Name)); } // buyProductSKU count == getProductSKU count so equal // mac book pro= buy product // get product is exist in previous scan // apply offer for existing if (order.Product.SKU == buyProductSKU && (orders.Count(x => x.Product.SKU == getProductSKU) >= orders.Count(x => x.Product.SKU == buyProductSKU))) { var existingGetOrder = orders.FirstOrDefault(x => x.Product.SKU == getProductSKU && x.OfferPrice != 0); if (existingGetOrder != null) { existingGetOrder.OfferPrice -= existingGetOrder.Product.Price; } } // buyProductSKU count == getProductSKU count so equal // HDMI cable= get product // buy product is exist in previous scan // apply offer for current if (order.Product.SKU == getProductSKU && (orders.Count(x => x.Product.SKU == buyProductSKU) >= orders.Count(x => x.Product.SKU == getProductSKU))) { order.OfferPrice -= order.Product.Price; } }
public bool ResolveProductOrder(IProductOrder order, bool resolve) { try { GetLock(); using (StoreKeeperDataContext dataContext = new StoreKeeperDataContext()) { SqlParameter orderIdParam = new SqlParameter("@OrderId", SqlDbType.UniqueIdentifier) { Value = order.OrderId.ToGuid() }; SqlParameter resolveParam = new SqlParameter("@Resolve", SqlDbType.Bit) { Value = resolve }; dataContext.Database.ExecuteSqlCommand("exec ResolveProductOrder @OrderId, @Resolve", orderIdParam, resolveParam); } _productOrders.Clear(); LoadProductOrders(); RequestForCalculation(); return(true); } catch (Exception ex) { Logger.Error(ex); return(false); } }
public override void ApplyOffer(IProductOrder order, List <IProductOrder> orders) { if (order == null) { throw new ArgumentNullException("Order object is null"); } if (!IsValid(order)) { throw new OfferNotValidException(string.Format("Offer {0} not valid for this {1} product", Name, order.Product.Name)); } if (order.Quantity >= nBuy) { order.OfferPrice = order.Quantity * newPrice; } }
public override void ApplyOffer(IProductOrder order, List <IProductOrder> orders) { if (order == null) { throw new ArgumentNullException("Order object is null"); } if (!IsValid(order)) { throw new OfferNotValidException(string.Format("Offer {0} not valid for this {1} product", Name, order.Product.Name)); } int set = (order.Quantity / mOffer); if (set > 0) { order.OfferPrice = (set * nBuy) * order.Product.Price; order.OfferPrice += (order.Quantity - (set * mOffer)) * order.Product.Price; } // 5/2 = 2 //total= 2 * 2 * price = (2*2) * $10 == 4*10 = 40 //total+= 5-( 2*2) =1 * price; = (5-4) =1 * $10 = 10 // remaining one product doesn't have any discount }
public override decimal GetTotal(IProductOrder item) { var regularPrice = base.GetTotal(item); decimal volumeDiscount = 0; int units = item.GetUnits(); decimal unitPrice = item.GetUnitPrice(); if (units >= _volumeThreshold) { volumeDiscount = _volumeThreshold * unitPrice - _volumePrice; int multiplyDiscount = units / _volumeThreshold; //Handle if volumeThreshold is 3 and units are 6 then the discount should be applied twice if (multiplyDiscount > 1) { volumeDiscount *= multiplyDiscount; } } return(regularPrice - volumeDiscount); }
public virtual void ApplyOffer(IProductOrder order, List <IProductOrder> orders) { order.OfferPrice = order.Quantity * order.Product.Price; }
public virtual bool IsValid(IProductOrder order) { return(true); }
public override bool IsValid(IProductOrder order) { return(order.Product.SKU == getProductSKU || order.Product.SKU == buyProductSKU); }
void CreateMaterialRequisition(DepotManagementDataContext ctx, Business_WarehouseOutPut_WholeMachineRequisition billInfo, List <Business_WarehouseOutPut_WholeMachineRequisitionDetail> listDetail, List <Business_WarehouseOutPut_WholeMachineRequisition_StorageID> listStorage, out List <string> listBillNo) { listBillNo = null; ServerModule.IMaterialRequisitionGoodsServer serviceGoods = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IMaterialRequisitionGoodsServer>(); ServerModule.IMaterialRequisitionServer serviceBill = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IMaterialRequisitionServer>(); ServerModule.IStoreServer serviceStore = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IStoreServer>(); IFlowServer serviceFlow = FlowControlService.ServerModuleFactory.GetServerModule <IFlowServer>(); ServerModule.IMaterialRequisitionPurposeServer servicePurpose = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IMaterialRequisitionPurposeServer>(); BillNumberControl billControl = new BillNumberControl(CE_BillTypeEnum.领料单, serviceBill); List <CommonProcessInfo> listProcessInfo = serviceFlow.GetFlowData(billInfo.BillNo); try { List <GoodsInfo> listGoodsInfo = new List <GoodsInfo>(); foreach (Business_WarehouseOutPut_WholeMachineRequisitionDetail detail in listDetail) { decimal requstCount = detail.GoodsCount; foreach (Business_WarehouseOutPut_WholeMachineRequisition_StorageID storage in listStorage) { if (requstCount == 0) { break; } List <View_S_Stock> lstStock = serviceStore.GetGoodsStoreOnlyForAssembly(detail.GoodsID, storage.StorageID).ToList(); foreach (View_S_Stock stock in lstStock) { if (requstCount == 0) { break; } if (stock.库存数量 <= requstCount) { GoodsInfo goodsInfo = new GoodsInfo(); goodsInfo.GoodsID = detail.GoodsID; goodsInfo.BatchNo = stock.批次号; goodsInfo.Provider = stock.供货单位; goodsInfo.GoodsCount = stock.库存数量; goodsInfo.ListInfo = new List <string>(); goodsInfo.ListInfo.Add(listGoodsInfo.Count.ToString()); goodsInfo.ListInfo.Add(storage.StorageID); goodsInfo.ListInfo.Add(stock.库存数量.ToString()); listGoodsInfo.Add(goodsInfo); requstCount = requstCount - stock.库存数量; } else { GoodsInfo goodsInfo = new GoodsInfo(); goodsInfo.GoodsID = detail.GoodsID; goodsInfo.BatchNo = stock.批次号; goodsInfo.Provider = stock.供货单位; goodsInfo.GoodsCount = requstCount; goodsInfo.ListInfo = new List <string>(); goodsInfo.ListInfo.Add(listGoodsInfo.Count.ToString()); goodsInfo.ListInfo.Add(storage.StorageID); goodsInfo.ListInfo.Add(detail.GoodsCount.ToString()); listGoodsInfo.Add(goodsInfo); requstCount = 0; } } } } if (listGoodsInfo != null && listGoodsInfo.Count > 0) { listBillNo = new List <string>(); CommonProcessInfo firstProcess = new CommonProcessInfo(); CommonProcessInfo SecondProcess = new CommonProcessInfo(); CommonProcessInfo ThridProcess = new CommonProcessInfo(); var varTemp = from a in listProcessInfo where a.操作节点 == "新建" orderby a.时间 descending select a; if (varTemp.Count() != 0) { firstProcess = varTemp.First(); } else { throw new Exception("此单据无【新建】流程"); } varTemp = from a in listProcessInfo where a.操作节点 == "审核" orderby a.时间 descending select a; if (varTemp.Count() != 0) { SecondProcess = varTemp.First(); } else { throw new Exception("此单据无【审核】流程"); } varTemp = from a in listProcessInfo where a.操作节点 == "确认" orderby a.时间 descending select a; if (varTemp.Count() != 0) { ThridProcess = varTemp.First(); } foreach (Business_WarehouseOutPut_WholeMachineRequisition_StorageID storage in listStorage) { List <GoodsInfo> listGoodsInfoTemp = (from a in listGoodsInfo where a.ListInfo[1].ToString() == storage.StorageID orderby Convert.ToInt32(a.ListInfo[0]) select a).ToList(); if (listGoodsInfoTemp.Count > 0) { string error = ""; S_MaterialRequisition bill = new S_MaterialRequisition(); bill.AssociatedBillNo = billInfo.BillNo; bill.AssociatedBillType = CE_BillTypeEnum.整台份请领单.ToString(); bill.Bill_ID = billControl.GetNewBillNo(ctx); bill.Bill_Time = ServerTime.Time; bill.BillStatus = "等待出库"; View_HR_Personnel personnelInfo = UniversalFunction.GetPersonnelInfo(firstProcess.工号); bill.Department = personnelInfo.部门编码; bill.DepartmentDirector = SecondProcess.人员; bill.DepotManager = ThridProcess == new CommonProcessInfo() ? BasicInfo.LoginName : ThridProcess.人员; bill.FetchCount = (int)billInfo.MachineCount; bill.FetchType = FetchGoodsType.整台领料.ToString(); bill.FillInPersonnel = firstProcess.人员; bill.FillInPersonnelCode = personnelInfo.工号; bill.ProductType = billInfo.ProductType; bill.PurposeCode = servicePurpose.GetBillPurpose(ctx, billInfo.BillTypeDetail).Code; bill.Remark = billInfo.Remark; bill.StorageID = storage.StorageID; if (!serviceBill.AutoCreateBill(ctx, bill, out error)) { throw new Exception(error); } listBillNo.Add(bill.Bill_ID); for (int i = 0; i < listGoodsInfoTemp.Count; i++) { S_MaterialRequisitionGoods goodsInfo = new S_MaterialRequisitionGoods(); goodsInfo.BasicCount = Convert.ToDecimal(listGoodsInfoTemp[i].ListInfo[2]); goodsInfo.BatchNo = listGoodsInfoTemp[i].BatchNo; goodsInfo.Bill_ID = bill.Bill_ID; goodsInfo.GoodsID = listGoodsInfoTemp[i].GoodsID; goodsInfo.ProviderCode = listGoodsInfoTemp[i].Provider; goodsInfo.RealCount = listGoodsInfoTemp[i].GoodsCount; goodsInfo.Remark = GetWorkBench_WashFlag(billInfo.ProductType, goodsInfo.GoodsID); goodsInfo.RequestCount = listGoodsInfoTemp[i].GoodsCount; IProductOrder serviceProductOrder = ServerModuleFactory.GetServerModule <IProductOrder>(); goodsInfo.ShowPosition = 0; //serviceProductOrder.GetPosition(ctx, billInfo.ProductType, goodsInfo.GoodsID); if (!serviceGoods.AutoCreateGoods(ctx, goodsInfo, out error)) { throw new Exception(error); } } } ctx.SubmitChanges(); } } } catch (Exception ex) { throw new Exception(ex.Message); } }
public override bool IsValid(IProductOrder order) { return(order.Product.SKU == productSKU); }