コード例 #1
0
        private void LoadTaxCodes()
        {
            var taxCodeSvc = new TaxCodeService(MyConfiguration, null,
                                                MyOAuthKeyService);

            taxCodeSvc.GetRange(MyCompanyFile, null, MyCredentials, OnTaxCodeComplete, OnError);
        }
コード例 #2
0
ファイル: MYOBCompanyFiles.cs プロジェクト: radtek/Pos
 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);
     }
 }
コード例 #3
0
 private void LoadTaxCodes()
 {
     var taxCodeSvc = new TaxCodeService(MyConfiguration, null,
                                         MyOAuthKeyService);
     taxCodeSvc.GetRange(MyCompanyFile, null, MyCredentials, OnTaxCodeComplete, OnError);
 }
コード例 #4
0
        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);
        }