Ejemplo n.º 1
0
        public IActionResult CreateReceiptExport([FromBody] ReceiptExport model)
        {
            //var model = _mapper.Map<ReceiptExport>(receiptExportCreate);

            _receiptExportService.Add(model);
            _receiptExportService.Save();
            return(Json(new { data = model, message = "Đẫ thêm thành công!" }));
        }
Ejemplo n.º 2
0
        public IActionResult Delete(int id)
        {
            ReceiptExport receiptExport = _receiptExportService.GetById(id);

            receiptExport.IsActive = false;

            _receiptExportService.Update(receiptExport);
            _receiptExportService.Save();
            return(Ok(new { message = "Xoa mem thanh cong" }));
        }
Ejemplo n.º 3
0
        public IHttpActionResult ReceiptExport([FromBody] ReceiptExport receiptExport)
        {
            if (existReferenceNumber(receiptExport.Header.ReferenceNumber, WmsOperation.Receipt))
            {
                return(BadRequest("ReferenceNumber exist:" + receiptExport.Header.ReferenceNumber));
            }

            foreach (ReceiptExportLine receiptExportLine in receiptExport.Lines)
            {
                int receivedQuantity = int.Parse(receiptExportLine.ReceivedQuantity);
                var vReceiptPlanLinesUnconfirmedList = db.VReceiptPlanLines.Where(x => x.ReceiptPlanId.ToString() == receiptExport.Header.ErCode && x.ProductId.ToString() == receiptExportLine.PartNumber && x.RecivedQty < x.ExpectedQty).ToList();
                foreach (VReceiptPlanLines vReceiptPlanLine in vReceiptPlanLinesUnconfirmedList)
                {
                    if (receivedQuantity > 0)
                    {
                        int confirmed = 0;
                        int unconfirmedReceiptPlanLine = vReceiptPlanLine.ExpectedQty - vReceiptPlanLine.RecivedQty;
                        if (unconfirmedReceiptPlanLine == 0)
                        {
                            break;
                        }
                        else if (unconfirmedReceiptPlanLine >= receivedQuantity)
                        {
                            confirmed = receivedQuantity;
                        }
                        else
                        {
                            confirmed = unconfirmedReceiptPlanLine;
                        }
                        var currentDateTime = DateTime.Now;

                        ReceiptPlanLineConfirmWms receiptPlanLineConfirmWms = new ReceiptPlanLineConfirmWms()
                        {
                            WmsDate = currentDateTime
                        };
                        Mapper.Map <ReceiptExportHeader, ReceiptPlanLineConfirmWms>(receiptExport.Header, receiptPlanLineConfirmWms);
                        Mapper.Map <ReceiptExportLine, ReceiptPlanLineConfirmWms>(receiptExportLine, receiptPlanLineConfirmWms);
                        db.ReceiptPlanLineConfirmWms.Add(receiptPlanLineConfirmWms);

                        var receiptPlanLines = db.ReceiptPlanLines.FirstOrDefault(x => x.ReceiptPlanId == vReceiptPlanLine.ReceiptPlanId && x.ReceiptPlanLineNo == vReceiptPlanLine.ReceiptPlanLineNo);
                        receiptPlanLines.RecivedQty += confirmed;
                        receiptPlanLines.LastUpdate  = currentDateTime;
                        receiptPlanLines.LastAuthor  = "Wms";

                        var purchaseOrderLines = db.PurchaseOrderLines.FirstOrDefault(x => x.PurchaseOrderId == vReceiptPlanLine.PurchaseOrderId && x.PurchaseOrderLineNo == vReceiptPlanLine.PurchaseOrderLineNo);
                        purchaseOrderLines.RecivedQty += confirmed;
                        purchaseOrderLines.LastUpdate  = currentDateTime;
                        purchaseOrderLines.LastAuthor  = "Wms";
                        receivedQuantity -= confirmed;
                        db.SaveChanges();
                    }
                }
            }
            return(Ok());
        }
Ejemplo n.º 4
0
 public void Update(ReceiptExport receiptExport)
 {
     try
     {
         _unitOfWork.ReceiptExportRepository.Update(receiptExport);
     }
     catch (Exception e)
     {
         _logger.LogError(e.Message, "update fail");
         throw;
     }
 }
Ejemplo n.º 5
0
 public void Add(ReceiptExport receiptExport)
 {
     try
     {
         _unitOfWork.ReceiptExportRepository.Add(receiptExport);
     }
     catch (Exception e)
     {
         _logger.LogError(e.Message, "add Fail");
         throw;
     }
 }