public static void DisplayPoHeader(ITestOutputHelper output, Storage.Po po) { output.WriteLine(""); if (po == null) { output.WriteLine($"No PO to display."); } else { output.WriteLine($"PO number : {po.PoNumber}"); output.WriteLine($"BuyerUserAddress : {po.BuyerUserAddress}"); output.WriteLine($"BuyerReceiverAddress : {po.BuyerReceiverAddress}"); output.WriteLine($"BuyerWalletAddress : {po.BuyerWalletAddress}"); output.WriteLine($"EShopId : {po.EShopId}"); output.WriteLine($"QuoteId : {po.QuoteId}"); output.WriteLine($"QuoteExpiryDate : {po.QuoteExpiryDate}"); output.WriteLine($"QuoteSignerAddress : {po.QuoteSignerAddress}"); output.WriteLine($"CurrencySymbol : {po.CurrencySymbol}"); output.WriteLine($"CurrencyAddress : {po.CurrencyAddress}"); output.WriteLine($"PoType : {po.PoType}"); output.WriteLine($"SellerId : {po.SellerId}"); output.WriteLine($"PoCreateDate : {po.PoCreateDate}"); output.WriteLine($"PoItemCount : {po.PoItemCount}"); output.WriteLine($"PoRulesCount : {po.RulesCount}"); } }
private async Task <Purchasing.Po> CreatePurchasingPoAsync(uint quoteId, string eShopId) { Storage.Po po = CreatePoForPurchasingContracts( buyerUserAddress: _contracts.Web3.TransactionManager.Account.Address.ToLowerInvariant(), buyerReceiverAddress: _contracts.Web3.TransactionManager.Account.Address.ToLowerInvariant(), buyerWalletAddress: _contracts.Deployment.BuyerWalletService.ContractHandler.ContractAddress.ToLowerInvariant(), eShopId: eShopId, sellerId: _contracts.Deployment.ContractNewDeploymentConfig.Seller.SellerId, currencySymbol: await _contracts.Deployment.MockDaiService.SymbolQueryAsync(), currencyAddress: _contracts.Deployment.MockDaiService.ContractHandler.ContractAddress.ToLowerInvariant(), quoteId); return(po.ToPurchasingPo()); }
/// <summary> /// Compare a requested PO with an as-built version of the same PO. /// Optionally also check the approver address and creation date. /// </summary> public static void CheckCreatedPoFieldsMatch(Storage.Po poAsRequested, Storage.Po poAsBuilt, BigInteger poNumberAsBuilt, string quoteSignerAddressAsBuilt = null, BigInteger?poCreateDateAsBuilt = null) { poAsBuilt.PoNumber.Should().Be(poNumberAsBuilt); poAsBuilt.BuyerUserAddress.Should().Be(poAsRequested.BuyerUserAddress); poAsBuilt.BuyerReceiverAddress.Should().Be(poAsRequested.BuyerReceiverAddress); poAsBuilt.BuyerWalletAddress.Should().Be(poAsRequested.BuyerWalletAddress); poAsBuilt.EShopId.Should().Be(poAsRequested.EShopId); poAsBuilt.QuoteId.Should().Be(poAsRequested.QuoteId); poAsBuilt.QuoteExpiryDate.Should().Be(poAsRequested.QuoteExpiryDate); if (quoteSignerAddressAsBuilt is string quoteSignerAddressAsBuiltValue) { poAsBuilt.QuoteSignerAddress.Should().Be(quoteSignerAddressAsBuiltValue); } poAsBuilt.SellerId.Should().Be(poAsRequested.SellerId); poAsBuilt.CurrencySymbol.Should().Be(poAsRequested.CurrencySymbol); poAsBuilt.CurrencyAddress.Should().Be(poAsRequested.CurrencyAddress); poAsBuilt.PoType.Should().Be(poAsRequested.PoType); if (poCreateDateAsBuilt is BigInteger poCreateDateAsBuiltValue) { poAsBuilt.PoCreateDate.Should().Be(poCreateDateAsBuiltValue); } poAsBuilt.PoItemCount.Should().Be((uint)poAsRequested.PoItems.Count); for (int i = 0; i < poAsBuilt.PoItemCount; i++) { poAsBuilt.PoItems[i].PoNumber.Should().Be(poNumberAsBuilt); poAsBuilt.PoItems[i].PoItemNumber.Should().Be((uint)(i + 1)); poAsBuilt.PoItems[i].SoNumber.Should().Be(poAsRequested.PoItems[i].SoNumber); poAsBuilt.PoItems[i].SoItemNumber.Should().Be(poAsRequested.PoItems[i].SoItemNumber); poAsBuilt.PoItems[i].ProductId.Should().Be(poAsRequested.PoItems[i].ProductId); poAsBuilt.PoItems[i].Quantity.Should().Be(poAsRequested.PoItems[i].Quantity); poAsBuilt.PoItems[i].Unit.Should().Be(poAsRequested.PoItems[i].Unit); poAsBuilt.PoItems[i].QuantitySymbol.Should().Be(poAsRequested.PoItems[i].QuantitySymbol); poAsBuilt.PoItems[i].QuantityAddress.Should().Be(poAsRequested.PoItems[i].QuantityAddress); poAsBuilt.PoItems[i].CurrencyValue.Should().Be(poAsRequested.PoItems[i].CurrencyValue); // Don't check CurrencyValueFee, it is assigned by contract poAsBuilt.PoItems[i].Status.Should().Be(PoItemStatus.Created); poAsBuilt.PoItems[i].GoodsIssuedDate.Should().Be(0); poAsBuilt.PoItems[i].GoodsReceivedDate.Should().Be(0); poAsBuilt.PoItems[i].PlannedEscrowReleaseDate.Should().Be(0); poAsBuilt.PoItems[i].ActualEscrowReleaseDate.Should().Be(0); poAsBuilt.PoItems[i].IsEscrowReleased.Should().Be(false); poAsBuilt.PoItems[i].CancelStatus.Should().Be(PoItemCancelStatus.Initial); } }
public Storage.Po CreateDummyPoForPurchasingCreate(Quote quote) { var po = new Storage.Po() { // PoNumber assigned by contract BuyerAddress = "0x37ed4f49ec2c7bdcce8631b1a7b54ed5d4aa9610", ReceiverAddress = "0x36ed4f49ec2c7bdcce8631b1a7b54ed5d4aa9610", BuyerWalletAddress = "0x39ed4f49ec2c7bdcce8631b1a7b54ed5d4aa9610", CurrencySymbol = "DAI", CurrencyAddress = "0x41ed4f49ec2c7bdcce8631b1a7b54ed5d4aa9610", QuoteId = quote.Id, QuoteExpiryDate = DateTimeOffset.UtcNow.AddMonths(1).ToUnixTimeSeconds(), ApproverAddress = string.Empty, // assigned by contract PoType = PoType.Cash, SellerId = _config.SellerId, // PoCreateDate assigned by contract // PoItemCount assigned by contract PoItems = new List <Storage.PoItem>() }; //gtin1111 foreach (var quoteItem in quote.QuoteItems) { po.PoItems.Add(new Storage.PoItem { // PoNumber assigned by contract // PoItemNumber assigned by contract SoNumber = string.Empty, SoItemNumber = string.Empty, ProductId = quoteItem.ItemOrdered.Gtin, Quantity = quoteItem.Quantity, Unit = "EA", QuantitySymbol = "NA", QuantityAddress = "0x40ed4f49ec2c7bdcce8631b1a7b54ed5d4aa9610", CurrencyValue = quoteItem.CurrencyValue == null ? 0 : BigInteger.Parse(quoteItem.CurrencyValue), // Status assigned by contract // GoodsIssuedDate assigned by contract // GoodsReceivedDate assigned by contract // PlannedEscrowReleaseDate assigned by contract // ActualEscrowReleaseDate assigned by contract // IsEscrowReleased assigned by contract // CancelStatus assigned by contract }); } return(po); }
/// <summary> /// Compare every field of two POs /// </summary> public static void CheckEveryPoFieldMatches(Storage.Po poExpected, Storage.Po poActual) { poActual.PoNumber.Should().Be(poExpected.PoNumber); poActual.BuyerUserAddress.Should().Be(poExpected.BuyerUserAddress); poActual.BuyerReceiverAddress.Should().Be(poExpected.BuyerReceiverAddress); poActual.BuyerWalletAddress.Should().Be(poExpected.BuyerWalletAddress); poActual.EShopId.Should().Be(poExpected.EShopId); poActual.QuoteId.Should().Be(poExpected.QuoteId); poActual.QuoteExpiryDate.Should().Be(poExpected.QuoteExpiryDate); poActual.QuoteSignerAddress.Should().Be(poExpected.QuoteSignerAddress); poActual.SellerId.Should().Be(poExpected.SellerId); poActual.CurrencySymbol.Should().Be(poExpected.CurrencySymbol); poActual.CurrencyAddress.Should().Be(poExpected.CurrencyAddress); poActual.PoType.Should().Be(poExpected.PoType); poActual.PoCreateDate.Should().Be(poExpected.PoCreateDate); poActual.PoItemCount.Should().Be(poExpected.PoItemCount); for (int i = 0; i < poActual.PoItemCount; i++) { poActual.PoItems[i].PoNumber.Should().Be(poExpected.PoItems[i].PoNumber); poActual.PoItems[i].PoItemNumber.Should().Be(poExpected.PoItems[i].PoItemNumber); poActual.PoItems[i].SoNumber.Should().Be(poExpected.PoItems[i].SoNumber); poActual.PoItems[i].SoItemNumber.Should().Be(poExpected.PoItems[i].SoItemNumber); poActual.PoItems[i].ProductId.Should().Be(poExpected.PoItems[i].ProductId); poActual.PoItems[i].Quantity.Should().Be(poExpected.PoItems[i].Quantity); poActual.PoItems[i].Unit.Should().Be(poExpected.PoItems[i].Unit); poActual.PoItems[i].QuantitySymbol.Should().Be(poExpected.PoItems[i].QuantitySymbol); poActual.PoItems[i].QuantityAddress.Should().Be(poExpected.PoItems[i].QuantityAddress); poActual.PoItems[i].CurrencyValue.Should().Be(poExpected.PoItems[i].CurrencyValue); poActual.PoItems[i].CurrencyValueFee.Should().Be(poExpected.PoItems[i].CurrencyValueFee); poActual.PoItems[i].Status.Should().Be(poExpected.PoItems[i].Status); poActual.PoItems[i].GoodsIssuedDate.Should().Be(poExpected.PoItems[i].GoodsIssuedDate); poActual.PoItems[i].GoodsReceivedDate.Should().Be(poExpected.PoItems[i].GoodsReceivedDate); poActual.PoItems[i].PlannedEscrowReleaseDate.Should().Be(poExpected.PoItems[i].PlannedEscrowReleaseDate); poActual.PoItems[i].ActualEscrowReleaseDate.Should().Be(poExpected.PoItems[i].ActualEscrowReleaseDate); poActual.PoItems[i].IsEscrowReleased.Should().Be(poExpected.PoItems[i].IsEscrowReleased); poActual.PoItems[i].CancelStatus.Should().Be(poExpected.PoItems[i].CancelStatus); } poActual.RulesCount.Should().Be(poExpected.RulesCount); for (int i = 0; i < poActual.RulesCount; i++) { poActual.Rules[i].Should().BeEquivalentTo(poExpected.Rules[i]); } }
/// <summary> /// A realistic test PO intended for passing to contracts BuyerWallet.sol or Purchasing.sol poCreate() functions. /// </summary> public static Storage.Po CreatePoForPurchasingContracts( string buyerUserAddress, string buyerReceiverAddress, string buyerWalletAddress, string eShopId, string sellerId, string currencySymbol, string currencyAddress, uint quoteId, bool isLargeValue = false) { BigInteger valueLine01 = BigInteger.Parse("110000000000000000000"); // eg this is 110 dai BigInteger valueLine02 = BigInteger.Parse("220000000000000000000"); // eg this is 220 dai if (isLargeValue) { valueLine01 *= 1000; valueLine02 *= 1000; } var po = new Storage.Po() { // PoNumber assigned by contract BuyerUserAddress = buyerUserAddress, BuyerReceiverAddress = buyerReceiverAddress, BuyerWalletAddress = buyerWalletAddress, EShopId = eShopId, QuoteId = quoteId, QuoteExpiryDate = new BigInteger(DateTimeOffset.Now.ToUnixTimeSeconds() + 3600), // expires in an hour QuoteSignerAddress = string.Empty, // assigned by contract SellerId = sellerId, CurrencySymbol = currencySymbol, CurrencyAddress = currencyAddress, PoType = PoType.Cash, // PoCreateDate assigned by contract // PoItemCount assigned by contract PoItems = new List <Storage.PoItem>() { new Storage.PoItem() { // PoNumber assigned by contract // PoItemNumber assigned by contract SoNumber = string.Empty, SoItemNumber = string.Empty, ProductId = "gtin1111", Quantity = 1, Unit = "EA", QuantitySymbol = "NA", QuantityAddress = "0x40ed4f49ec2c7bdcce8631b1a7b54ed5d4aa9610", CurrencyValue = valueLine01 // CurrencyValueFee assigned by contract // Status assigned by contract // GoodsIssuedDate assigned by contract // GoodsReceivedDate assigned by contract // PlannedEscrowReleaseDate assigned by contract // ActualEscrowReleaseDate assigned by contract // IsEscrowReleased assigned by contract // CancelStatus assigned by contract }, new Storage.PoItem() { // PoNumber assigned by contract // PoItemNumber assigned by contract SoNumber = string.Empty, SoItemNumber = string.Empty, ProductId = "gtin2222", Quantity = 2, Unit = "EA", QuantitySymbol = "NA", QuantityAddress = "0x42ed4f49ec2c7bdcce8631b1a7b54ed5d4aa9610", CurrencyValue = valueLine02 // Status assigned by contract // GoodsIssuedDate assigned by contract // GoodsReceivedDate assigned by contract // PlannedEscrowReleaseDate assigned by contract // ActualEscrowReleaseDate assigned by contract // IsEscrowReleased assigned by contract // CancelStatus assigned by contract } }, // RulesCount assigned by contract Rules = new List <byte[]>() { "rule01".ConvertToBytes32(), "rule02".ConvertToBytes32(), "rule03".ConvertToBytes32() } }; return(po); }
public static Purchase.Po ToPurchasingPo(this Storage.Po po) { return(_mapper.Map <Purchase.Po>(po)); }
public static Seller.Po ToSellerPo(this Storage.Po po) { return(_mapper.Map <Seller.Po>(po)); }
public static Buyer.Po ToBuyerPo(this Storage.Po po) { return(_mapper.Map <Buyer.Po>(po)); }