private void LoadTaxCodes() { var taxCodeSvc = new TaxCodeService(MyConfiguration, null, MyOAuthKeyService); taxCodeSvc.GetRange(MyCompanyFile, null, MyCredentials, OnTaxCodeComplete, OnError); }
public TaxCodeServiceTest( StripeMockFixture stripeMockFixture, MockHttpClientFixture mockHttpClientFixture) : base(stripeMockFixture, mockHttpClientFixture) { this.service = new TaxCodeService(this.StripeClient); this.listOptions = new TaxCodeListOptions { Limit = 1, }; }
public void Create_TaxCodeEmpty_ThrowsDomainValidationException() { var id = Guid.NewGuid(); var taxCodeName = String.Empty; var description = "Tax at 20%"; var rate = 0.2d; _taxCodeService = new TaxCodeService( _userContext, MockRepository.GenerateMock <ITaxCodeRepository>(), MockRepository.GenerateStub <IQueueDispatcher <IMessage> >()); Create(id, taxCodeName, description, rate); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.TaxCodeEmpty)); }
private void LoadTaxes() { try { var taxCodeSvc = new TaxCodeService(ConfigurationCloud, null, MyOAuthKeyService); taxCodeSvc.GetRange(CompanyFile, null, Credentials, OnTaxCodeComplete, OnError); } catch (Exception ex) { ServiceLogger.LogException("Exception in LoadTaxes", ex); } }
public void Create_DuplicateName_ThrowsDomainValidationException() { var id = Guid.NewGuid(); var taxCodeName = "T1"; var description = "Tax at 20%"; var rate = 0.2d; var taxCodeRepositoryStub = MockRepository.GenerateMock <ITaxCodeRepository>(); taxCodeRepositoryStub.Stub(x => x.GetByName(taxCodeName)).Return(new TaxCode { TaxCodeName = taxCodeName }); _taxCodeService = new TaxCodeService( _userContext, taxCodeRepositoryStub, MockRepository.GenerateStub <IQueueDispatcher <IMessage> >()); Create(id, taxCodeName, description, rate); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.DuplicateName)); }
public void Create_ValidDetails_TaxCodeCreate() { var id = Guid.NewGuid(); var taxCodeName = "T1"; var description = "Tax at 20%"; var rate = 0.2d; var taxCodeRepositoryMock = MockRepository.GenerateMock <ITaxCodeRepository>(); taxCodeRepositoryMock.Expect(x => x.Update(null)).IgnoreArguments(); _taxCodeService = new TaxCodeService( _userContext, taxCodeRepositoryMock, MockRepository.GenerateStub <IQueueDispatcher <IMessage> >()); Create(id, taxCodeName, description, rate); taxCodeRepositoryMock.VerifyAllExpectations(); Assert.AreEqual(_savedTaxCode.Id, id); Assert.AreEqual(_savedTaxCode.TaxCodeName, taxCodeName); Assert.AreEqual(_savedTaxCode.Description, description); Assert.AreEqual(_savedTaxCode.Rate, rate); }
public void InitService(ApiConfiguration myConfiguration, OAuthKeyService myOAuthKeyService) { _myService = new TaxCodeService(myConfiguration, null, myOAuthKeyService); items = new List <TaxCode>(); }
public string PostSaleInvoice(PelicanSale sale, PelicanContext context = null, Guid?companyFileId = null) { var authorizationService = new AuthorizationService(); context = context ?? PelicanContext.CreateFromApplicationSettings(); companyFileId = companyFileId ?? context.CompanyFileId; var apiContext = authorizationService.GetAuthorizedContext(context, companyFileId.Value); try { if (_taxCode == null) { var taxCodeService = new TaxCodeService(apiContext.ApiConfiguration); var taxCodes = taxCodeService.GetRange(apiContext.CompanyFile, null, apiContext.CompanyFileCredentials); _taxCode = taxCodes.Items.First(_ => _.Code == "GST"); } var service = new ItemInvoiceService(apiContext.ApiConfiguration); var entity = new ItemInvoice(); entity.UID = Guid.NewGuid(); entity.InvoiceType = InvoiceLayoutType.Item; entity.Customer = new CustomerLink { UID = Guid.Parse(sale.Customer.Id) }; entity.Number = string.Format("SJ{0:D5}", _referenceNbr++); entity.Date = DateTime.Today; var invoiceLines = new List <ItemInvoiceLine>(); for (var index = 0; index < sale.SaleableItems.Count(); index++) { var saleableItem = sale.SaleableItems[index]; var item = new ItemInvoiceLine(); item.Item = new ItemLink { UID = Guid.Parse(saleableItem.Id) }; item.RowID = index; item.ShipQuantity = 1; item.Total = Convert.ToDecimal(saleableItem.Price); item.TaxCode = new TaxCodeLink { UID = _taxCode.UID }; invoiceLines.Add(item); } entity.Lines = invoiceLines; entity.TotalAmount = Convert.ToDecimal(sale.SaleableItems.Sum(_ => _.Price)); entity.Comment = "Entered via Pelican"; return(service.Insert(apiContext.CompanyFile, entity, apiContext.CompanyFileCredentials)); } catch (Exception ex) { switch (ex.GetType() .Name) { case "WebException": Debug.WriteLine(FormatMessage((WebException)ex)); break; case "ApiCommunicationException": Debug.WriteLine(FormatMessage((WebException)ex.InnerException)); break; case "ApiOperationException": Debug.WriteLine(ex.Message); break; default: Debug.WriteLine(ex.Message); break; } } return(null); }