PI2024-23 #2
@ -135,7 +135,9 @@ namespace FirmTracker_Server.Controllers
|
|||||||
product.TransactionId = transaction.Id;
|
product.TransactionId = transaction.Id;
|
||||||
decimal price = _productCRUD.GetProductPrice(product.ProductID);
|
decimal price = _productCRUD.GetProductPrice(product.ProductID);
|
||||||
transaction.TotalPrice += ((product.Quantity * price) * ((1 - (transaction.Discount / 100))));
|
transaction.TotalPrice += ((product.Quantity * price) * ((1 - (transaction.Discount / 100))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transaction.TotalPrice = Math.Round(transaction.TotalPrice, 2, MidpointRounding.AwayFromZero);
|
||||||
_transactionCRUD.UpdateTransaction(transaction);
|
_transactionCRUD.UpdateTransaction(transaction);
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ namespace FirmTracker_Server.nHibernate.Transactions
|
|||||||
Map(x => x.PaymentType);
|
Map(x => x.PaymentType);
|
||||||
Map(x => x.Discount);
|
Map(x => x.Discount);
|
||||||
Map(x => x.Description);
|
Map(x => x.Description);
|
||||||
Map(x => x.TotalPrice);
|
Map(x => x.TotalPrice).Precision(18).Scale(2);
|
||||||
|
|
||||||
HasMany(x => x.TransactionProducts)
|
HasMany(x => x.TransactionProducts)
|
||||||
.KeyColumn("TransactionId")
|
.KeyColumn("TransactionId")
|
||||||
|
@ -28,9 +28,11 @@ namespace FirmTracker_Server.nHibernate.Transactions
|
|||||||
{
|
{
|
||||||
transaction.TotalPrice += (product.Price) * ((1 - (transaction.Discount / 100)));
|
transaction.TotalPrice += (product.Price) * ((1 - (transaction.Discount / 100)));
|
||||||
}
|
}
|
||||||
transactionProduct.TransactionId = transaction.Id;
|
transactionProduct.TransactionId = transaction.Id;
|
||||||
|
|
||||||
session.Save(transactionProduct);
|
session.Save(transactionProduct);
|
||||||
}
|
}
|
||||||
|
transaction.TotalPrice = Math.Round(transaction.TotalPrice, 2, MidpointRounding.AwayFromZero);
|
||||||
session.Save(transaction);
|
session.Save(transaction);
|
||||||
|
|
||||||
// Decrease product quantities based on transaction
|
// Decrease product quantities based on transaction
|
||||||
@ -183,8 +185,8 @@ namespace FirmTracker_Server.nHibernate.Transactions
|
|||||||
|
|
||||||
transactionProduct.TransactionId= transactionToUpdate.Id;
|
transactionProduct.TransactionId= transactionToUpdate.Id;
|
||||||
session.Save(transactionProduct);
|
session.Save(transactionProduct);
|
||||||
transaction.Commit();
|
|
||||||
|
|
||||||
|
transactionToUpdate.TotalPrice = Math.Round(transactionToUpdate.TotalPrice, 2, MidpointRounding.AwayFromZero);
|
||||||
session.Update(transactionToUpdate);
|
session.Update(transactionToUpdate);
|
||||||
//var product = session.Get<Product>(transactionProduct.ProductID);
|
//var product = session.Get<Product>(transactionProduct.ProductID);
|
||||||
if (product.Type != 0)
|
if (product.Type != 0)
|
||||||
@ -192,7 +194,7 @@ namespace FirmTracker_Server.nHibernate.Transactions
|
|||||||
product.Availability -= transactionProduct.Quantity;
|
product.Availability -= transactionProduct.Quantity;
|
||||||
session.Update(product);
|
session.Update(product);
|
||||||
}
|
}
|
||||||
|
transaction.Commit();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ namespace FirmTracker_Server.nHibernate.Transactions
|
|||||||
Map(x => x.PaymentType);
|
Map(x => x.PaymentType);
|
||||||
Map(x => x.Discount);
|
Map(x => x.Discount);
|
||||||
Map(x => x.Description);
|
Map(x => x.Description);
|
||||||
Map(x => x.TotalPrice);
|
Map(x => x.TotalPrice).Precision(18).Scale(2);
|
||||||
|
|
||||||
HasMany(x => x.TransactionProducts)
|
HasMany(x => x.TransactionProducts)
|
||||||
.KeyColumn("TransactionId")
|
.KeyColumn("TransactionId")
|
||||||
|
Loading…
Reference in New Issue
Block a user