public void NewBillUrl_IncOptionalParams_GeneratesCorrectUrl()
        {
            var request = new BillRequest("0190G74E3J", 15m)
            {
                Name        = "Premium Account",
                Description = "Test payment",
                User        = new UserRequest
                {
                    Name            = "John Smith",
                    FirstName       = "John",
                    LastName        = "Smith",
                    Email           = "*****@*****.**",
                    BillingAddress1 = "Flat 1",
                    BillingAddress2 = "100 Main Street",
                    BillingTown     = "Townville",
                    BillingCounty   = "Countyshire",
                    BillingPostcode = "N1 1AB",
                }
            };

            GoCardless.Environment              = GoCardless.Environments.Sandbox;
            GoCardless.AccountDetails.AppId     = "test_id";
            GoCardless.AccountDetails.AppSecret = "test_secret";
            GoCardless.GenerateNonce            = () => "Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT+HO3ReWMxavlco0Fw8rva+ZcI";
            GoCardless.GetUtcNow = () => new DateTimeOffset(new DateTime(2012, 03, 21, 08, 55, 56));

            var url      = GoCardless.Connect.NewBillUrl(request);
            var expected =
                "https://sandbox.gocardless.com/connect/bills/new?bill%5Bamount%5D=15.00&bill%5Bdescription%5D=Test%20payment&bill%5Bmerchant_id%5D=0190G74E3J&bill%5Bname%5D=Premium%20Account&bill%5Buser%5D%5Bbilling_address1%5D=Flat%201&bill%5Buser%5D%5Bbilling_address2%5D=100%20Main%20Street&bill%5Buser%5D%5Bbilling_county%5D=Countyshire&bill%5Buser%5D%5Bbilling_postcode%5D=N1%201AB&bill%5Buser%5D%5Bbilling_town%5D=Townville&bill%5Buser%5D%5Bemail%5D=john.smith%40example.com&bill%5Buser%5D%5Bfirst_name%5D=John&bill%5Buser%5D%5Blast_name%5D=Smith&bill%5Buser%5D%5Bname%5D=John%20Smith&client_id=test_id&nonce=Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT%2BHO3ReWMxavlco0Fw8rva%2BZcI&signature=7534d0255bb20d8ca38255c9861431f65ffb1625be9c6d0f338624f3b2c7b9b5&timestamp=2012-03-21T08%3A55%3A56Z";

            Assert.AreEqual(expected, url);
        }
Esempio n. 2
0
        public async Task <IList <BillLineItem> > Generate(BillRequest request)
        {
            var result = new List <BillLineItem>();

            if ((request.Type == BillType.Stage1 && request.RequestType == BillRequestType.New) ||
                (request.Type == BillType.Stage2 && request.RequestType == BillRequestType.Renewal))
            {
                var code = await(request.Expedite
          ? _context.GetTransactionCode(TransactionCodes.ApplicationFeeExpress, request.ReferenceDate)
          : _context.GetTransactionCode(TransactionCodes.ApplicationFeeNormal, request.ReferenceDate));

                var gst = await _context.GST();

                var amount    = BillingUtils.CalculateAmount(code, 1M);
                var gstAmount = amount * gst;
                var section   = BillingUtils.LineItemSection(request.Type);

                result.Add(new BillLineItem
                {
                    SectionIndex = section.Item1,
                    Section      = section.Item2,
                    Qty          = 1M,
                    CodeID       = code.ID,
                    Code         = code.Code,
                    Descr        = code.Text,
                    UnitPrice    = code.GetLatestPriceAmount(),
                    Amount       = decimal.Round(amount, 2),
                    GSTAmount    = decimal.Round(gstAmount, 2),
                    GST          = gst,
                    WillRecord   = true
                });
            }

            return(result);
        }
