SHARE
TWEET

Untitled

a guest Jun 27th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         private incomingInvoiceDto CreateInvoice(SignableData invoice, string supplier_id, string store_id, string supplier_code)
  2.         {
  3.             incomingInvoiceDto idt = new incomingInvoiceDto();
  4.             idt.comment = "Auto upload";
  5.             //idt.documentNumber =
  6.                 idt.invoice =
  7.                     idt.incomingDocumentNumber = invoice.GeneralInfo.InvoiceNumber.Number;
  8.             idt.supplier = supplier_id;
  9.             idt.defaultStore = store_id;
  10.             idt.dateIncoming = DateTime.Parse(invoice.GeneralInfo.SupplyDate, CultureInfo.InvariantCulture).ToString("dd.MM.yyyy");
  11.             List<incomingInvoiceItemDto> items = new List<incomingInvoiceItemDto>();
  12.             int index = 1;
  13.             foreach (var good in invoice.GoodsInfo.Good)
  14.             {
  15.                 incomingInvoiceItemDto item = new incomingInvoiceItemDto();
  16.                 item.name = good.Description;
  17.                 item.num = index++;
  18.                 var products = RestApi.GetPriceList(supplier_code)?.Where(a => a.supplierProductName.Trim() == good.Description.Trim()).ToList();
  19.                 var product = (products.Count == 0 || products.Count > 1) ? null : products[0];
  20.                 var container = product?.container;
  21.                 item.product = product?.nativeProduct;
  22.                 item.containerId = container?.id;
  23.                 item.supplierProduct = product?.supplierProduct;
  24.                 item.price = decimal.Parse(good.PricePerUnit ?? "0", CultureInfo.InvariantCulture);
  25.                 item.priceSpecified = true;
  26.                 item.amount = decimal.Parse(good.Amount ?? "0", CultureInfo.InvariantCulture);
  27.                 item.amountSpecified = true;
  28.                 item.vatPercent = decimal.Parse(good.VATRate ?? "0", CultureInfo.InvariantCulture);
  29.                 item.vatPercentSpecified = true;
  30.                 if (product?.container != null && product?.container.countSpecified == true && product?.container.count > 1)
  31.                 {
  32.                     item.amount *= product.container.count;
  33.                 }
  34.                 item.sum = decimal.Parse(good.TotalPrice ?? "0", CultureInfo.InvariantCulture);
  35.                 item.sumSpecified = true;
  36.                 //item.sumWithoutNds = decimal.Parse(good.Price, CultureInfo.InvariantCulture);
  37.                 //item.sumWithoutNdsSpecified = true;
  38.                 item.store = store_id;
  39.                 items.Add(item);
  40.             }
  41.             idt.items = items.ToArray();
  42.             return idt;
  43.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top