예제 #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;
     }
 }
        /// <summary>
        /// This method is used for insert temp data for puchase item by customer. - PS
        /// </summary>
        /// <returns></returns>
        private bool InsertTempTranscation(CustomerPOAC cpoDetailData)
        {
            POSTempTrans tempTrans = new POSTempTrans();

            tempTrans.BranchID         = SettingHelpers.CurrentBranchId;
            tempTrans.CreatedDateTime  = DateTime.UtcNow;
            tempTrans.CustomerID       = cpoDetailData.Customer.Id;
            tempTrans.IsSuspendedBill  = false;
            tempTrans.PurchaseOrderNo  = cpoDetailData.PurchaseOrderNo;
            tempTrans.ReturnedBillNo   = null;
            tempTrans.TransDate        = DateTime.UtcNow;
            tempTrans.TransReference   = string.Empty;
            tempTrans.UserID           = SettingHelpers.CurrentUserId;
            tempTrans.CpoDownPayment   = cpoDetailData.DownPaymentAmount;
            tempTrans.AdditionalAmount = SettingHelpers.AdditionalAmount;

            HttpClients httpClient  = new HttpClients();
            string      jsonString  = JsonConvert.SerializeObject(tempTrans);
            var         httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json");

            var response = httpClient.PostAsync("api/posprocess/insertpostemptransdata", httpContent);

            if (response.IsSuccessStatusCode)
            {
                var tempTranscation = response.Content.ReadAsAsync <POSTempTrans>().Result;
                SettingHelpers.CurrentTempTransId = tempTranscation.Id;
                // bool result = InsertTempTranscationItemData(cpoDetailData.CPOItemDetailPOS.ToList());
                return(true);
            }
            return(false);
        }
 public void DeletePOSTempIransItem(POSTempTransItem posTempTransItem)
 {
     HttpClients httpClient  = new HttpClients();
     string      jsonString  = JsonConvert.SerializeObject(posTempTransItem);
     var         httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json");
     var         response    = httpClient.PostAsync("api/posprocess/deletepostemptransitem", httpContent);
 }
        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);
        }
