private void HandlePartialRefunds(BankEntry entry, List <BankEntry> updatedEntries, Myorder order, AllegroDataContainer container) { List <Offer> offersWithProperPrice = order.offers.Where(x => this.converter.ToDecimal(x.offerPrice.amount) == entry.Amount).ToList(); if (offersWithProperPrice.Any()) { if (offersWithProperPrice.Count == 1) { Offer offer = offersWithProperPrice.First(); BankEntry newEntry = BankEntry.Clone(entry); newEntry.Note = $"ZWROT: {offer.title} (Ilość sztuk: {offer.quantity}, Oferta {offer.id})"; newEntry.Payer = "allegro.pl - " + order.seller.login; newEntry.Recipient = container.ServiceUserName; newEntry.FullDetails += $"\r\nPłatność Allegro: {order.payment.id}.\r\n URL: {offer.friendlyUrl}"; updatedEntries.Add(newEntry); } else { BankEntry newEntry = BankEntry.Clone(entry); newEntry.Note = "ZWROT pasujący do jednej z ofert: " + string.Join("\r\n", offersWithProperPrice.Select(x => x.title)); newEntry.Payer = "allegro.pl - " + order.seller.login; newEntry.Recipient = container.ServiceUserName; newEntry.FullDetails += $"\r\nPłatność Allegro: {order.payment.id}.\r\n{newEntry.Note}"; updatedEntries.Add(newEntry); } } }
private void AddDeliveryCost(BankEntry entry, List <BankEntry> updatedEntries, Myorder allegroEntry, AllegroDataContainer container) { if (allegroEntry.delivery.cost.amount != "0.00") { //lets add a delivery cost as a separate entry, but assign it a category etc. of the most expensive item Offer mostExpensive = allegroEntry.offers.OrderByDescending(x => this.converter.ToDecimal(x.offerPrice.amount)).First(); BankEntry deliveryEntry = BankEntry.Clone(entry); deliveryEntry.Amount = this.converter.ToDecimal(allegroEntry.delivery.cost.amount) * -1; deliveryEntry.Note = $"DOSTAWA: {mostExpensive.title} (Oferta {mostExpensive.id}, Suma zamówień: {allegroEntry.offers.Length})"; deliveryEntry.Recipient = "allegro.pl - " + allegroEntry.seller.login; deliveryEntry.Tags.Add("dostawa"); if (string.IsNullOrEmpty(deliveryEntry.Payer)) { deliveryEntry.Payer = container.ServiceUserName; } deliveryEntry.FullDetails += $"\r\nPłatność Allegro: {allegroEntry.payment.id}.\r\n URL: {mostExpensive.friendlyUrl}"; updatedEntries.Add(deliveryEntry); } }
private BankEntry PrepareNewBankEntryForOffer(Myorder allegroEntry, int offerIndex, BankEntry entry, AllegroDataContainer container) { Offer offer = allegroEntry.offers[offerIndex]; BankEntry newEntry = BankEntry.Clone(entry); newEntry.Amount = this.converter.ToDecimal(offer.offerPrice.amount); newEntry.Note = $"ZWROT: {offer.title} (Ilość sztuk: {offer.quantity}, Oferta {offer.id}, Pozycja {offerIndex + 1}/{allegroEntry.offers.Length})"; newEntry.Payer = "allegro.pl - " + allegroEntry.seller.login; newEntry.Recipient = container.ServiceUserName; newEntry.FullDetails += $"\r\nPłatność Allegro: {allegroEntry.payment.id}.\r\n URL: {offer.friendlyUrl}"; return(newEntry); }