Esempio n. 3
0
        public async Task <IActionResult> GenerateInvoice([FromBody] BillRequest request)
        {
            try
            {
                var validator = new BillRequestValidator();
                var result    = await validator.ValidateAsync(request);

                if (result.IsValid)
                {
                    var bills          = _mapper.Map <Bill>(request);
                    var computeInvoice = await _invoicingService.ComputeInvoiceAMount(bills);

                    var invoice = _mapper.Map <InvoiceResponse>(computeInvoice);
                    invoice.UserName        = request.UserName;
                    invoice.UserPhoneNumber = request.UserPhoneNumber;

                    return(Ok(invoice));
                }

                throw new ValidationException(result.Errors.ToList());
            }
            catch (Exception e)
            {
                _logger.LogInformation($"Error Occur while Generating Invoice --> message {e.Message}");
                throw;
            }
        }
Esempio n. 4
0
 /*
  * id is a value of motel room and u must get id for it
  */
 // POST: create a bill payment
 public async Task <int> Create(BillRequest create, int id)
 {
     if (!IDmotel.Contains(create.IdMotel))
     {
         return(0);
     }
     if (!IDBill.Contains(create.Id))
     {
         var bill = new InforBill()
         {
             ElectricBill = create.ElectricBill,
             IdInforBill  = create.Id,
             MonthRent    = create.MonthRent,
             ParkingFee   = create.ParkingFee,
             RoomBill     = create.RoomBil,
             WaterBill    = create.WaterBill,
             WifiBill     = create.WifiBill,
             IdMotel      = id,
             Payment      = false,
             DateCreate   = DateTime.Now,
         };
         _context.InforBills.Add(bill);
         return(await _context.SaveChangesAsync());
     }
     return(0);
 }
Esempio n. 5
0
        public async Task <IList <BillLineItem> > Generate(BillRequest request)
        {
            var result = new List <BillLineItem>();

            if (request.Type == BillType.Stage1)
            {
                return(result);
            }

            var bill = (await _dbContext.Bill.Query(new BillFilter
            {
                RequestID = request.RequestID
            })).Where(e => e.Status == BillStatus.Paid && e.Type == BillType.Stage1).FirstOrDefault();

            if (bill != null &&
                (bill.LineItems?.Any() ?? false))
            {
                result.AddRange(bill.LineItems.OrderBy(e => e.Index)
                                .Select(e =>
                {
                    e.WillRecord = false;
                    return(e);
                }).ToList());
            }

            return(result);
        }
Esempio n. 6
0
        async Task BuildLineItem(IList <BillLineItem> container, BillRequest request,
                                 BillRequestLineItem item)
        {
            // No stage 2 payments
            if (request.Type == BillType.Stage2 &&
                (item.Scheme == Scheme.Endorsement ||
                 item.SubScheme == SubScheme.Canteen ||
                 item.SubScheme == SubScheme.ShortTerm))
            {
                return;
            }

            var codes = await GetCertFeeCodes(request.ReferenceDate, item.Scheme, item.SubScheme);

            var code = codes.Count() == 1
        ? codes.First()
        : codes.FirstOrDefault(e => ConditionEvaluator.Evaluate(item.Area, e.Conditions?.ToArray()));

            if (code == null)
            {
                return;
            }

            if (request.Type == BillType.Stage1)
            {
                await Stage1CertFee(container, code, item);
            }
            else if (request.Type == BillType.Stage2)
            {
                await Stage2CertFee(request.RequestType, container, code, item);
            }
        }
Esempio n. 7
0
        // GET Update - have more and more infor so u need add s.th func, example : update money ....
        public async Task <int> Update(BillRequest update)
        {
            var bill = _context.InforBills.Find(update.Id);

            if (bill == null)
            {
                return(0);
            }
            else
            {
                if (!IDmotel.Contains(update.IdMotel))
                {
                    return(0);
                }
                else
                {
                    bill.ElectricBill = update.ElectricBill;
                    bill.IdMotel      = update.IdMotel;
                    bill.MonthRent    = update.MonthRent;
                    bill.ParkingFee   = update.ParkingFee;
                    bill.RoomBill     = update.ParkingFee;
                    bill.WaterBill    = update.WaterBill;
                    bill.WifiBill     = update.WifiBill;
                    _context.InforBills.Update(bill);
                    return(await _context.SaveChangesAsync());
                }
            }
        }
