public void TestAutoNumberingOfPurchaseNextAvailableNumberIsAvailable() { CrudProxy proxy = new InvoiceProxy(); var dto1 = this.GetUnpaidServicePurchase(); proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); var savedDto = (InvoiceDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, savedDto); Assert.IsNotNullOrEmpty(dto1.PurchaseOrderNumber); }
public void InsertAndGetServiceSaleWith_TradingTerms_EOM_Plus_14_days() { CrudProxy proxy = new InvoiceProxy(); var dto1 = this.GetServiceSale(); // EOM+ dto1.TradingTerms.TypeEnum = TradingTermsType.DueInEomPlusXDays; // Days dto1.TradingTerms.IntervalTypeEnum = TimeIntervalType.Day; // 14 days. dto1.TradingTerms.Interval = 14; //should be due in 14 days from the end of the month, using the transaction date as the base DateTime. var year = dto1.Date.Year; var month = dto1.Date.Month; var daysInMonth = DateTime.DaysInMonth(year, month); var dueDate = new DateTime(year, month, daysInMonth).AddDays(dto1.TradingTerms.Interval); proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); var savedDto = (InvoiceDto)proxy.GetByUid(dto1.Uid); //check trading terms Assert.AreEqual(dueDate, savedDto.DueOrExpiryDate); Assert.AreEqual(dto1.TradingTerms.Type, savedDto.TradingTerms.Type); Assert.AreEqual(dto1.TradingTerms.IntervalType, savedDto.TradingTerms.IntervalType); Assert.AreEqual(dto1.TradingTerms.Interval, savedDto.TradingTerms.Interval); Assert.AreEqual(dto1.TradingTerms.TypeEnum, savedDto.TradingTerms.TypeEnum); Assert.AreEqual(dto1.TradingTerms.IntervalTypeEnum, savedDto.TradingTerms.IntervalTypeEnum); Assert.AreEqual((int)dto1.TradingTerms.IntervalTypeEnum, savedDto.TradingTerms.IntervalType); Assert.AreEqual((int)dto1.TradingTerms.TypeEnum, savedDto.TradingTerms.Type); }
public void InsertAndGetServiceSaleWith_TradingTerms_Due_In_28_days() { CrudProxy proxy = new InvoiceProxy(); var dto1 = this.GetServiceSale(); // DueIn type dto1.TradingTerms.TypeEnum = TradingTermsType.DueIn; // Days dto1.TradingTerms.IntervalTypeEnum = TimeIntervalType.Day; // 14 days. dto1.TradingTerms.Interval = 28; //should be due in 6 months form the end of the transaction date. var dueDate = dto1.Date.AddDays(28); proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); var savedDto = (InvoiceDto)proxy.GetByUid(dto1.Uid); //check trading terms Assert.AreEqual(dto1.TradingTerms.Type, savedDto.TradingTerms.Type); Assert.AreEqual(dto1.TradingTerms.IntervalType, savedDto.TradingTerms.IntervalType); Assert.AreEqual(dto1.TradingTerms.Interval, savedDto.TradingTerms.Interval); Assert.AreEqual(dueDate, savedDto.DueOrExpiryDate); Assert.AreEqual(dto1.TradingTerms.TypeEnum, savedDto.TradingTerms.TypeEnum); Assert.AreEqual(dto1.TradingTerms.IntervalTypeEnum, savedDto.TradingTerms.IntervalTypeEnum); Assert.AreEqual((int)dto1.TradingTerms.IntervalTypeEnum, savedDto.TradingTerms.IntervalType); Assert.AreEqual((int)dto1.TradingTerms.TypeEnum, savedDto.TradingTerms.Type); }
public void InsertAndGetItemSale_Invoice_Totals_Test() { //Arange var proxy = new InvoiceProxy(); var input = GetServiceSaleTotalsTest(); var item = new ServiceInvoiceItemDto { Description = "Design & Development of REST WS", AccountUid = this.IncomeService.Uid, TaxCode = TaxCode.SaleInclGst, TotalAmountInclTax = 2500.65m }; input.Items.Add(item); item = new ServiceInvoiceItemDto { Description = "Subscription to XYZ", AccountUid = this.IncomeSubscription.Uid, TaxCode = TaxCode.SaleInclGst, TotalAmountInclTax = 11.96m }; input.Items.Add(item); //act var totalItem1 = ((ServiceInvoiceItemDto)input.Items[0]).TotalAmountInclTax; var totalItem2 = ((ServiceInvoiceItemDto)input.Items[1]).TotalAmountInclTax; var totalTax1 = totalItem1 - (Math.Round(totalItem1 / (1 + 0.100000m), 2, MidpointRounding.AwayFromZero)); var totalTax2 = totalItem2 - (Math.Round(totalItem2 / (1 + 0.100000m), 2, MidpointRounding.AwayFromZero)); proxy.Insert(input); var output = (InvoiceDto)proxy.GetByUid(input.Uid); var outputLineItem1 = ((ServiceInvoiceItemDto)output.Items[0]); var outputLineItem2 = ((ServiceInvoiceItemDto)output.Items[1]); //assert //Test Line Item Totals. Assert.AreEqual(outputLineItem1.TotalAmountInclTax, totalItem1); Assert.AreEqual(outputLineItem1.TotalTaxAmount, totalTax1); Assert.AreEqual(outputLineItem1.TotalAmountExclTax, outputLineItem1.TotalAmountInclTax - totalTax1); Assert.AreEqual(outputLineItem2.TotalAmountInclTax, totalItem2); Assert.AreEqual(outputLineItem2.TotalTaxAmount, totalTax2); Assert.AreEqual(outputLineItem2.TotalAmountExclTax, outputLineItem2.TotalAmountInclTax - totalTax2); //Test Invoice Totals. Assert.AreEqual(output.TotalAmountInclTax, outputLineItem1.TotalAmountInclTax + outputLineItem2.TotalAmountInclTax); Assert.AreEqual(output.TotalTaxAmount, outputLineItem1.TotalTaxAmount + outputLineItem2.TotalTaxAmount); Assert.AreEqual(output.TotalAmountExclTax, outputLineItem1.TotalAmountExclTax + outputLineItem2.TotalAmountExclTax); }
public void InsertAndEmailUsingShippingSlipTemplate() { InvoiceProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetServiceSale(); EmailMessageDto emailMessage = new EmailMessageDto(); emailMessage.From = ConfigurationSettings.AppSettings["NUnitTests.Email.From"]; emailMessage.To = ConfigurationSettings.AppSettings["NUnitTests.Email.To"]; emailMessage.Subject = "Insert And Email: Shipping slip Template"; emailMessage.Body = "Insert Invoice then email."; proxy.InsertAndEmail(dto1, this.ShippingTemplateUid, emailMessage); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); // // Ensure IsSent is updated. // dto1 = (InvoiceDto)proxy.GetByUid(dto1.Uid); Assert.IsTrue(dto1.IsSent, "Invoice should have been sent."); }
public void Update_Service_Sale_Line_Item_Tags() { CrudProxy proxy = new InvoiceProxy(); var dto1 = this.GetServiceSale(); dto1.Tags = "Tag1, Tag2, Tag3"; var lineItem1 = (ServiceInvoiceItemDto)dto1.Items[0]; var lineItem2 = (ServiceInvoiceItemDto)dto1.Items[1]; lineItem1.Tags = "LineItem1Tag1, LineItem1Tag2"; lineItem2.Tags = "LineItem2Tag1, LineItem2Tag2"; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); var savedDto = (InvoiceDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, savedDto); var line1 = (ServiceInvoiceItemDto)savedDto.Items[0]; var line2 = (ServiceInvoiceItemDto)savedDto.Items[1]; line1.Tags = "UpdateLineItem1Tag1, UpdateLineItem1Tag2"; line2.Tags = "UpdateLineItem2Tag1, UpdateLineItem2Tag2"; proxy.Update(savedDto); var updatedDto = (InvoiceDto)proxy.GetByUid(savedDto.Uid); AssertEqual(savedDto, updatedDto); }
public void UpdateShipToContactForServiceSale() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetServiceSale(); dto1.ShipToContactUid = MrsSmith.Uid; proxy.Insert(dto1); dto1.ShipToContactUid = MrsSmith.Uid; proxy.Update(dto1); InvoiceDto dto2 = (InvoiceDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, dto2); }
public void UpdateMultiCcySaleWithPaymentOverrideManualFXFeed() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetServiceSale(); dto1.Date = DateTime.Parse("12-Feb-2010"); dto1.Ccy = "USD"; dto1.AutoPopulateFXRate = false; dto1.FCToBCFXRate = 1.1458902517M; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InvoiceDto dto2 = (InvoiceDto)proxy.GetByUid(dto1.Uid); dto2.FCToBCFXRate = 1.1258801678M; try { proxy.Update(dto2); throw new Exception("Expected exception not thrown."); } catch (RestException rex) { Assert.AreEqual("Sorry, FX rate cannot be changed because there are payments applied to the transaction already. Please change the FX rate on payment instead.", rex.Message, "Incorrect message."); } }
public void InsertWithShipToContact() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetItemSale(); dto1.ShipToContactUid = MrsSmith.Uid; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InvoiceDto dto2 = (InvoiceDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, dto2); }
public void InsertUsingLowerCaseTranType() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetServiceSale(); dto1.TransactionType = "s"; // Lower case shouldn't really matter proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InvoiceDto dto2 = (InvoiceDto)proxy.GetByUid(dto1.Uid); }
public void ChangeInvoiceTypeFromTaxInvoiceToAdjustmentNote() { CrudProxy proxy = new InvoiceProxy(); var dto1 = this.GetAdjustmentNote(); dto1.InvoiceType = InvoiceType.TaxInvoice; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); var savedDto = (InvoiceDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, savedDto); Assert.AreEqual(InvoiceType.TaxInvoice, savedDto.InvoiceType, "Incorrect invoice type."); savedDto.InvoiceType = InvoiceType.AdjustmentNote; proxy.Update(savedDto); savedDto = (InvoiceDto)proxy.GetByUid(dto1.Uid); Assert.AreEqual(InvoiceType.AdjustmentNote, savedDto.InvoiceType, "Incorrect invoice type."); }
public void InsertServiceSale1() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetServiceSale(); dto1.Date = DateTime.Today; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InvoiceDto dto2 = (InvoiceDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, dto2); ServiceInvoiceItemDto line1 = (ServiceInvoiceItemDto)dto2.Items[0]; ServiceInvoiceItemDto line2 = (ServiceInvoiceItemDto)dto2.Items[1]; Assert.AreEqual("AUD", dto2.Ccy, "Incorrect Currency"); Assert.AreEqual(1, dto2.FCToBCFXRate, "Incorrect FXRate."); Assert.AreEqual(2132.51M, line1.TotalAmountInclTax, "Incorrect amount on line 1."); Assert.AreEqual(11.22M, line2.TotalAmountInclTax, "Incorrect amount on line 2."); }
public void InsertMultiCcyServiceSaleUsingFXFeed() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetServiceSale(); dto1.Date = DateTime.Parse("12-Feb-2010"); dto1.Ccy = "USD"; dto1.AutoPopulateFXRate = true; dto1.FCToBCFXRate = 0M; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InvoiceDto dto2 = (InvoiceDto)proxy.GetByUid(dto1.Uid); Assert.AreEqual(dto1.Ccy, dto2.Ccy, "Incorrect Currency."); Assert.AreEqual(dto1.AutoPopulateFXRate, dto2.AutoPopulateFXRate, "Incorrect Auto Populate FX Rate flag."); Assert.IsTrue(dto2.FCToBCFXRate > 0, "Incorrect FX rate."); // Set by the server. AssertEqual(dto1, dto2); ServiceInvoiceItemDto line1 = (ServiceInvoiceItemDto)dto2.Items[0]; ServiceInvoiceItemDto line2 = (ServiceInvoiceItemDto)dto2.Items[1]; Assert.AreEqual(2132.51M, line1.TotalAmountInclTax, "Incorrect amount on line 1."); Assert.AreEqual(11.22M, line2.TotalAmountInclTax, "Incorrect amount on line 2."); }
public void InsertItemSaleOrder1() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetItemSale(); dto1.Status = InvoiceStatus.Order; dto1.Date = DateTime.Today; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InvoiceDto dto2 = (InvoiceDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, dto2); }
public void InsertAndUpdateItemSalePassingLineItemId() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetItemSale(); proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InvoiceDto dto2 = (InvoiceDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, dto2); var lineItems = dto2.Items; foreach (var lineItem in lineItems) { Assert.IsTrue(((ItemInvoiceItemDto)lineItem).Uid > 0); } InvoiceDto dto3 = GetItemSale(); dto3.Uid = dto2.Uid; dto3.LastUpdatedUid = dto2.LastUpdatedUid; dto3.InvoiceNumber = dto2.InvoiceNumber; dto3.Items = lineItems; proxy.Update(dto3); InvoiceDto dto4 = (InvoiceDto)proxy.GetByUid(dto3.Uid); AssertEqual(dto3, dto4); }
public void UpdateMultiCcySaleWithPaymentChangeCurrency() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetServiceSale(); dto1.Date = DateTime.Parse("12-Feb-2010"); dto1.Ccy = "USD"; dto1.AutoPopulateFXRate = true; dto1.FCToBCFXRate = 1.1337403549M; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InvoiceDto dto2 = (InvoiceDto)proxy.GetByUid(dto1.Uid); dto2.Ccy = "EUR"; try { proxy.Update(dto2); } catch (RestException rex) { Assert.AreEqual("Sorry, FX rate cannot be changed because there are payments applied to the transaction already. Please change the FX rate on payment instead.", rex.Message, "Incorrect message."); } }
public void UpdateMultiCcySaleWithPaymentOverrideAutoFXFeed() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetServiceSale(); dto1.Date = DateTime.Parse("12-Feb-2010"); dto1.Ccy = "USD"; dto1.AutoPopulateFXRate = true; dto1.FCToBCFXRate = 0M; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InvoiceDto dto2 = (InvoiceDto)proxy.GetByUid(dto1.Uid); dto2.AutoPopulateFXRate = false; dto2.FCToBCFXRate = 1.039M; try { proxy.Update(dto2); // Should not be allowed. There's a payment applied already. Assert.Fail("No exception thrown."); } catch (RestException restException) { var expectedMessage = "Sorry, FX rate cannot be changed because there are payments applied to the transaction already. Please change the FX rate on payment instead."; Assert.AreEqual(expectedMessage, restException.Message, "Incorrect error message."); } }
public void InsertWithTags() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetServiceSale(); dto1.Tags = "TestInsertWithTags1, TestInsertWithTags2, TestInsertWithTags3"; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InvoiceDto dto2 = (InvoiceDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, dto2); }
public void UpdateServiceSale() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetServiceSale(); proxy.Insert(dto1); InvoiceDto fromDB = (InvoiceDto)proxy.GetByUid(dto1.Uid); int invoiceUid = dto1.Uid; string lastUpdatedUid = dto1.LastUpdatedUid; string invoiceNumber = dto1.InvoiceNumber; dto1 = this.GetServiceSale2(); dto1.Uid = invoiceUid; dto1.LastUpdatedUid = lastUpdatedUid; dto1.InvoiceNumber = invoiceNumber; proxy.Update(dto1); InvoiceDto dto2 = (InvoiceDto)proxy.GetByUid(dto1.Uid); Assert.AreEqual("AUD", dto2.Ccy, "Incorrect Currency."); Assert.AreEqual(1, dto2.FCToBCFXRate, "Incorrect FXRate."); AssertEqual(dto1, dto2); }
public void Insert_And_Get_Item_Sale_With_Tags_On_Line_Items() { CrudProxy proxy = new InvoiceProxy(); var dto1 = this.GetItemSale(); dto1.Tags = "Tag1, Tag2, Tag3"; var lineItem1 = (ItemInvoiceItemDto)dto1.Items[0]; var lineItem2 = (ItemInvoiceItemDto)dto1.Items[1]; lineItem1.Tags = "LineItem1Tag1, LineItem1Tag2"; lineItem2.Tags = "LineItem2Tag1, LineItem2Tag2"; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); var savedDto = (InvoiceDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, savedDto); }
public void DeleteSale() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetServiceSale(); proxy.Insert(dto1); proxy.DeleteByUid(dto1.Uid); try { proxy.GetByUid(dto1.Uid); } catch (RestException ex) { Assert.AreEqual("RecordNotFoundException", ex.Type); } }
public void Insert_And_Get_Service_Sale_With_Tags_On_Line_Items() { CrudProxy proxy = new InvoiceProxy(); var dto1 = this.GetServiceSale(); dto1.Tags = "Tag1, Tag2, Tag3"; var lineItem1 = (ServiceInvoiceItemDto)dto1.Items[0]; var lineItem2 = (ServiceInvoiceItemDto)dto1.Items[1]; lineItem1.Tags = "LineItem1Tag1, LineItem1Tag2"; lineItem2.Tags = "LineItem2Tag1, LineItem2Tag2"; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); var savedDto = (InvoiceDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, savedDto); var line1 = (ServiceInvoiceItemDto)savedDto.Items[0]; var line2 = (ServiceInvoiceItemDto)savedDto.Items[1]; Assert.AreEqual("AUD", savedDto.Ccy, "Incorrect Currency."); Assert.AreEqual(1, savedDto.FCToBCFXRate, "Incorrect FXRate."); Assert.AreEqual(2132.51M, line1.TotalAmountInclTax, "Incorrect amount on line 1."); Assert.AreEqual(11.22M, line2.TotalAmountInclTax, "Incorrect amount on line 2."); }
public void InsertAdjustmentNote() { CrudProxy proxy = new InvoiceProxy(); var dto1 = this.GetAdjustmentNote(); proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); var savedDto = (InvoiceDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, savedDto); }
public void TestAutoNumberingOfInvoiceNextAvailableNumberNotAvailable() { CrudProxy proxy = new InvoiceProxy(); var dto1 = this.GetServiceSale(); proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); string alphaComponent; var numericalComponentDto1 = GetNumericalComponentOfInvoiceNumber(dto1.InvoiceNumber, out alphaComponent); Assert.IsNotNull(numericalComponentDto1, "InvoiceNumber returned did not contain a numerical component"); //manually insert an invoice. var nextAvailableInvoiceNumber = alphaComponent + (numericalComponentDto1 + 1).ToString(); var dto2 = this.GetServiceSale(nextAvailableInvoiceNumber); proxy.Insert(dto2); Assert.IsTrue(dto2.Uid > 0, "Uid must be > 0 after save."); //create next auto numbering invoice. var dto3 = this.GetServiceSale(); proxy.Insert(dto3); Assert.IsTrue(dto3.Uid > 0, "Uid must be > 0 after save."); var savedDto = (InvoiceDto)proxy.GetByUid(dto3.Uid); Assert.IsNotNull(savedDto.InvoiceNumber); Assert.AreEqual(savedDto.InvoiceNumber, alphaComponent + (numericalComponentDto1 + 2).ToString()); }
public void InsertAndGetItemSale() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetItemSale(); proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InvoiceDto dto2 = (InvoiceDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, dto2); }
public void UpdateAndEmail() { InvoiceProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetServiceSale(); proxy.Insert(dto1); int invoiceUid = dto1.Uid; string lastUpdatedUid = dto1.LastUpdatedUid; string invoiceNumber = dto1.InvoiceNumber; dto1 = this.GetServiceSale2(); dto1.Uid = invoiceUid; dto1.LastUpdatedUid = lastUpdatedUid; dto1.InvoiceNumber = invoiceNumber; EmailMessageDto emailMessage = new EmailMessageDto(); emailMessage.From = ConfigurationSettings.AppSettings["NUnitTests.Email.From"]; emailMessage.To = ConfigurationSettings.AppSettings["NUnitTests.Email.To"]; emailMessage.Subject = "Invoice - Sent using NetAccounts OLA REST API (TestUpdateAndEmail)."; emailMessage.Body = "Update Invoice then email."; proxy.UpdateAndEmail(dto1, this.IncTaxTemplateUid, emailMessage); InvoiceDto dto2 = (InvoiceDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, dto2); }
public void InsertAndGetServiceSale() { CrudProxy proxy = new InvoiceProxy(); var dto1 = this.GetServiceSale(); proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); var savedDto = (InvoiceDto)proxy.GetByUid(dto1.Uid); AssertEqual(dto1, savedDto); var line1 = (ServiceInvoiceItemDto)savedDto.Items[0]; var line2 = (ServiceInvoiceItemDto)savedDto.Items[1]; Assert.AreEqual("AUD", savedDto.Ccy, "Incorrect Currency."); Assert.AreEqual(1, savedDto.FCToBCFXRate, "Incorrect FXRate."); Assert.AreEqual(2132.51M, line1.TotalAmountInclTax, "Incorrect amount on line 1."); Assert.AreEqual(11.22M, line2.TotalAmountInclTax, "Incorrect amount on line 2."); // For testing load generation on Tag queue //const int numRuns = 5000; //CrudProxy proxy = new InvoiceProxy(); //for (var i = 0; i < numRuns; i++) //{ // Console.WriteLine("Inserting sale #{0}", i); // var dto1 = this.GetServiceSale(); // proxy.Insert(dto1); //} }
public void UpdateMultiCcySaleOverrideAutoFXFeedRateWithZero() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetUnpaidServiceSale(); dto1.Date = DateTime.Parse("12-Feb-2010"); dto1.Ccy = "USD"; dto1.AutoPopulateFXRate = true; dto1.FCToBCFXRate = 0M; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InvoiceDto dto2 = (InvoiceDto)proxy.GetByUid(dto1.Uid); dto2.AutoPopulateFXRate = false; dto2.FCToBCFXRate = 0M; try { proxy.Update(dto2); } catch (RestException rex) { Assert.AreEqual("Invalid FX Rate. Must be > 0.", rex.Message, "Incorrect message."); } }
public void InsertAndGetServiceSaleWith_TradingTerms_Due_In_Specific_Date() { CrudProxy proxy = new InvoiceProxy(); var dto1 = this.GetServiceSale(); // DueIn type dto1.TradingTerms.TypeEnum = TradingTermsType.DueIn; // Unspecified - means actual date dto1.TradingTerms.IntervalTypeEnum = TimeIntervalType.Unspecified; //Set specific date that invoice is due in. var dueDate = new DateTime(2012, 12, 24); // Set to specific date dto1.DueOrExpiryDate = dueDate; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); var savedDto = (InvoiceDto)proxy.GetByUid(dto1.Uid); //check trading terms Assert.AreEqual(dueDate, savedDto.DueOrExpiryDate); Assert.AreEqual(dto1.TradingTerms.Type, savedDto.TradingTerms.Type); Assert.AreEqual(dto1.TradingTerms.IntervalType, savedDto.TradingTerms.IntervalType); Assert.AreEqual(dto1.TradingTerms.Interval, savedDto.TradingTerms.Interval); Assert.AreEqual(dto1.TradingTerms.TypeEnum, savedDto.TradingTerms.TypeEnum); Assert.AreEqual(dto1.TradingTerms.IntervalTypeEnum, savedDto.TradingTerms.IntervalTypeEnum); Assert.AreEqual((int)dto1.TradingTerms.IntervalTypeEnum, savedDto.TradingTerms.IntervalType); Assert.AreEqual((int)dto1.TradingTerms.TypeEnum, savedDto.TradingTerms.Type); }
public void UpdateMultiCcySaleOverrideManualFXRateWithZero() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetUnpaidServiceSale(); dto1.Date = DateTime.Parse("12-Feb-2010"); dto1.Ccy = "USD"; dto1.AutoPopulateFXRate = false; dto1.FCToBCFXRate = 1.1458902517M; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); InvoiceDto dto2 = (InvoiceDto)proxy.GetByUid(dto1.Uid); dto2.AutoPopulateFXRate = true; dto2.FCToBCFXRate = 0M; proxy.Update(dto2); InvoiceDto dto3 = (InvoiceDto)proxy.GetByUid(dto1.Uid); Assert.AreEqual(dto2.Ccy, dto3.Ccy, "Incorrect Currency."); Assert.AreEqual(dto2.AutoPopulateFXRate, dto3.AutoPopulateFXRate, "Incorrect Auto Populate FX Rate flag."); Assert.IsTrue(dto3.FCToBCFXRate > 0, "Incorrect FX rate."); AssertEqual(dto2, dto3); }