using Biskilog_Accounting.Shared.POSModels; using Microsoft.AspNetCore.Components; using Net.ConnectCode.Barcode; namespace Biskilog_Accounting.Client.Pages.Transactions.Elements { public partial class ReceiptDialog { [Parameter] public string ReceiptId { get; set; } private IEnumerable ReceiptDetail { get; set; } = Enumerable.Empty(); string barcode = ""; string barcode_text = ""; private string m_balance { get; set; } private string m_tendered { get; set; } private string m_total { get; set; } private string m_subtotal { get; set; } private string m_discount { get; set; } = "0.00"; private string m_vat { get; set; } private string m_cashier { get; set; } private string m_date { get; set; } private Tblbranch m_branch { get; set; } private string m_companyName { get; set; } = string.Empty; void GenerateBarcode() { BarcodeFonts bcf = new BarcodeFonts(); bcf.BarcodeType = BarcodeFonts.BarcodeEnum.Code39; bcf.CheckDigit = BarcodeFonts.YesNoEnum.Yes; bcf.Data = ReceiptId; bcf.encode(); barcode = bcf.EncodedData; barcode_text = ReceiptId; } protected override async Task OnParametersSetAsync() { ReceiptDetail = await m_saleInterface.GetReceiptDetail(ReceiptId); SetParams(); GenerateBarcode(); StateHasChanged(); return; } private void SetParams() { if (ReceiptDetail.Count() > 0) { double total = (double)ReceiptDetail.Sum(t => t.Total).Value; double discount = (double)ReceiptDetail.First().Discount.Value; double vat = (double)ReceiptDetail.First().ValueAddTax.Value; double billTotal = (vat + total); m_cashier = ReceiptDetail.First().Cashier; m_subtotal = m_calculator.FormatMoneyWithCurrency(total); m_tendered = m_calculator.FormatMoneyWithCurrency((double)ReceiptDetail.First().Tendered.Value); m_balance = m_calculator.FormatMoneyWithCurrency((double)ReceiptDetail.First().Balance.Value); m_vat = (vat).ToString("0.00") + "%"; m_date = ReceiptDetail.First().Date.Value.ToString("dd MMMM, yyyy HH:mm:ss"); m_total = m_calculator.FormatMoneyWithCurrency(billTotal); string branchId = ReceiptDetail.First().BranchId; m_branch = m_companyInfo.FetchBranches().ToList().First(t => t.BranchId == branchId); m_companyName = m_companyInfo.GetCompanyName(); } } } }