예제 #5
0
 private void UpdateCreditAccountLimitForCustomer()
 {
     try
     {
         if (!String.IsNullOrEmpty(CreditAccountAmount))
         {
             HttpClients httpClient = new HttpClients();
             customerInfo.Customer.TransactionAmount = customerInfo.Customer.TransactionAmount + Convert.ToDecimal(CreditAccountAmount);
             var jsonString  = JsonConvert.SerializeObject(customerInfo.Customer);
             var httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json");
             var response    = httpClient.PostAsync("api/customer/updatecustomertransctionamount", httpContent);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        /// <summary>
        /// This method  is used for Insert data in POSTempTransItem table.
        /// </summary>
        /// <returns>boolean</returns>
        private bool InsertTempTranscationItemData(List <POSItemDetail> cpoDetailData)
        {
            HttpClients httpClient = new HttpClients();

            foreach (var item in cpoDetailData)
            {
                POSTempTransItem tempItem = new POSTempTransItem();
                tempItem.Barcode         = item.Barcode;
                tempItem.CreatedDateTime = DateTime.UtcNow;
                tempItem.ItemPrice       = item.ItemPrice;
                tempItem.ItemID          = item.ItemId;
                tempItem.Quantity        = item.ItemQuantity;
                tempItem.TempTransID     = SettingHelpers.CurrentTempTransId;
                tempItem.IsOfferItem     = item.IsOfferItem;
                string tempTransString     = JsonConvert.SerializeObject(tempItem);
                var    httpContentTempItem = new StringContent(tempTransString, Encoding.UTF8, "application/json");
                var    tempItemResponse    = httpClient.PostAsync("api/posprocess/insertpostemptransitemsdata", httpContentTempItem);
            }
            return(true);
        }
예제 #7
0
        /// <summary>
        /// This method is used for Insert PosBill related data at the time of Payment.
        /// </summary>
        private void InsertPOSBillData()
        {
            try
            {
                var accountingEntries = new List <DomainModel.Models.Accounting.DoubleEntry>();
                printParameters = new PrintParameters();
                //Get the total bill count of current date.
                string billNumber        = ""; //SettingHelpers.CompanyConfigruationObject.InvoiceNo + DateTime.UtcNow.ToString("dd/mm/yyyy") + "0001";
                var    billCountResponse = _posRepository.GetTotalBillDataByBillDate();
                if (billCountResponse < 9)
                {
                    billNumber = SettingHelpers.CompanyConfigruationObject.InvoiceNo + DateTime.UtcNow.ToString("dd/MM/yy") + "000" + (billCountResponse + 1);
                }
                else if (billCountResponse < 99)
                {
                    billNumber = SettingHelpers.CompanyConfigruationObject.InvoiceNo + DateTime.UtcNow.ToString("dd/MM/yy") + "00" + (billCountResponse + 1);
                }
                else if (billCountResponse < 999)
                {
                    billNumber = SettingHelpers.CompanyConfigruationObject.InvoiceNo + DateTime.UtcNow.ToString("dd/MM/yy") + "0" + (billCountResponse + 1);
                }
                else if (billCountResponse < 9999)
                {
                    billNumber = SettingHelpers.CompanyConfigruationObject.InvoiceNo + DateTime.UtcNow.ToString("dd/MM/yy") + (billCountResponse + 1);
                }
                else
                {
                    billNumber = SettingHelpers.CompanyConfigruationObject.InvoiceNo + DateTime.UtcNow.ToString("dd/MM/yy") + (billCountResponse + 1);
                }
                POSBill posBill = new POSBill();
                posBill.POSSessionID = SettingHelpers.CurrentPosSessionId;
                posBill.UserID       = SettingHelpers.CurrentUserId;
                posBill.BranchID     = SettingHelpers.CurrentBranchId;
                if (customerInfo == null || customerInfo.Customer.Id == 0 || customerInfo.Customer.Id == 1)
                {
                    printParameters.IsCustomer = false;
                    posBill.CustomerID         = 1;
                }
                else
                {
                    posBill.CustomerID         = customerInfo.Customer.Id;
                    printParameters.IsCustomer = true;
                }
                posBill.BillDate        = DateTime.UtcNow;
                posBill.TotalAmount     = TotalAmount;
                posBill.BillNo          = billNumber.Replace("/", "").Replace("-", "");
                posBill.CreatedDateTime = DateTime.UtcNow.Date;

                var billDetail = _posRepository.InsertPosBillData(posBill);
                if (billDetail != null)
                {
                    accountingEntries.Add(new DoubleEntry
                    {
                        Description     = "POS Sale Entry Bill No:" + posBill.BillNo,
                        LedgerId        = SettingHelpers.Ledgers.First(x => x.Name == StringConstants.Sales).Id,
                        ActivityName    = StringConstants.PosSale,
                        Debit           = 0,
                        Credit          = TotalAmount + discount,
                        CreatedDateTime = DateTime.UtcNow,
                        TransactionDate = DateTime.UtcNow
                    });
                    _posRepository.InsertPosBillItemsData(_itemProfileCollection.ToList(), billDetail.Id);
                    if (!String.IsNullOrEmpty(CashAmount))
                    {
                        accountingEntries.Add(new DoubleEntry
                        {
                            Description     = "POS Sale by cash Entry Bill No:" + posBill.BillNo,
                            LedgerId        = SettingHelpers.Ledgers.First(x => x.Name == StringConstants.CashInHand).Id,
                            ActivityName    = StringConstants.PosSale,
                            Debit           = Convert.ToDecimal(CashAmount),
                            Credit          = 0,
                            CreatedDateTime = DateTime.UtcNow,
                            TransactionDate = DateTime.UtcNow
                        });
                        InsertPosBillPaymentData(billDetail.Id, POSBillPaymentType.Cash, string.Empty, Convert.ToDecimal(CashAmount));
                    }
                    if (!String.IsNullOrEmpty(DebitCardAmount))
                    {
                        accountingEntries.Add(new DoubleEntry
                        {
                            Description     = "POS Sale by Debit Card Entry Bill No:" + posBill.BillNo,
                            LedgerId        = SettingHelpers.Ledgers.First(x => x.Name == StringConstants.Bank).Id,
                            ActivityName    = StringConstants.PosSale,
                            Debit           = Convert.ToDecimal(DebitCardAmount),
                            Credit          = 0,
                            CreatedDateTime = DateTime.UtcNow,
                            TransactionDate = DateTime.UtcNow
                        });
                        InsertPosBillPaymentData(billDetail.Id, POSBillPaymentType.DebitCard, DebitCardReceiptNo, Convert.ToDecimal(DebitCardAmount));
                    }
                    if (!String.IsNullOrEmpty(CreditCardAmount))
                    {
                        accountingEntries.Add(new DoubleEntry
                        {
                            Description     = "POS Sale by Credit Card Entry Bill No:" + posBill.BillNo,
                            LedgerId        = SettingHelpers.Ledgers.First(x => x.Name == StringConstants.Bank).Id,
                            ActivityName    = StringConstants.PosSale,
                            Debit           = Convert.ToDecimal(CreditCardAmount),
                            Credit          = 0,
                            CreatedDateTime = DateTime.UtcNow,
                            TransactionDate = DateTime.UtcNow
                        });
                        InsertPosBillPaymentData(billDetail.Id, POSBillPaymentType.CreditCard, CreditCardReceiptNumber, Convert.ToDecimal(CreditCardAmount));
                    }
                    if (!String.IsNullOrEmpty(CouponAmount))
                    {
                        accountingEntries.Add(new DoubleEntry
                        {
                            Description     = "POS Sale by Coupan Entry Bill No:" + posBill.BillNo,
                            LedgerId        = SettingHelpers.Ledgers.First(x => x.Name == StringConstants.Expenses).Id,
                            ActivityName    = StringConstants.PosSale,
                            Debit           = Convert.ToDecimal(CouponAmount),
                            Credit          = 0,
                            CreatedDateTime = DateTime.UtcNow,
                            TransactionDate = DateTime.UtcNow
                        });
                        InsertPosBillPaymentData(billDetail.Id, POSBillPaymentType.Coupon, CouponNo, Convert.ToDecimal(CouponAmount));
                    }
                    if (!String.IsNullOrEmpty(chequeAmount))
                    {
                        accountingEntries.Add(new DoubleEntry
                        {
                            Description     = "POS Sale by Cheque Entry Bill No:" + posBill.BillNo,
                            LedgerId        = SettingHelpers.Ledgers.First(x => x.Name == StringConstants.Bank).Id,
                            ActivityName    = StringConstants.PosSale,
                            Debit           = Convert.ToDecimal(chequeAmount),
                            Credit          = 0,
                            CreatedDateTime = DateTime.UtcNow,
                            TransactionDate = DateTime.UtcNow
                        });
                        InsertPosBillPaymentData(billDetail.Id, POSBillPaymentType.Cheque, ChequeNo, Convert.ToDecimal(chequeAmount));
                    }
                    if (!String.IsNullOrEmpty(CreditAccountAmount))
                    {
                        //TODO: Customer Ledger
                        InsertPosBillPaymentData(billDetail.Id, POSBillPaymentType.CreditAccount, string.Empty, Convert.ToDecimal(CreditAccountAmount));
                    }
                    if (!String.IsNullOrEmpty(DownPaymentAmount))
                    {
                        InsertPosBillPaymentData(billDetail.Id, POSBillPaymentType.DownPayment, string.Empty, Convert.ToDecimal(DownPaymentAmount));
                    }

                    //If Bill process for Customer PO then update Customer PO is collected in CustomerPruchaseOrder table.
                    if (SettingHelpers.IsCustomerPO)
                    {
                        //update CPO bill
                        var cpoObj = new CustomerPurchaseOrder
                        {
                            PurchaseOrderNo = customerInfo.CPO.PurchaseOrderNo,
                            IsCollected     = true
                        };
                        var httpClient         = new HttpClients();
                        var jsonCPO            = JsonConvert.SerializeObject(cpoObj);
                        var httpContentCpo     = new StringContent(jsonCPO, Encoding.UTF8, "application/json");
                        var responseCustomerPO = httpClient.PostAsync("api/customerpo/updatecustomerpurchseorderforpos", httpContentCpo);
                        if (responseCustomerPO.IsSuccessStatusCode)
                        {
                            var resultCpo = responseCustomerPO.Content.ReadAsAsync <int>().Result;
                            //add CPO Bill mapping
                            var cpoBill = new CPOBill();
                            cpoBill.CPOId     = resultCpo;
                            cpoBill.POSBillId = billDetail.Id;

                            jsonCPO        = JsonConvert.SerializeObject(cpoBill);
                            httpContentCpo = new StringContent(jsonCPO, Encoding.UTF8, "application/json");

                            var responseCpoBill = httpClient.PostAsync("api/customerpo/addcpobillforpos", httpContentCpo);
                            if (responseCpoBill.IsSuccessStatusCode)
                            {
                                resultCpo = responseCpoBill.Content.ReadAsAsync <int>().Result;
                            }
                        }
                        printParameters.IsCpo          = true;
                        printParameters.DownPayment    = DownPaymentAmount;
                        printParameters.AdditionalCost = AdditionalCost;
                        printParameters.CpoNumber      = cpoObj.PurchaseOrderNo;
                    }
                    // if bill process for Return Bill then updat the ReturnBill table for process successfully.
                    if (customerInfo.ReturnBill != null)
                    {
                        UpdateReuturnBill();
                        printParameters.IsReturnBill = true;
                        printParameters.ReturnBillNo = customerInfo.ReturnBill.ReturnedBillNo;
                        printParameters.Substitute   = customerInfo.ReturnBill.SubstituteItemsAmount;
                        printParameters.ReturnAmount = customerInfo.ReturnBill.ReturnedCash;

                        if (RemainingAmount != 0)
                        {
                            accountingEntries.Add(new DoubleEntry
                            {
                                Description     = "POS Sale cash return Bill No:" + customerInfo.ReturnBill.ReturnedBillNo,
                                LedgerId        = SettingHelpers.Ledgers.First(x => x.Name == StringConstants.CashInHand).Id,
                                ActivityName    = StringConstants.PosSale,
                                Debit           = 0,
                                Credit          = RemainingAmount,
                                CreatedDateTime = DateTime.UtcNow,
                                TransactionDate = DateTime.UtcNow
                            });
                        }
                    }
                }
                if (discount > 0)
                {
                    accountingEntries.Add(new DoubleEntry
                    {
                        Description     = "POS Sale Discount Bill No:" + printParameters.InvoiceNo,
                        LedgerId        = SettingHelpers.Ledgers.First(x => x.Name == StringConstants.Expenses).Id,
                        ActivityName    = StringConstants.PosSale,
                        Debit           = discount,
                        Credit          = 0,
                        CreatedDateTime = DateTime.UtcNow,
                        TransactionDate = DateTime.UtcNow
                    });
                }

                #region "Set Print Parameters"
                printParameters.Tax           = 0;
                printParameters.Cash          = PaidAmount.Value;
                printParameters.CashReturn    = RemainingAmount;
                printParameters.Customer      = customerInfo.Customer;
                printParameters.Items         = _itemProfileCollection.ToList();
                printParameters.TotalQuantity = _itemProfileCollection.Sum(x => x.ItemQuantity);
                printParameters.TotalAmount   = posBill.TotalAmount + printParameters.Substitute;
                printParameters.Discount      = discount;
                printParameters.InvoiceNo     = posBill.BillNo;
                printParameters.SDateTime     = DateTime.UtcNow.ToString("dd-MM-yy hh:mm:ss");
                #endregion

                _posRepository.AddAccountingEntries(accountingEntries);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public int AddUnregisteredItem(ItemProfile item)
        {
            var jsonString  = JsonConvert.SerializeObject(item);
            var httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json");
            var response    = httpClient.PostAsync("api/item/insertitemprofileforpos", httpContent);

            if (response.IsSuccessStatusCode)
            {
                return(response.Content.ReadAsAsync <int>().Result);
            }
            return(0);
        }