Пример #1
0
        public ActionResult PaymentDelete(int id)
        {
            ActionResult actionResult;

            try
            {
                LedgerPosting postingObj = this.postingService.GetById(new int?(id));
                foreach (LedgerPosting item in this.postingService.GetAll(postingObj.VoucherNo, true))
                {
                    item.IsActive = false;
                    this.postingService.Update(item, item.Id);
                }
                PartyBalanceService partyBalanceService = this.partyBalanceService;
                int?         ledgerId   = postingObj.LedgerId;
                PartyBalance paymentObj = partyBalanceService.GetByVoucher((ledgerId.HasValue ? ledgerId.GetValueOrDefault() : 0), postingObj.VoucherNo);
                this.partyBalanceService.Delete(paymentObj.PartyBalanceId);
                AccountLedger   customer        = this.accledgerService.GetById(postingObj.LedgerId);
                CustomerService customerService = new CustomerService();
                ledgerId = postingObj.LedgerId;
                rptIndividualLedger_Result due = customerService.GetBalance((ledgerId.HasValue ? ledgerId.GetValueOrDefault() : 0));
                string  balanceText            = "";
                decimal?balance = due.Balance;
                decimal num     = new decimal();
                if ((balance.GetValueOrDefault() < num ? !balance.HasValue : true))
                {
                    balance     = due.Balance;
                    balanceText = string.Concat("Balance with Dada Rice Tk=", string.Format("{0:#,#.}", decimal.Round((balance.HasValue ? balance.GetValueOrDefault() : decimal.Zero)), ""), "=");
                }
                else
                {
                    decimal minusOne = decimal.MinusOne;
                    balance     = due.Balance;
                    balanceText = string.Concat("Balance with Dada Rice Tk=", string.Format("{0:#,#.}", minusOne * decimal.Round((balance.HasValue ? balance.GetValueOrDefault() : decimal.Zero)), ""), "=");
                }
                var isSendSMS = false;
                if (isSendSMS)
                {
                    SMSEmailService sMSEmailService = new SMSEmailService();
                    string[]        ledgerName      = new string[] { "Dear ", customer.LedgerName, ",Tk=", null, null, null, null, null, null };
                    balance       = postingObj.Credit;
                    ledgerName[3] = string.Format("{0:#,#.}", decimal.Round((balance.HasValue ? balance.GetValueOrDefault() : decimal.Zero)), "");
                    ledgerName[4] = " payment was wrong posted. Your Ref No:";
                    ledgerName[5] = postingObj.VoucherNo;
                    ledgerName[6] = " has been deleted,";
                    ledgerName[7] = balanceText;
                    ledgerName[8] = " Dada Rice.";
                    sMSEmailService.SendOneToOneSingleSms("01739110321", string.Concat(ledgerName));
                }
                actionResult = base.Json("Sucess", 0);
            }
            catch (Exception exception)
            {
                actionResult = base.Json(exception.Message, 0);
            }
            return(actionResult);
        }
