internal static CommonInvoice GetInvoice(Guid saleId) { CommonInvoice result = new CommonInvoice(); DatabaseEntities entities = new DatabaseEntities(); Document invoice = entities.Documents.FirstOrDefault(p => p.SaleId == saleId); if (invoice != null) { result.OwnerId = invoice.OwnerId; result.PartnerId = invoice.PartnerId; result.SaleId = invoice.SaleId; result.InvoiceId = invoice.InvoiceId; result.InvoiceNumber = invoice.InvoiceNumber; result.BuyerCompanyName = invoice.BuyerCompanyName; result.BuyerAddress = invoice.BuyerAddress; result.BuyerVATNumber = invoice.BuyerVATNumber; result.BuyerBulstat = invoice.BuyerBulstat; result.OwnerCompanyName = invoice.OwnerCompanyName; result.OwnerAddress = invoice.OwnerAddress; result.OwnerVATNumber = invoice.OwnerVATNumber; result.OwnerBulstat = invoice.OwnerBulstat; result.OwnerBank = invoice.OwnerBank; result.OwnerIBAN = invoice.OwnerIBAN; result.OwnerSwiftCode = invoice.OwnerSwiftCode; result.BuyerMol = invoice.BuyerMol; result.OwnerMol = invoice.OwnerMol; result.DiscountPercent = invoice.DiscountPercent.Value; } result.SoldItems = new List <CommonSoldItem>(); return(result); }
public static async Task <CommonInvoice> GetInvoice(Guid SaleId) { CommonInvoice invoice = new CommonInvoice(); HttpResponseMessage response; using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri(DataHolder.ServerAddress); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic"); try { response = await client.GetAsync("api/sales/invoice/" + SaleId); } catch (HttpRequestException ex) { throw new Exception(ex.InnerException.Message); } if (response.IsSuccessStatusCode) { invoice = await response.Content.ReadAsAsync <CommonInvoice>(); } } return(invoice); }
/// <summary> /// Return basic water fee of common invoice /// </summary> /// <returns></returns> public WaterFee GetBasicFee() { Contract.Requires(CommonInvoice != null); return(CommonInvoice.GetBasicFee()); }
/// <summary> /// Return consumption of common invoice /// </summary> /// <returns></returns> public ConsumptionValue GetConsumption() { Contract.Requires(CommonInvoice != null); return(CommonInvoice.GetConsumption()); }
/// <summary> /// Return read-out date of common invoice /// </summary> /// <returns></returns> public DateTime GetReadOutDate() { Contract.Requires(CommonInvoice != null); return(CommonInvoice.GetReadOutDate()); }
/// <summary> /// Return total water fee of common invoice /// </summary> /// <returns></returns> public Price GetTotalPrice() { return(CommonInvoice.GetTotalPrice()); }
/// <summary> /// Set fee plan used by invoice /// </summary> /// <param name="feeConfig"></param> public void SetFeeConfig(FeeConfig feeConfig) { CommonInvoice.SetFeeConfig(feeConfig); UserInvoices.ForEach(userInvoice => userInvoice.SetFeeConfig(feeConfig)); }
private async void LoadDataFromDb() { CommonInvoice invoice = await SASale.GetInvoice(Sale.SaleId); mlLabel17.Text = invoice.BuyerCompanyName; mlLabel15.Text = invoice.BuyerVATNumber; mlLabel13.Text = invoice.BuyerBulstat; mlLabel7.Text = invoice.BuyerMol; mlLabel29.Text = invoice.BuyerMol; mlLabel9.Text = invoice.BuyerAddress; labelInvoiceNumber.Text = invoice.InvoiceNumber.ToString().PadLeft(10, '0'); mlLabel19.Text = Sale.Date.ToString(CultureInfo.InvariantCulture); mlLabel18.Text = Sale.Date.ToString(CultureInfo.InvariantCulture); mlLabel24.Text = invoice.OwnerCompanyName; mlLabel23.Text = invoice.OwnerVATNumber; mlLabel22.Text = invoice.OwnerBulstat; mlLabel42.Text = invoice.OwnerIBAN; mlLabel41.Text = invoice.OwnerSwiftCode; mlLabel40.Text = invoice.OwnerBank; mlLabel21.Text = invoice.OwnerAddress; mlLabel20.Text = invoice.OwnerMol; mlLabel28.Text = invoice.OwnerMol; decimal totalBoth = 0; decimal ddsTotal = 0; decimal totatAmount = 0; List <GridItem> items = new List <GridItem>(); foreach (var soldItem in Sale.SoldItems) { CommonItem item = await SAItem.GetItemsById(soldItem.ItemId.ToString()); if (item != null) { GridItem gridItem = new GridItem(); gridItem.Name = item.Name; gridItem.Quantity = soldItem.Quantity.ToString(); if (DataHolder.UserCulture.TwoLetterISOLanguageName == "bg") { Enums.UnitTypesBg types = (Enums.UnitTypesBg)item.MeasurmentUnit; gridItem.MeasurementUnitString = types.ToString(); } else { Enums.UnitTypes types = (Enums.UnitTypes)item.MeasurmentUnit; gridItem.MeasurementUnitString = types.ToString(); } decimal temp = item.SellingPriceCent; gridItem.Price = temp / 100; var vatPercent = DataHolder.Settings.VatSettingsByGroup.FirstOrDefault(p => p.Key == item.Type); gridItem.Total = soldItem.Quantity * gridItem.Price; items.Add(gridItem); totatAmount += gridItem.Price * soldItem.Quantity; ddsTotal += (gridItem.Price * soldItem.Quantity) * vatPercent.Value; totalBoth += (gridItem.Price * soldItem.Quantity) + ((gridItem.Price * soldItem.Quantity) * vatPercent.Value); } } dgvItems.DataSource = items; labelAmount.Text = totatAmount.ToString(); labelTotal.Text = totalBoth.ToString(); labelDDS.Text = ddsTotal.ToString(); // do not change set grid size and export method order! SetGridSize(); if (SavePdf) { ExportInvoiceToPdf(); } }