Skip to content

Commit

Permalink
Fixed an issue introduced in last commit Where Refunded sale was show…
Browse files Browse the repository at this point in the history
…n with positive Received Amount and Partner Share.
  • Loading branch information
ravibpatel committed Aug 8, 2017
1 parent 704351b commit d7e33cb
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions Sales Manager/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,25 +279,23 @@ public static bool GetSales(DateTime fromDate, DateTime toDate, Account account,
transaction.PriceAfterAuthorFee = transaction.PriceAfterBuyerFee -
transaction.PriceAfterAuthorFee;
transaction.GetPartnerShare();
if (transaction.ReceivedAmount < 0)
db.Transactions.Add(transaction);
}
db.SaveChanges();
foreach (var transaction in transactions.Where(tr => tr.ReceivedAmount < 0))
{
var refundedTransaction =
db.Transactions.FirstOrDefault(
tr => !tr.ID.Equals(transaction.ID) && tr.OrderID.Equals(transaction.OrderID) &&
tr.Product.ID.Equals(transaction.Product.ID) &&
tr.PriceAfterAuthorFee.Equals(transaction.PriceAfterAuthorFee));
if (refundedTransaction != null)
{
var refundedTransaction =
db.Transactions.FirstOrDefault(
tr => tr.OrderID.Equals(transaction.OrderID) &&
tr.Product.ID.Equals(transaction.Product.ID) &&
tr.PriceAfterAuthorFee.Equals(transaction.PriceAfterAuthorFee)) ??
transactions.FirstOrDefault(
tr => tr.OrderID.Equals(transaction.OrderID) &&
tr.Product.ID.Equals(transaction.Product.ID) &&
tr.PriceAfterAuthorFee.Equals(transaction.PriceAfterAuthorFee));
if (refundedTransaction != null)
{
transaction.ReceivedAmount = refundedTransaction.ReceivedAmount * -1;
transaction.PartnerShare = refundedTransaction.PartnerShare * -1;
transaction.Detail += $" (Original Order was from {refundedTransaction.Date.ToShortDateString()})";
}
transaction.ReceivedAmount = refundedTransaction.ReceivedAmount * -1;
transaction.PartnerShare = refundedTransaction.PartnerShare * -1;
transaction.Detail +=
$" (Original Order was from {refundedTransaction.Date.ToShortDateString()})";
}
db.Transactions.Add(transaction);
}
db.SaveChanges();
}
Expand Down

0 comments on commit d7e33cb

Please sign in to comment.