/// <summary> /// Marshals information about a collection of outstanding MasterCard redeemed deals into a collection of MasterCard rebate records. /// </summary> /// <param name="outstandingRedeemedDeals"> /// The outstanding redeemed deals to marshal. /// </param> /// <returns> /// The corresponding collection of rebate records. /// </returns> /// <exception cref="ArgumentNullException"> /// Parameter outstandingRedeemedDeals cannot be null. /// </exception> public static Collection <RebateRecord> MarshalOutstandingRedeemedDeals(Collection <OutstandingRedeemedDealInfo> outstandingRedeemedDeals) { if (outstandingRedeemedDeals == null) { throw new ArgumentNullException("outstandingRedeemedDeals", "Parameter outstandingRedeemedDeals cannot be null."); } Collection <RebateRecord> result = new Collection <RebateRecord>(); foreach (OutstandingRedeemedDealInfo outstandingRedeemedDeal in outstandingRedeemedDeals) { KeyClearingData keyClearingData = KeyClearingData.Deserialize(outstandingRedeemedDeal.PartnerData); RebateRecord rebateRecord = new RebateRecord { TransactionSequenceNumber = outstandingRedeemedDeal.AcquirerReferenceNumber, TransactionAmount = ((decimal)outstandingRedeemedDeal.SettlementAmount / 100), TransactionDate = outstandingRedeemedDeal.TransactionDate, RebateAmount = ((decimal)outstandingRedeemedDeal.DiscountAmount / 100), MerchantId = keyClearingData.MerchantId, IssuerIca = keyClearingData.IssuerIca, BankCustomerNumber = keyClearingData.BankCustomerNumber, TransactionDescription = MicrosoftEarnRebateSource }; result.Add(rebateRecord); } return(result); }
/// <summary> /// Builds the rebate record of the specified type for the specified record. /// </summary> /// <param name="record"> /// The record for which to build a rebate record. /// </param> /// <returns> /// The rebate record for the specified record. /// </returns> internal static string Build(RebateRecord record) { StringBuilder result = new StringBuilder(); // Record type. result.Append(RecordType); // Transaction sequence number. result.Append(record.TransactionSequenceNumber); // Bank account number. result.Append(RebateConstants.AlphaOmittedCharacter, BankAccountNumberFieldLength); // Transaction amount. result.Append(record.TransactionAmount.ToString("F2").PadLeft(TransactionAmountFieldLength, RebateConstants.NumericOmittedCharacter)); // Transaction date. result.Append(record.TransactionDate.ToString("yyyyMMdd")); // Rebate amount. result.Append(record.RebateAmount.ToString("F2").PadLeft(RebateAmountFieldLength, RebateConstants.NumericOmittedCharacter)); // Merchant category code. result.Append(MerchantCategoryCode); // Transaction description. result.Append(record.TransactionDescription.PadRight(TransactionDescriptionFieldLength)); // Reversal indicator. result.Append(NoReversalIndicator); // Merchant ID. result.Append(record.MerchantId.PadRight(MerchantIdFieldLength)); // Issuer ICA. result.Append(record.IssuerIca); // Program code. result.Append(ProgramCode); // Bank product code. result.Append(BankProductCode.PadRight(BankProductCodeFieldLength)); // Bank customer number. result.Append(record.BankCustomerNumber.PadRight(BankCustomerNumberFieldLength)); // Filler. result.Append(RebateConstants.AlphaOmittedCharacter, FillerFieldLength); return(result.ToString()); }