+ Timeout logout
+ Pred kreiranjem povpraševanja vprašaj za partnerja + Prikaz TOP 100 (predolgo nalaga) + Dodaj Sorovec na Urejanje Artikla (zadnji surovec) + V Urejanju artikla popravi opis v pot dokumentov + Kooperant
This commit is contained in:
@@ -183,7 +183,7 @@ namespace EveryThing.Pages.Projects
|
||||
return Partial("DetailsPartItem", item);
|
||||
}
|
||||
|
||||
public IActionResult OnPostCreateOrder(string itemsJson, bool inquiry)
|
||||
public IActionResult OnPostCreateCooperation(string itemsJson, int idPartner)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
@@ -197,6 +197,83 @@ namespace EveryThing.Pages.Projects
|
||||
var suppliers = _context.ProjectPartItems
|
||||
.Where(x => itemsId.Contains(x.IdProjectPartItem))
|
||||
.Select(x => x.IdMaterialSupplierFk).Distinct().ToList();
|
||||
|
||||
if (idPartner > 0) //vse na izbranega partnerja
|
||||
suppliers = new List<int?> { idPartner };
|
||||
|
||||
var idInvoice = -1;
|
||||
|
||||
foreach (var idSupplier in suppliers)
|
||||
{
|
||||
var invoice = _context.Invoices
|
||||
.Include(x => x.InvoiceInvoiceItem)
|
||||
.ThenInclude(x => x.ProjectPartItem)
|
||||
.ThenInclude(x => x.ProjectPart)
|
||||
.Where(x => x.State == Models.Invoice.Invoice.InvoiceState.New
|
||||
&& x.Type == Models.Invoice.Invoice.InvoiceType.Cooperation
|
||||
//Ce ze kateri item obstaja na dobavnici
|
||||
&& x.InvoiceInvoiceItem.Any(invoiceItem => items.Select(item => item.ProjectPart.IdProjectFk).Contains(invoiceItem.ProjectPartItem.ProjectPart.IdProjectFk)))
|
||||
.FirstOrDefault(x => x.IdPartnerFk == idSupplier);
|
||||
|
||||
|
||||
if (invoice == null)
|
||||
{
|
||||
//Create new invoice
|
||||
var newInvoice = new Models.Invoice.Invoice();
|
||||
Pages.Invoices.CreateModel.SetNewInvoice(user.IdCompanyFk, Models.Invoice.Invoice.InvoiceType.Cooperation, ref newInvoice, _context);
|
||||
newInvoice.IdPartnerFk = idSupplier;
|
||||
newInvoice.Date = DateTime.Now.Date;
|
||||
|
||||
_context.Invoices.Add(newInvoice);
|
||||
_context.SaveChanges();
|
||||
idInvoice = newInvoice.IdInvoice;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Add to existing invoice
|
||||
idInvoice = invoice.IdInvoice;
|
||||
}
|
||||
|
||||
foreach (var projectPartItem in items.Where(x => idPartner > 0 || //ce damo vse na izbranega partnerja
|
||||
x.IdMaterialSupplierFk == idSupplier))
|
||||
{
|
||||
var newInvoiceItem = new Models.Invoice.InvoiceItem
|
||||
{
|
||||
Discount = 0,
|
||||
IdInvoiceFk = idInvoice,
|
||||
IdProjectPartItem = projectPartItem.IdProjectPartItem,
|
||||
IdItemFk = projectPartItem.IdMaterialFk,
|
||||
ItemDescription = projectPartItem.MaterialDimensions,
|
||||
Note = "",
|
||||
Price = projectPartItem.MaterialPrice,
|
||||
Quantity = projectPartItem.NumberOfItems
|
||||
};
|
||||
_context.InvoiceItems.Add(newInvoiceItem);
|
||||
}
|
||||
_context.SaveChanges();
|
||||
}
|
||||
|
||||
return new JsonResult(new { error = "", successful = true, idInvoice });
|
||||
}
|
||||
|
||||
public IActionResult OnPostCreateOrder(string itemsJson, bool inquiry, int idPartner)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var itemsId = JsonSerializer.Deserialize<List<int>>(itemsJson);
|
||||
|
||||
var items = _context.ProjectPartItems
|
||||
.Include(x => x.ProjectPart)
|
||||
.ThenInclude(x => x.Project)
|
||||
.Where(x => itemsId.Contains(x.IdProjectPartItem)).ToList();
|
||||
|
||||
var suppliers = _context.ProjectPartItems
|
||||
.Where(x => itemsId.Contains(x.IdProjectPartItem))
|
||||
.Select(x => x.IdMaterialSupplierFk).Distinct().ToList();
|
||||
|
||||
if (idPartner > 0) //vse na izbranega partnerja
|
||||
suppliers = new List<int?> { idPartner };
|
||||
|
||||
var idInvoice = -1;
|
||||
|
||||
foreach (var idSupplier in suppliers)
|
||||
@@ -232,7 +309,8 @@ namespace EveryThing.Pages.Projects
|
||||
idInvoice = invoice.IdInvoice;
|
||||
}
|
||||
|
||||
foreach (var projectPartItem in items.Where(x => x.IdMaterialSupplierFk == idSupplier))
|
||||
foreach (var projectPartItem in items.Where(x => idPartner > 0 || //ce damo vse na izbranega partnerja
|
||||
x.IdMaterialSupplierFk == idSupplier))
|
||||
{
|
||||
var newInvoiceItem = new Models.Invoice.InvoiceItem
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user