public async Task <IActionResult> AddSupplierInvoice([FromBody] SupplierInvoiceView view) { SupplierInvoiceModule invMod = new SupplierInvoiceModule(); NextNumber nnSupplierInvoice = await invMod.SupplierInvoice.Query().GetNextNumber(); view.SupplierInvoiceNumber = nnSupplierInvoice.NextNumberValue; SupplierInvoice supplierInvoice = await invMod.SupplierInvoice.Query().MapToEntity(view); invMod.SupplierInvoice.AddSupplierInvoice(supplierInvoice).Apply(); SupplierInvoiceView newView = await invMod.SupplierInvoice.Query().GetViewByNumber(view.SupplierInvoiceNumber); return(Ok(newView)); }
public bool CreateSupplierInvoice(SupplierInvoiceView supplierInvoiceView) { try { SupplierInvoice .CreateSupplierInvoiceByView(supplierInvoiceView) .Apply(); SupplierInvoiceDetail .CreateSupplierInvoiceDetailsByView(supplierInvoiceView) .Apply(); return(true); } catch (Exception ex) { throw new Exception("CreateSupplierInvoice", ex); } }
public async Task TestReceiveSupplierInvoice() { long? supplierId = 3; SupplierModule supplierMod = new SupplierModule(); try { SupplierView supplierView = await supplierMod.Supplier.Query().GetViewById(supplierId ?? 0); string json = @"{ ""SupplierId"" : " + supplierView.SupplierId + @", ""SupplierInvoiceNumber"": ""AZW23-1"", ""SupplierInvoiceDate"" : """ + DateTime.Parse("8/20/2018") + @""", ""PONumber"" : ""PO-2"", ""Amount"": 268, ""Description"": ""Back to School supplies"", ""TaxAmount"" : 16.08, ""PaymentDueDate"": """ + DateTime.Parse("8/20/2018") + @""", ""PaymentTerms"" : ""Net 30"", ""FreightCost"" : 4.98, ""SupplierInvoiceDetailViews"":[ { ""ItemId"": 5, ""Quantity"": 5, ""UnitPrice"" : " + 10 + @", ""ExtendedCost"" : " + 50 + @", ""UnitOfMeasure"" : """ + "Dozen" + @""", ""Description"": """ + "Pencil HB" + @""" }, { ""ItemId"": 6, ""Quantity"": 4, ""UnitPrice"" : " + 10 + @", ""ExtendedCost"" : " + 40 + @", ""UnitOfMeasure"" : """ + "Dozen" + @""", ""Description"": """ + "Pencils 2B" + @""" }, { ""ItemId"": 7, ""Quantity"": 10, ""UnitPrice"" : " + 3 + @", ""ExtendedCost"" : " + 30 + @", ""UnitOfMeasure"" : """ + "Ream" + @""", ""Description"": """ + "Paper - A4, Photo coper, 70 grams" + @""" }, { ""ItemId"": 8, ""Quantity"": 15, ""UnitPrice"" : " + 3.20 + @", ""ExtendedCost"" : " + 48 + @", ""UnitOfMeasure"" : """ + "Ream" + @""", ""Description"": """ + "NPaper - A4, Photo Copier, 80 gramULL" + @""" }, { ""ItemId"": 9, ""Quantity"": 5, ""UnitPrice"" : " + 10 + @", ""ExtendedCost"" : " + 100 + @", ""UnitOfMeasure"" : """ + "Ream" + @""", ""Description"": """ + "Pens - Ball Point, Blue" + @""" } ] }"; SupplierInvoiceView supplierInvoiceView = JsonConvert.DeserializeObject <SupplierInvoiceView>(json); AccountPayableModule apMod = new AccountPayableModule(); apMod.CreateSupplierInvoice(supplierInvoiceView); apMod.AccountPayable.Apply(); } catch (Exception ex) { } }