Esempio n. 8
0
        public async Task <IList <BillLineItem> > Generate(BillRequest request)
        {
            var result = new List <BillLineItem>();

            if (request.Type == BillType.Stage1)
            {
                return(result);
            }

            var bill = (await _dbContext.Bill.Query(new BillFilter
            {
                RequestID = request.RequestID
            })).Where(e => e.Status == BillStatus.Paid && e.Type == BillType.Stage1).FirstOrDefault();

            var payment = bill?.Payments.FirstOrDefault(e => e.Status == PaymentStatus.Processed);

            if (payment != null)
            {
                // Use bill amount instead of payment amount. For the reason, the amount from payment
                // can be total of all bills paid.
                result.Add(new BillLineItem
                {
                    SectionIndex = 4,
                    Section      = "Deductions",
                    Descr        = $"Stage 1 Payment - paid on {payment.PaidOn.Value.AddHours(8):dd MMM yyyy}",
                    Amount       = -bill.Amount,
                    GSTAmount    = -bill.GSTAmount,
                    GST          = payment.GST,
                    WillRecord   = false
                });
            }

            return(result);
        }
Esempio n. 9
0
        // PUT api/<controller>/5
        /// <summary>
        /// Modifica un Bill
        /// </summary>
        /// <param name="Bill">Bill a modificar</param>
        /// <returns></returns>
        public IHttpActionResult Put(int id, BillRequest Bill)
        {
            var originalBill = BillService.GetById(id);

            var ret = BillService.UpdateBill(originalBill, Bill);

            return(Ok());
        }
Esempio n. 10
0
        public IHttpActionResult Post(BillRequest Bill)
        {
            var result = BillService.CreateBill(Bill);

            return(Created <Entidad>("", new Entidad {
                Id = result.Id
            }));
        }
Esempio n. 11
0
        public Bill CreateBill(BillRequest Bill)
        {
            var entityToInsert = new Bill()
            {
            };

            MergeBill(entityToInsert, Bill);
            BillRepository.Insert(entityToInsert);
            return(entityToInsert);
        }
Esempio n. 12
0
        public async Task <IActionResult> Create([FromBody] BillRequest create, int id)
        {
            var result = await _manage.Create(create, id);

            if (result == 0)
            {
                return(BadRequest());
            }
            return(Ok("create ok"));
        }
Esempio n. 13
0
        public async Task <IActionResult> Update(BillRequest infor)
        {
            var result = await _manage.Update(infor);

            if (result == 0)
            {
                return(NotFound());
            }
            return(Ok("updated"));
        }
        public Bill HandleRequest(string jsonRequest)
        {
            BillRequest     billRequest = JsonConvert.DeserializeObject <BillRequest>(jsonRequest);
            List <BillLine> billLines   = new List <BillLine>();

            foreach (ItemLine line in billRequest.ItemLines)
            {
                billLines.Add(new BillLine(line.Item, line.Quantity));
            }
            return(new Bill(billRequest.User, billLines));
        }
Esempio n. 15
0
 private void MergeBill(Bill originalBill, BillRequest Bill)
 {
     originalBill.Amount             = Bill.Amount;
     originalBill.CreationDate       = Bill.CreationDate;
     originalBill.ExpirationDate     = Bill.ExpirationDate;
     originalBill.NextExpirationDate = Bill.NextExpirationDate;
     originalBill.Number             = Bill.Number;
     originalBill.ClientNumber       = Bill.ClientNumber;
     originalBill.Worker             = Bill.WorkerId.HasValue ? this.WorkerRepository.GetById(Bill.WorkerId.Value) : null;
     originalBill.Provider           = Bill.ProviderId.HasValue ? this.ProviderRepository.GetById(Bill.ProviderId.Value) : null;
     originalBill.Manager            = Bill.ManagerId.HasValue ? this.ManagerRepository.GetById(Bill.ManagerId.Value) : null;
 }
