public void ApplyPaymentOnUpdateCausingOverpayment() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetUnpaidServiceSale(); proxy.Insert(dto1); dto1.QuickPayment = this.GetServiceSale().QuickPayment; dto1.QuickPayment.Amount = 10000; try { proxy.Update(dto1); throw new Exception("Expected exception not thrown."); } catch (RestException ex) { Assert.AreEqual("InvalidInvoicePaymentException", ex.Type); } }
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 ApplyPaymentOnUpdate() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetUnpaidServiceSale(); proxy.Insert(dto1); dto1.QuickPayment = this.GetServiceSale().QuickPayment; proxy.Update(dto1); }
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 UpdateWithInvalidUid() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetUnpaidServiceSale(); proxy.Insert(dto1); dto1.Uid = 0; try { proxy.Update(dto1); throw new Exception("Expected exception not thrown."); } catch (RestException ex) { Assert.AreEqual("ArgumentException", ex.Type); } }
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 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 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 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); }
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 ConvertInvoiceToOrder() { CrudProxy proxy = new InvoiceProxy(); InvoiceDto dto1 = this.GetItemSale(); dto1.Status = InvoiceStatus.Invoice; dto1.Date = DateTime.Today; proxy.Insert(dto1); Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save."); dto1.Status = InvoiceStatus.Order; try { proxy.Update(dto1); throw new Exception("Exception should be thrown."); } catch (RestException rex) { Assert.AreEqual("Sorry, conversion from invoice to non invoice such as order or quote is not allowed.", rex.Message, "Incorrect exception message."); } }
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 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); }