Пример #2
0
        public ActionResult ReceivePayment(string voucherNo, int supplierId, DateTime voucherDate, string notes, List <LedgerPosting> ledgerPosting, bool isSendSMS)
        {
            decimal?credit;
            var     supplierInfo = supplierService.GetById(supplierId);

            if (supplierInfo == null)
            {
                return(Json("error", JsonRequestBehavior.AllowGet));
            }
            //credit
            foreach (var item in ledgerPosting)
            {
                item.Credit        = 0;
                item.VoucherNo     = voucherNo;
                item.PostingDate   = voucherDate;
                item.ChequeDate    = DateTime.Now;
                item.ChequeNo      = "";
                item.VoucherTypeId = (int)BAL.VoucherType.PaymentVoucher;
                item.Extra1        = "Voucher:" + voucherNo + " " + notes;
                postingService.Save(item);
            }
            //debit
            LedgerPosting posting = new LedgerPosting();

            posting.ChequeDate    = DateTime.Now;
            posting.VoucherNo     = voucherNo;
            posting.ChequeNo      = "";
            posting.VoucherTypeId = (int)BAL.VoucherType.PaymentVoucher;
            posting.LedgerId      = supplierInfo.LedgerId;
            posting.PostingDate   = voucherDate;
            posting.Credit        = ledgerPosting.Sum(a => a.Debit).Value;
            posting.Debit         = 0;
            posting.Extra1        = "Voucher:" + voucherNo + " " + notes;
            postingService.Save(posting);
            //balance
            //party balance
            PartyBalance balance = new PartyBalance();

            balance.AgainstVoucherTypeId = 4;
            balance.VoucherNo            = voucherNo;
            balance.PostingDate          = voucherDate;
            balance.LedgerId             = supplierInfo.LedgerId ?? 0;
            balance.Debit         = posting.Credit;
            balance.Credit        = 0;
            balance.VoucherTypeId = (int)BAL.VoucherType.PaymentVoucher;
            balance.extra1        = "Payment Invoice: " + voucherNo + " Notes:" + notes;
            balance.extra2        = posting.Id.ToString();

            partyBalanceService.Save(balance);

            if (isSendSMS)
            {
                SMSEmailService            sMSEmailService = new SMSEmailService();
                string                     phone           = supplierInfo.Phone;
                rptIndividualLedger_Result due             = customerService.GetBalance((supplierInfo.LedgerId ?? 0));

                string balanceText = "";
                credit = due.Balance;
                var num = new decimal();
                if ((credit.GetValueOrDefault() < num ? !credit.HasValue : true))
                {
                    credit      = due.Balance;
                    balanceText = string.Concat("Your Present Balance With Dada Rice Tk=", string.Format("{0:#,#.}", decimal.Round((credit.HasValue ? credit.GetValueOrDefault() : decimal.Zero)), ""), "/=.");
                }
                else
                {
                    decimal minusOne = decimal.MinusOne;
                    credit      = due.Balance;
                    balanceText = string.Concat("Your Present Balance With Dada Rice Tk=", string.Format("{0:#,#.}", minusOne * decimal.Round((credit.HasValue ? credit.GetValueOrDefault() : decimal.Zero)), ""), "/= Thanks.");
                }
                balanceText = "";
                string[] name = new string[] { "Dear ", supplierInfo.Name, " Tk=", null, null, null };
                credit  = balance.Credit;
                name[3] = string.Format("{0:#,#.}", decimal.Round((posting.Credit.HasValue ? posting.Credit.GetValueOrDefault() : decimal.Zero)), "");
                name[4] = "/- has been Deposited to your Account. Ref:No-" + voucherNo + ", Dated:" + voucherDate.ToString("dd-MM-yyyy") + ". Thanks with Dada Rice";
                sMSEmailService.SendOneToOneSingleSms("01979110321", string.Concat(string.Concat(name), balanceText), false);
            }
            return(Json("", JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        public ActionResult ReceivePayment(string voucherNo, int supplierId, DateTime voucherDate, string notes, List <LedgerPosting> ledgerPosting, bool isSendSMS)
        {
            ActionResult actionResult;
            decimal      num;
            decimal?     credit;
            int?         ledgerId;
            DateTime     now;
            Customer     supplierInfo = this.supplierService.GetById(new int?(supplierId));

            if (supplierInfo != null)
            {
                foreach (LedgerPosting item in ledgerPosting)
                {
                    num                = new decimal();
                    item.Debit         = new decimal?(num);
                    item.PostingDate   = new DateTime?(voucherDate);
                    item.VoucherNo     = voucherNo;
                    item.VoucherTypeId = new int?(5);
                    item.Extra1        = string.Concat("Voucher:", voucherNo, " ", notes);
                    this.postingService.Save(item);
                    credit      = item.Credit;
                    this.Amount = (credit.HasValue ? credit.GetValueOrDefault() : decimal.Zero);
                    this.ChkNo  = item.ChequeNo;
                    ledgerId    = item.LedgerId;
                    if ((ledgerId.GetValueOrDefault() == 1 ? !ledgerId.HasValue : true))
                    {
                        string[] str = new string[] { "Ref:No- TT-DR", voucherNo, ",Dated:", null, null };
                        now        = DateTime.Now;
                        str[3]     = now.ToString("dd-MM-yyyy");
                        str[4]     = ".";
                        this.ChkNo = string.Concat(str);
                    }
                    else
                    {
                        string[] strArrays = new string[] { "Ref:No- Cash-DR", voucherNo, ",Dated:", null, null };
                        now          = DateTime.Now;
                        strArrays[3] = now.ToString("dd-MM-yyyy");
                        strArrays[4] = ".";
                        this.ChkNo   = string.Concat(strArrays);
                    }
                }
                string        smsmsg  = this.ChkNo;
                LedgerPosting posting = new LedgerPosting()
                {
                    ChequeDate    = new DateTime?(DateTime.Now),
                    VoucherNo     = voucherNo,
                    ChequeNo      = "",
                    VoucherTypeId = new int?(5),
                    LedgerId      = supplierInfo.LedgerId,
                    PostingDate   = new DateTime?(voucherDate)
                };
                LedgerPosting nullable = posting;
                credit         = ledgerPosting.Sum <LedgerPosting>((LedgerPosting a) => a.Credit);
                nullable.Debit = new decimal?(credit.Value);
                num            = new decimal();
                posting.Credit = new decimal?(num);
                posting.Extra1 = string.Concat("Voucher:", voucherNo, " ", notes);
                this.postingService.Save(posting);
                PartyBalance balance = new PartyBalance()
                {
                    AgainstVoucherTypeId = new int?(5),
                    VoucherNo            = voucherNo,
                    PostingDate          = new DateTime?(voucherDate)
                };
                PartyBalance partyBalance = balance;
                ledgerId = supplierInfo.LedgerId;
                partyBalance.LedgerId = (ledgerId.HasValue ? ledgerId.GetValueOrDefault() : 0);
                num                   = new decimal();
                balance.Debit         = new decimal?(num);
                balance.Credit        = posting.Debit;
                balance.VoucherTypeId = 5;
                balance.extra1        = string.Concat("Recipt Invoice: ", voucherNo, " Notes:", notes);
                balance.extra2        = posting.Id.ToString();
                this.partyBalanceService.Save(balance);
                if (isSendSMS)
                {
                    Customer        customer        = (new CustomerService()).GetById(new int?(supplierId));
                    CustomerService customerService = new CustomerService();
                    ledgerId = customer.LedgerId;
                    rptIndividualLedger_Result due = customerService.GetBalance((ledgerId.HasValue ? ledgerId.GetValueOrDefault() : 0));
                    string balanceText             = "";
                    credit = due.Balance;
                    num    = new decimal();
                    if ((credit.GetValueOrDefault() < num ? !credit.HasValue : true))
                    {
                        credit      = due.Balance;
                        balanceText = string.Concat("Your Present Balance With Dada Rice Tk=", string.Format("{0:#,#.}", decimal.Round((credit.HasValue ? credit.GetValueOrDefault() : decimal.Zero)), ""), "/=.");
                    }
                    else
                    {
                        decimal minusOne = decimal.MinusOne;
                        credit      = due.Balance;
                        balanceText = string.Concat("Your Present Balance With Dada Rice Tk=", string.Format("{0:#,#.}", minusOne * decimal.Round((credit.HasValue ? credit.GetValueOrDefault() : decimal.Zero)), ""), "/=.");
                    }
                    SMSEmailService sMSEmailService = new SMSEmailService();
                    string          phone           = supplierInfo.Phone;
                    string[]        name            = new string[] { "Dear ", customer.Name, " Tk=", null, null, null };
                    credit  = balance.Credit;
                    name[3] = string.Format("{0:#,#.}", decimal.Round((credit.HasValue ? credit.GetValueOrDefault() : decimal.Zero)), "");
                    name[4] = "/-Received With Thanks As ";
                    name[5] = smsmsg;
                    sMSEmailService.SendOneToOneSingleSms(phone, string.Concat(string.Concat(name), balanceText));
                }
                actionResult = Json("", 0);
            }
            else
            {
                actionResult = Json("error", 0);
            }
            return(actionResult);
        }
Пример #4
0
        public ActionResult Authorize(int id, bool isSendSMS)
        {
            var          item = salesService.GetByTempId(id);
            decimal?     deliveryQty;
            decimal      baleQty;
            ActionResult actionResult;
            decimal?     nullable;
            string       message = "";
            SalesMaster  result  = new SalesMaster();

            result.SalesInvoice = item.SalesInvoice;
            SalesMaster FinalResult = new SalesMaster();

            FinalResult.SalesInvoice = item.SalesInvoice;
            SalesDetail FinalResultDetail = new SalesDetail();
            SalesOrder  resultOrder       = new SalesOrder();
            SalesOrder  FinalResultOrder  = new SalesOrder();
            List <int>  lstSalesMasterId  = new List <int>();

            try
            {
                result.SalesInvoice = item.SalesInvoice;
                result.SalesOrderId = item.SalesOrderId;
                result.SalesDate    = item.SalesDate;
                if (!result.SalesDate.HasValue)
                {
                    result.SalesDate = new DateTime?(DateTime.Now);
                }
                result.SalesBy        = CurrentSession.GetCurrentSession().UserName;
                result.CustomerID     = item.CustomerID;
                result.AdditionalCost = decimal.Zero;
                result.Discount       = item.Discount;
                result.Notes          = item.Notes;
                result.Coutha         = item.Coutha;
                result.TransportNo    = item.TransportNo;
                result.TransportType  = item.TransportType;
                result.CreatedBy      = CurrentSession.GetCurrentSession().UserName;
                result.CreatedDate    = new DateTime?(DateTime.Now);
                result.TotalAmount    = item.TotalAmount;
                result.GrandTotal     = item.GrandTotal;
                result.IsActive       = true;
                int count = 0;
                foreach (TempSalesDetail itemDetails in item.TempSalesDetails)
                {
                    SalesDetail resultDetail = new SalesDetail()
                    {
                        SalesMasterId = result.Id,
                        SalesInvoice  = result.SalesInvoice,
                        ProductId     = itemDetails.ProductId,
                        Qty           = itemDetails.BaleQty,
                        SD            = itemDetails.BaleWeight,
                        Tax           = itemDetails.TotalQtyInKG,
                        Rate          = itemDetails.Rate,
                        Amount        = itemDetails.Amount,
                        Notes         = FinalResult.Notes,
                        CreatedBy     = CurrentSession.GetCurrentSession().UserName,
                        CreatedDate   = new DateTime?(DateTime.Now),
                        IsActive      = new bool?(true),
                        WarehouseId   = itemDetails.WarehouseId
                    };
                    count += itemDetails.BaleQty;
                    result.SalesDetails.Add(resultDetail);
                }
                message = string.Concat(message, "Tk=", string.Format("{0:#,#.}", decimal.Round(result.GrandTotal), ""), "=");
                if (item.SalesOrder != null)
                {
                    string     orderid = "";
                    SalesOrder order   = this.salesService.GetSalesOrderById(new int?(Convert.ToInt32(item.SalesOrderId)));
                    orderid = string.Concat(",", order.SalesOrderId);
                    message = string.Concat(message, orderid);
                }
                message = string.Concat(message, ",SO-", result.SalesInvoice);
                message = string.Concat(message, ",T/No:", item.TransportType + ",Mob:" + result.TransportNo);

                result.DriverName = item.DriverName;
                result.RentAmount = item.RentAmount;
                SalesMaster saved = this.salesService.SaveSalesMaster(result);
                if (item.SalesOrder != null)
                {
                    item.SalesOrder.DeliveryDate = new DateTime?(DateTime.Now);
                    SalesOrder order      = this.salesService.GetSalesOrderById(new int?(Convert.ToInt32(item.SalesOrderId)));
                    SalesOrder salesOrder = order;
                    deliveryQty = order.DeliveryQty;
                    baleQty     = order.BaleQty;
                    if (deliveryQty.HasValue)
                    {
                        nullable = new decimal?(deliveryQty.GetValueOrDefault() + baleQty);
                    }
                    else
                    {
                        nullable = null;
                    }
                    salesOrder.DeliveryQty = nullable;
                    order.BaleQty          = order.BaleQty - order.BaleQty;
                    order.DeliveryDate     = new DateTime?(DateTime.Now);
                    order.IsActive         = false;
                    FinalResultOrder       = this.salesService.Update(order, order.Id);
                }
                if (saved.Id > 0)
                {
                    if (item.CustomerID != 0)
                    {
                        Customer customer = (new CustomerService()).GetById(new int?(item.CustomerID));
                        int?     ledgerId = customer.LedgerId;
                        rptIndividualLedger_Result due = customerService.GetBalance((ledgerId.HasValue ? ledgerId.GetValueOrDefault() : 0));
                        string balanceText             = "";
                        deliveryQty = due.Balance;
                        baleQty     = new decimal();
                        if ((deliveryQty.GetValueOrDefault() < baleQty ? !deliveryQty.HasValue : true))
                        {
                            deliveryQty = due.Balance;
                            balanceText = string.Concat("Balance with Dada Rice Tk=", string.Format("{0:#,#.}", decimal.Round((deliveryQty.HasValue ? deliveryQty.GetValueOrDefault() : decimal.Zero)), ""), "=");
                        }
                        else
                        {
                            decimal minusOne = decimal.MinusOne;
                            deliveryQty = due.Balance;
                            balanceText = string.Concat("Balance with Dada Rice Tk=", string.Format("{0:#,#.}", minusOne * decimal.Round((deliveryQty.HasValue ? deliveryQty.GetValueOrDefault() : decimal.Zero)), ""), "=");
                        }
                        SMSEmailService sMSEmailService = new SMSEmailService();
                        string          phone           = customer.Phone;
                        string[]        str             = new string[] { "Dear Customer,Del Qty=", count.ToString(), " BAGS ", message, ",Dated:", null, null, null };
                        str[5] = DateTime.Now.ToString("dd-MM-yyyy");
                        str[6] = ".";
                        str[7] = balanceText;
                        if (isSendSMS)
                        {
                            sMSEmailService.SendOneToOneSingleSms(phone, string.Concat(str));
                        }
                    }
                    //update temp
                    item.IsActive    = false;
                    item.UpdatedDate = DateTime.Now.ToString();
                    this.salesService.Update(item, id);
                }
                var r = AutoMapper.Mapper.Map <SalesMaster, SalesMasterResponse>(saved);
                actionResult = base.Json(r, 0);
            }
            catch (Exception exception)
            {
                exception.ErrorWritter();
                actionResult = base.Json("Error", 0);
            }
            return(actionResult);
        }