Add ability to enter promotions when creating transaction

This commit is contained in:
2023-07-24 15:17:44 +01:00
parent c0c1743d78
commit bb2820f7df
17 changed files with 382 additions and 42 deletions

View File

@ -12,10 +12,9 @@
.SingleAsync();
var itemIds = Model.Items.Select(item => item.ItemId);
var items = await dbContext.Items
var itemNames = await dbContext.Items
.Where(item => itemIds.Contains(item.Id))
.Select(item => new { item.Id, Name = string.Concat(item.Brand, " ", item.Name) })
.ToListAsync();
.ToDictionaryAsync(item => item.Id, item => string.Concat(item.Brand, " ", item.Name));
}
<h1>New Transaction</h1>
@ -45,7 +44,7 @@
{
<tr>
<td class="table__cell table__cell--compact">
@items.Single(i => i.Id == item.ItemId).Name
@itemNames[item.ItemId]
</td>
<td class="table__cell table__cell--compact table__cell--numeric">
@item.Price.ToString("c")
@ -54,7 +53,7 @@
@item.Quantity
</td>
<td class="table__cell table__cell--compact table__cell--numeric">
@((item.Price * item.Quantity).ToString("c"))
@item.Amount.ToString("c")
</td>
<td class="table__cell table__cell--compact">
<a class="link" asp-action="EditTransactionItem" asp-route-id="@item.ItemId" data-turbo-frame="modal">Edit</a>
@ -64,9 +63,9 @@
</tbody>
<tfoot>
<tr>
<td class="table__cell table__cell--compact table__cell--total" colspan="3">Total</td>
<td class="table__cell table__cell--compact table__cell--total" colspan="3">Subtotal</td>
<td class="table__cell table__cell--compact table__cell--numeric table__cell--total">
@Model.Items.Sum(item => item.Price * item.Quantity).ToString("c")
@Model.Items.Sum(item => item.Amount).ToString("c")
</td>
<td class="table__cell table__cell--compact"></td>
</tr>
@ -76,7 +75,7 @@
</div>
<div class="row">
<button class="button button--primary" type="submit" @(Model.Items.Count == 0 ? "disabled" : "")>Save</button>
<a class="button" asp-action="Index">Cancel</a>
<button class="button button--primary" type="submit" @(Model.Items.Count == 0 ? "disabled" : "")>Next</button>
<a class="button" asp-action="NewTransaction">Back</a>
</div>
</form>