Esempio n. 16
0
        private void PostSpend(IList <Spend> spends, int consortiumId)
        {
            foreach (var spend in spends)
            {
                var nbill = new BillRequest()
                {
                    Amount             = spend.Bill.Amount,
                    CreationDate       = spend.PaymentDate,
                    Number             = "00000",
                    ExpirationDate     = spend.PaymentDate,
                    NextExpirationDate = spend.PaymentDate,
                    ManagerId          = spend.Bill.Manager != null ? spend.Bill.Manager.Id : 0
                };

                var nspend = new SpendRequest()
                {
                    Description  = spend.Description,
                    PaymentDate  = spend.PaymentDate,
                    SpendTypeId  = spend.Type.Id,
                    SpendClassId = spend.SpendClass.Id,
                    ConsortiumId = consortiumId
                };


                try
                {
                    var     result = false;
                    Entidad entity = new Entidad()
                    {
                        Id = nbill.Id
                    };
                    if (nbill.Id == 0)
                    {
                        entity = this.BillService.CreateBill(nbill);
                        result = entity.Id != 0;
                    }


                    if (result)
                    {
                        nspend.BillId = entity.Id;
                        result        = this.SpendService.CreateSpend(nspend);
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Esempio n. 17
0
        public async Task <IList <BillLineItem> > Generate(BillRequest request)
        {
            var result = new List <BillLineItem>();

            if (request.LineItems?.Any() ?? false)
            {
                foreach (var item in request.LineItems)
                {
                    if (item.NoOfProducts > 0 &&
                        (item.Scheme == Scheme.Endorsement ||
                         item.SubScheme == SubScheme.Product ||
                         item.SubScheme == SubScheme.WholePlant))
                    {
                        var duration = BillingUtils.CalculateNoOfMonths(
                            item.StartsFrom.Date,
                            item.ExpiresOn.Date);

                        var code = await GetTransactionCode(item.StartsFrom, item.Scheme, item.SubScheme);

                        var unitPrice = code.GetLatestPriceAmount();
                        var gst       = await _context.GST();

                        var qty       = Math.Round(duration / 12M, 2);
                        var fee       = item.NoOfProducts * unitPrice * qty;
                        var gstAmount = fee * gst;

                        var section = BillingUtils.LineItemSection(request.Type);

                        result.Add(new BillLineItem
                        {
                            SectionIndex = section.Item1,
                            Section      = section.Item2,
                            Qty          = qty,
                            CodeID       = code.ID,
                            Code         = code.Code,
                            Descr        = $"{code.Text} x {item.NoOfProducts} prd. ({duration} months)",
                            UnitPrice    = code.GetLatestPriceAmount(),
                            Amount       = decimal.Round(fee, 2),
                            GSTAmount    = decimal.Round(gstAmount, 2),
                            GST          = gst,
                            WillRecord   = true
                        });
                    }
                }
            }

            return(result);
        }
        public void NewBillUrl_GreaterThan1000_GeneratesCorrectUrl()
        {
            var request = new BillRequest("0190G74E3J", 1000m);

            GoCardless.Environment              = GoCardless.Environments.Sandbox;
            GoCardless.AccountDetails.AppId     = "test_id";
            GoCardless.AccountDetails.AppSecret = "test_secret";
            GoCardless.GenerateNonce            = () => "Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT+HO3ReWMxavlco0Fw8rva+ZcI";
            GoCardless.GetUtcNow = () => new DateTimeOffset(new DateTime(2012, 03, 21, 08, 55, 56));

            var url      = GoCardless.Connect.NewBillUrl(request);
            var expected =
                "https://sandbox.gocardless.com/connect/bills/new?bill%5Bamount%5D=1000.00&bill%5Bmerchant_id%5D=0190G74E3J&client_id=test_id&nonce=Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT%2BHO3ReWMxavlco0Fw8rva%2BZcI&signature=d65039ed59c227bcfa96e3bc1b3d42562a11806db57086509fba17c0028b3f76&timestamp=2012-03-21T08%3A55%3A56Z";

            Assert.AreEqual(expected, url);
        }
        public void NewBillUrl_ExcOptionalParams_GeneratesCorrectUrl()
        {
            var request = new BillRequest("0190G74E3J", 15m);

            GoCardless.Environment              = GoCardless.Environments.Sandbox;
            GoCardless.AccountDetails.AppId     = "test_id";
            GoCardless.AccountDetails.AppSecret = "test_secret";
            GoCardless.GenerateNonce            = () => "Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT+HO3ReWMxavlco0Fw8rva+ZcI";
            GoCardless.GetUtcNow = () => new DateTimeOffset(new DateTime(2012, 03, 21, 08, 55, 56));

            var url      = GoCardless.Connect.NewBillUrl(request);
            var expected =
                "https://sandbox.gocardless.com/connect/bills/new?bill%5Bamount%5D=15.00&bill%5Bmerchant_id%5D=0190G74E3J&client_id=test_id&nonce=Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT%2BHO3ReWMxavlco0Fw8rva%2BZcI&signature=bab27ff9111e292286d207e68722a00a3d8a36d1cf69fb4d094b4443998283b1&timestamp=2012-03-21T08%3A55%3A56Z";

            Assert.AreEqual(expected, url);
        }
Esempio n. 20
0
        public BaseResponse UpdateBill(BillRequest request)
        {
            BaseResponse billResponse = new BaseResponse();

            try
            {
                var orderID = repository.UpdateBill(request.bill);
                billResponse.Success = true;
            }
            catch (Exception ex)
            {
                billResponse.Success    = false;
                billResponse.Message    = ex.Message;
                billResponse.StackTrace = ex.StackTrace;
            }

            return(billResponse);
        }
Esempio n. 21
0
        public static void Main(string[] args)
        {
            IHandlerResolver resolver = new HandlerResolver(typeof(CustomerRequestHandler).Assembly.GetTypes());

            var customerRequest = new CustomerRequest {
                Name = "Joe", Surname = "Bloggs"
            };
            var customerResponse = resolver.GetRequestHandler <CustomerRequest, CustomerResponse>().Handle(customerRequest);

            var billRequest = new BillRequest {
                Amount = 100m
            };
            var billResponse = resolver.GetRequestHandler <BillRequest, BillResponse>().Handle(billRequest);

            Console.WriteLine(billResponse.Success);
            Console.WriteLine(customerResponse.Success);
            Console.ReadKey();
        }
        public void NewBillUrl_UkrainianCulture_GeneratesCorrectUrl()
        {
            // test Ukrainian culture, where numbers are formatted 0,00
            Thread.CurrentThread.CurrentCulture = new CultureInfo("uk-UA");

            var request = new BillRequest("0190G74E3J", 10.45m);

            GoCardless.Environment              = GoCardless.Environments.Sandbox;
            GoCardless.AccountDetails.AppId     = "test_id";
            GoCardless.AccountDetails.AppSecret = "test_secret";
            GoCardless.GenerateNonce            = () => "Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT+HO3ReWMxavlco0Fw8rva+ZcI";
            GoCardless.GetUtcNow = () => new DateTimeOffset(new DateTime(2012, 03, 21, 08, 55, 56));

            var url      = GoCardless.Connect.NewBillUrl(request);
            var expected =
                "https://sandbox.gocardless.com/connect/bills/new?bill%5Bamount%5D=10.45&bill%5Bmerchant_id%5D=0190G74E3J&client_id=test_id&nonce=Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT%2BHO3ReWMxavlco0Fw8rva%2BZcI&signature=2b67e51028b69a67f0f08c67282386ec625a9b78ebc1936c786602897c52f268&timestamp=2012-03-21T08%3A55%3A56Z";

            Assert.AreEqual(expected, url);
        }
Esempio n. 23
0
        public async Task <IList <BillLineItem> > Generate(BillRequest request)
        {
            var result = new List <BillLineItem>();

            if (request.RequestType != BillRequestType.New &&
                request.RequestType != BillRequestType.Renewal)
            {
                return(result);
            }

            if (request.LineItems?.Any() ?? false)
            {
                foreach (var item in request.LineItems)
                {
                    await BuildLineItem(result, request, item);
                }
            }

            return(result);
        }
Esempio n. 24
0
        public async Task<BaseReponse<ModelListResult<BillViewModel>>> GetAllPaging(BillRequest request)
        {
            var query = (await _orderRepository.FindAll()).AsNoTracking().AsParallel();
            if (!string.IsNullOrEmpty(request.StartDate))
            {
                DateTime start = DateTime.ParseExact(request.StartDate, "dd/MM/yyyy", CultureInfo.GetCultureInfo("vi-VN"));
                query = query.AsParallel().AsOrdered().WithDegreeOfParallelism(3).Where(x => x.DateCreated >= start);
            }
            if (!string.IsNullOrEmpty(request.EndDate))
            {
                DateTime end = DateTime.ParseExact(request.EndDate, "dd/MM/yyyy", CultureInfo.GetCultureInfo("vi-VN"));
                query = query.AsParallel().AsOrdered().WithDegreeOfParallelism(3).Where(x => x.DateCreated <= end);
            }
            if (!string.IsNullOrEmpty(request.SearchText))
            {
                query = query.AsParallel().AsOrdered().WithDegreeOfParallelism(3).Where(x => x.CustomerName.Contains(request.SearchText) || x.CustomerMobile.Contains(request.SearchText));
            }
            var totalRow = query.AsParallel().AsOrdered().WithDegreeOfParallelism(3).Count();

            var items = query.AsParallel().AsOrdered().WithDegreeOfParallelism(3)
                .OrderByDescending(x => x.DateCreated)
                .Skip(request.PageIndex * request.PageSize)
                .Take(request.PageSize);


            var result = new BaseReponse<ModelListResult<BillViewModel>>
            {
                Data = new ModelListResult<BillViewModel>
                {
                    Items = new BillViewModel().Map(items).ToList(),
                    Message = Message.Success,
                    RowCount = totalRow,
                    PageSize = request.PageSize,
                    PageIndex = request.PageIndex
                },
                Message = Message.Success,
                Status = (int)QueryStatus.Success
            };
            return result;
        }
Esempio n. 25
0
        // GET Find an id bill - enter true id and it's will return if not => null
        public async Task <BillRequest> Find(string id)
        {
            var result = await _context.InforBills.FindAsync(id);

            if (result == null)
            {
                return(null);
            }
            var value = new BillRequest()
            {
                ElectricBill = result.ElectricBill,
                Id           = result.IdInforBill,
                IdMotel      = result.IdMotel,
                MonthRent    = result.MonthRent,
                ParkingFee   = result.ParkingFee,
                RoomBil      = result.RoomBill,
                WaterBill    = result.WaterBill,
                WifiBill     = result.WifiBill,
            };

            return(value);
        }
Esempio n. 26
0
 public BaseResponse UpdateBill(BillRequest request)
 {
     return(service.UpdateBill(request));
 }
Esempio n. 27
0
 public BaseResponse CreateBill(BillRequest request)
 {
     return(service.InsertBill(request));
 }
Esempio n. 28
0
        public IActionResult GetAllPaging(BillRequest request)
        {
            var model = _billService.GetAllPaging(request);

            return(new OkObjectResult(model));
        }
        public JsonResult GeneratePreBill(BillRequest billRequest)
        {
            bool isEnglishBilling;
            var  preBill = _billRepo.GeneratePreBill(billRequest, out isEnglishBilling);
            //Report setup
            var details = preBill.BillDetails.Select(d => new
            {
                BillDetailType = Convert.ToInt32(d.BillDetailType),
                FixedAmount    = d.FixedAmount,
                UnitRate       = d.UnitRate,
                Quantity       = d.Quantity,
                Subtotal       = d.Subtotal,
                Description    = d.Description,
                TaxesAmount    = d.TaxesAmount
            }).ToList();

            string     basePath    = _hostingEnvironment.ContentRootPath;
            string     fullPath    = basePath + @"/Reports/Bill.rdlc";
            FileStream inputStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read);
            ReportDataSourceCollection dataSources = new ReportDataSourceCollection();

            dataSources.Add(new ReportDataSource {
                Name = "BillDataSet", Value = details
            });

            Syncfusion.ReportWriter.ReportWriter writer = new Syncfusion.ReportWriter.ReportWriter(inputStream, dataSources);
            //Setting up the parameters
            List <ReportParameter> parameters = new List <ReportParameter>();
            //IsEnglish
            ReportParameter isEnglishParam = new ReportParameter();

            isEnglishParam.Name   = "IsEnglish";
            isEnglishParam.Values = new List <string>()
            {
                isEnglishBilling ? "1" : "0"
            };
            //IsBilled
            ReportParameter isBilledParam = new ReportParameter();

            isBilledParam.Name   = "IsBilled";
            isBilledParam.Values = new List <string>()
            {
                "0"
            };
            //ClientName
            ReportParameter clientNameParam = new ReportParameter();

            clientNameParam.Name   = "ClientName";
            clientNameParam.Values = new List <string>()
            {
                preBill.BillName
            };
            //BillingPeriod

            string culture       = isEnglishBilling ? "en" : "es";
            string billingPeriod = $"{CultureInfo.GetCultureInfoByIetfLanguageTag(culture).DateTimeFormat.GetMonthName(DateTime.UtcNow.AddHours(-6).Month)} - {preBill.BillYear}";

            ReportParameter billingPeriodParam = new ReportParameter();

            billingPeriodParam.Name   = "BillingPeriod";
            billingPeriodParam.Values = new List <string>()
            {
                billingPeriod
            };
            //Subtotal
            ReportParameter subTotalExpenseParam = new ReportParameter();

            subTotalExpenseParam.Name   = "Subtotal";
            subTotalExpenseParam.Values = new List <string>()
            {
                preBill.BillSubtotal.ToString()
            };
            //Discount
            ReportParameter discountParam = new ReportParameter();

            discountParam.Name   = "Discount";
            discountParam.Values = new List <string>()
            {
                preBill.BillDiscount.ToString()
            };
            //Taxes
            ReportParameter taxesParam = new ReportParameter();

            taxesParam.Name   = "Taxes";
            taxesParam.Values = new List <string>()
            {
                preBill.Taxes.ToString()
            };
            //TotalExpense
            ReportParameter totalParam = new ReportParameter();

            totalParam.Name   = "Total";
            totalParam.Values = new List <string>()
            {
                preBill.Total.ToString()
            };

            //TotalExpense
            ReportParameter billDateParam = new ReportParameter();

            billDateParam.Name   = "BillDate";
            billDateParam.Values = new List <string>()
            {
                preBill.BillDate.ToString("dd/MM/yyyy")
            };

            parameters.Add(isEnglishParam);
            parameters.Add(isBilledParam);
            parameters.Add(clientNameParam);
            parameters.Add(billingPeriodParam);
            parameters.Add(subTotalExpenseParam);
            parameters.Add(discountParam);
            parameters.Add(taxesParam);
            parameters.Add(totalParam);
            parameters.Add(billDateParam);
            writer.SetParameters(parameters);
            writer.ReportProcessingMode = ProcessingMode.Local;
            MemoryStream memoryStream = new MemoryStream();

            writer.Save(memoryStream, WriterFormat.PDF);
            memoryStream.Position = 0;
            FileStreamResult fileStreamResult = new FileStreamResult(memoryStream, "application/pdf");

            fileStreamResult.FileDownloadName = $"FacturaCliente{preBill.BillName}deMes{preBill.BillMonth}YAño{preBill.BillYear}.pdf";
            return(Json(new { result = memoryStream.ConvertToBase64() }));
        }
Esempio n. 30
0
 public Bill UpdateBill(Bill originalBill, BillRequest Bill)
 {
     this.MergeBill(originalBill, Bill);
     BillRepository.Update(originalBill);
     return(originalBill);
 }