public decimal GetTaxRate(QuickBooksOnlineClient client, int taxCodeId)
        {
            var taxCode       = client.Query <TaxCode>($"select * from TaxCode where Id = '{taxCodeId}'").Single();
            var taxRateId     = taxCode.SalesTaxRateList.TaxRateDetail.Single().TaxRateRef.Value;
            var taxRateEntity = client.Query <TaxRate>($"select * from TaxRate where Id = '{taxRateId}'").Single();
            var taxRate       = taxRateEntity.RateValue.GetValueOrDefault() / 100;

            return(taxRate);
        }
示例#2
0
        public void Run(APIGatewayProxyRequest request, APIGatewayProxyResponse response, FinanceUser user)
        {
            var dbClient    = new AmazonDynamoDBClient();
            var qboDbClient = new DatabaseClient <QuickBooksOnlineConnection>(dbClient, new ConsoleLogger());
            var qboClient   = new QuickBooksOnlineClient(PrivateAccounting.Constants.LakelandMiPuebloRealmId, qboDbClient, new ConsoleLogger());

            var vendorDataClient = new DatabaseClient <Vendor>(dbClient, new ConsoleLogger());
            var vendor           = vendorDataClient.Get(new Vendor {
                Id = request.QueryStringParameters["id"]
            }).Result;
            var customer = qboClient.Query <Customer>($"select * from customer where Id = '{vendor.QuickBooksOnlineId}'").First();

            var json = new CustomerPaymentSettingsModel
            {
                Id = vendor.Id,
                QuickBooksOnlineId = vendor.QuickBooksOnlineId,
                PaymentFrequency   = vendor.PaymentFrequency,
                RentPrice          = vendor.RentPrice,
                Memo        = vendor.Memo,
                FirstName   = customer.GivenName,
                LastName    = customer.FamilyName,
                DisplayName = customer.DisplayName,
                Spots       = vendor.Spots
            };

            response.Body = JsonConvert.SerializeObject(json);
        }