Beispiel #1
0
 private void UpdateReuturnBill()
 {
     try
     {
         HttpClients httpClients = new HttpClients();
         if (customerInfo.ReturnBill != null)
         {
             POSReturnBill posReuturnObj = customerInfo.ReturnBill;
             posReuturnObj.IsProcessed        = true;
             posReuturnObj.ProcessingBranchID = SettingHelpers.CurrentBranchId;
             posReuturnObj.ProcessorID        = SettingHelpers.CurrentUserId;
             var jsonString  = JsonConvert.SerializeObject(posReuturnObj);
             var httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json");
             var response    = httpClients.PostAsync("api/returnbill/updateposreturnbillforpos", httpContent);
             if (response.IsSuccessStatusCode)
             {
                 var        result     = response.Content.ReadAsAsync <bool>().Result;
                 POSSession posSession = new POSSession();
                 posSession.Id           = SettingHelpers.CurrentPosSessionId;
                 posSession.ReturnedBill = RemainingAmount;
                 string jsonPosSession        = JsonConvert.SerializeObject(posSession);
                 var    httpContentPosSession = new StringContent(jsonPosSession, Encoding.UTF8, "application/json");
                 var    reponsePosSession     = httpClients.PostAsync("api/possession/updatepossessionforreturnedbillamount", httpContentPosSession);
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        public IHttpActionResult GetReturnBillReceipt(string returnBillNumber)
        {
            try
            {
                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    ReturnBillReceiptAC returnBillReceiptAC = new ReturnBillReceiptAC();
                    POSReturnBill       posReturnBill       = new POSReturnBill();
                    posReturnBill = _iReturnBillRepository.GetPOSReturnBillByReturnBillNumber(returnBillNumber);
                    if (posReturnBill != null)
                    {
                        returnBillReceiptAC.Date                = posReturnBill.ReturningDate.ToString("dd-MM-yyyy hh:mm");
                        returnBillReceiptAC.InvoiceNo           = posReturnBill.POSBill.BillNo;
                        returnBillReceiptAC.Invoice             = InvoiceToHtml.get39(posReturnBill.POSBill.BillNo, 1.5, 20);
                        returnBillReceiptAC.MemberShipNumber    = posReturnBill.POSBill.Customer.MembershipCode;
                        returnBillReceiptAC.ReturnInvoiceNumber = posReturnBill.ReturnedBillNo;

                        List <ReturnBillList>    returnBillList    = new List <ReturnBillList>();
                        List <POSReturnBillItem> listOfPOSBillItem = new List <POSReturnBillItem>();
                        listOfPOSBillItem = _iReturnBillRepository.GetListOfPOSReturnBillItemByReturnBillId(posReturnBill.Id);
                        decimal totalQunatity = 0;
                        decimal totalPrice    = 0;
                        foreach (var posBill in listOfPOSBillItem)
                        {
                            ReturnBillList listOfReturnBill = new ReturnBillList();
                            listOfReturnBill.ItemName       = posBill.POSBillItem.ItemProfile.ItemNameEn;
                            listOfReturnBill.ItemNameArebic = posBill.POSBillItem.ItemProfile.ItemNameSl;
                            listOfReturnBill.Price          = posBill.POSBillItem.SellPrice;
                            listOfReturnBill.ReturnQuantity = posBill.ReturnedQuantity;
                            listOfReturnBill.Total          = (listOfReturnBill.Price * listOfReturnBill.ReturnQuantity);
                            returnBillList.Add(listOfReturnBill);
                            totalQunatity = totalQunatity + listOfReturnBill.ReturnQuantity;
                            totalPrice    = totalPrice + listOfReturnBill.Total;
                        }
                        returnBillReceiptAC.TotalQuantity         = totalQunatity;
                        returnBillReceiptAC.ReturnAmount          = posReturnBill.ReturnedCash;
                        returnBillReceiptAC.ReturnSubtituteAmount = posReturnBill.SubstituteItemsAmount;
                        returnBillReceiptAC.CompanyName           = posReturnBill.BranchDetail.Name;
                        returnBillReceiptAC.CompanyAddress        = posReturnBill.BranchDetail.Address;

                        returnBillReceiptAC.ListOfReturnBillList = returnBillList;
                    }
                    return(Ok(new { isResult = returnBillReceiptAC }));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }
 public IHttpActionResult UpdatePosReturnBillForPOs(POSReturnBill posReturnBill)
 {
     try
     {
         var result = _iReturnBillRepository.UpdatePosReturnBillForPOs(posReturnBill);
         return(Ok(result));
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
Beispiel #4
0
 public IHttpActionResult GetPOSReturnBillByReturnBillNo(string returnbillNo)
 {
     try
     {
         POSReturnBill posReturnBill = _iPOSProcessRepository.GetPOSReturnBillByReturnBillNo(returnbillNo);
         return(Ok(posReturnBill));
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
 /// <summary>
 /// This method used for insert into POSReturnBill. -An
 /// </summary>
 /// <param name="posReturnBill"></param>
 /// <returns></returns>
 public int AddPOSReturnBill(POSReturnBill posReturnBill)
 {
     try
     {
         _posReturnBillContext.Add(posReturnBill);
         _posReturnBillContext.SaveChanges();
         return(posReturnBill.Id);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
 public bool UpdatePosReturnBillForPOs(POSReturnBill posReturnBill)
 {
     try
     {
         var posOjb = _posReturnBillContext.GetById(posReturnBill.Id);
         if (posOjb != null)
         {
             posOjb.IsProcessed        = posReturnBill.IsProcessed;
             posOjb.ProcessorID        = posReturnBill.ProcessorID;
             posOjb.ProcessingBranchID = posReturnBill.ProcessingBranchID;
             posOjb.ModifiedDateTime   = DateTime.UtcNow;
             _posReturnBillContext.Update(posOjb);
             _posReturnBillContext.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
        public bool UpdatePosReturnBillForPOs(POSReturnBill posReturnBill, POSSession posSession)
        {
            var httpClient  = new HttpClients();
            var jsonString  = JsonConvert.SerializeObject(posReturnBill);
            var httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json");
            var response    = httpClient.PostAsync("api/returnbill/updateposreturnbillforpos", httpContent);

            if (response.IsSuccessStatusCode)
            {
                string jsonPosSession        = JsonConvert.SerializeObject(posSession);
                var    httpContentPosSession = new StringContent(jsonPosSession, Encoding.UTF8, "application/json");
                var    reponsePosSession     = httpClient.PostAsync("api/possession/updatepossessionforreturnedbillamount", httpContentPosSession);
                if (!reponsePosSession.IsSuccessStatusCode)
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
            return(true);
        }
        public IHttpActionResult SubmitPOSBill(POSReturnBillAC posReturnBillAC)
        {
            try
            {
                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    if (posReturnBillAC != null)
                    {
                        int branchId;
                        if (posReturnBillAC.BranchId != 0)
                        {
                            branchId = posReturnBillAC.BranchId;
                        }
                        else
                        {
                            branchId = Convert.ToInt32(MerchantContext.UserDetails.BranchId);
                        }

                        POSReturnBill posReturnBill = new POSReturnBill();
                        posReturnBill.CreatedDateTime       = DateTime.UtcNow;
                        posReturnBill.IsProcessed           = false;
                        posReturnBill.IssuingBranchID       = Convert.ToInt32(MerchantContext.UserDetails.BranchId);
                        posReturnBill.POSBillId             = posReturnBillAC.POSBillId;
                        posReturnBill.ProcessingBranchID    = branchId;
                        posReturnBill.ProcessingDate        = posReturnBill.CreatedDateTime;
                        posReturnBill.ProcessorID           = MerchantContext.UserDetails.Id;
                        posReturnBill.ReturneBy             = posReturnBill.ProcessorID;
                        posReturnBill.ReturnedBillNo        = GetReturnBillNumber(posReturnBillAC.ReturnBillNumber);
                        posReturnBill.ReturnedCash          = posReturnBillAC.ReturnCashAmount;
                        posReturnBill.ReturningComments     = posReturnBillAC.Comment;
                        posReturnBill.ReturningDate         = posReturnBill.ProcessingDate;
                        posReturnBill.ReturningType         = Convert.ToInt32(POSBillPaymentType.Cash);
                        posReturnBill.SubstituteItemsAmount = posReturnBillAC.ReturnSubtituteItemsAmount;
                        int posReturnBillId = _iReturnBillRepository.AddPOSReturnBill(posReturnBill);
                        if (posReturnBillId != 0)
                        {
                            if (posReturnBillAC.ReturnBillItemList.Any())
                            {
                                foreach (var returnBillItem in posReturnBillAC.ReturnBillItemList) //this foreach used for add pos return bill item.
                                {
                                    if (returnBillItem.ReturnQunatity > 0)
                                    {
                                        POSReturnBillItem posReturnBillItem = new POSReturnBillItem();
                                        posReturnBillItem.CreatedDateTime  = DateTime.UtcNow;
                                        posReturnBillItem.POSBiillItemID   = returnBillItem.POSBillItemId;
                                        posReturnBillItem.ReturnedBillID   = posReturnBillId;
                                        posReturnBillItem.ReturnedQuantity = returnBillItem.ReturnQunatity;
                                        int id = _iReturnBillRepository.AddPOSReturnBillItem(posReturnBillItem);
                                        if (id != 0)
                                        {
                                            POSReturnBillItem returnPOSRetunBillItem = _iReturnBillRepository.GetPOSReturnBillItemById(id);
                                            if (returnPOSRetunBillItem != null)//this for maintain branch item qunatity,when client return quantity add quantity item in actual quantity.
                                            {
                                                var          posBillItem  = _iReturnBillRepository.GetPOSBillItemById(returnPOSRetunBillItem.POSBiillItemID);
                                                ItemProfile  itemProfile  = _iItemRepository.GetItemProfileObjectById(posBillItem.ItemID);
                                                ItemQuantity itemQuantity = new ItemQuantity();
                                                if (itemProfile != null)
                                                {
                                                    if (itemProfile.IsParentItem)
                                                    {
                                                        itemQuantity = _iItemRepository.GetItemQunatityByBranchIdAndItemId(posBillItem.ItemID, branchId);
                                                        if (itemQuantity != null)
                                                        {
                                                            itemQuantity.ActualQuantity = (itemQuantity.ActualQuantity + returnBillItem.ReturnQunatity);
                                                        }
                                                    }
                                                    else // for sub item
                                                    {
                                                        itemQuantity = _iItemRepository.GetItemQunatityByBranchIdAndItemId(Convert.ToInt32(itemProfile.ParentItemId), branchId);
                                                        if (itemQuantity != null)
                                                        {
                                                            int systemQuantity = itemQuantity.ActualQuantity + (itemProfile.BaseUnit * returnBillItem.ReturnQunatity);
                                                            itemQuantity.ActualQuantity = systemQuantity > 0 ? systemQuantity : 0;
                                                        }
                                                    }
                                                    _iItemRepository.UpdateItemQunatity(itemQuantity);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            return(Ok(new { isResult = posReturnBill.ReturnedBillNo }));
                        }
                    }
                    return(Ok(new { isResult = false }));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }