Fetch QuickBooks Cash flow report using C# - quickbooks

I want to fetch statement of cash flow reports from Quick Books using C#.
Is there any way (or) any query to fetch reports using Intuit SDK?.

If you are using QBO, refer this sample code in C#-
ReportService reportService = new ReportService(context);
//Date should be in the format YYYY-MM-DD
reportService.accounting_method = "Accrual";
reportService.start_date = "1997-01-01";
reportService.end_date = "2014-12-18";
////reportService.classid = "2800000000000634813";
//reportService.date_macro = "Last Month";
reportService.summarize_column_by = "Month";
List<String> columndata = new List<String>();
columndata.Add("tx_date");
columndata.Add("dept_name");
string coldata = String.Join(",", columndata);
reportService.columns = coldata;
var report1 = reportService.ExecuteReport("GeneralLedger");
Just remember to change the report type and cols based on the docs-
https://developer.intuit.com/docs/0100_accounting/0400_references/reports/cashflow

Related

Is it possible to get the high and low of a stock price during the day over a specific timeframe?

Like the title says, is there a way to get the highs and lows of a stock price during the day after a certain time? There's a way to get the days high and low over a period of time:
=GOOGLEFINANCE("AMZN","high","05/01/2020","05/10/2020","DAILY")
=GOOGLEFINANCE("AMZN","low","05/01/2020","05/10/2020","DAILY")
But what about during the day during a specific time period? For example from 9:12AM PST to 11:23AM PST?
Solution#3 : you can use Alpha Vantage by 2 ways, add-on GSheets or a custom function i.e. :
// mike steelson
var apikey = 'xxxxxxxxxxxxxx'
function getAllDataJSONv2(code) {
var url = 'https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol='+code+'&interval=5min&apikey='+apikey
var data = JSON.parse(UrlFetchApp.fetch(url).getContentText())['Time Series (5min)']
var resultat = []
for (var elem in eval(data)){
resultat.push([elem,eval(data[elem]['1. open']),eval(data[elem]['2. high']),eval(data[elem]['3. low']),eval(data[elem]['4. close']),eval(data[elem]['5. volume'])])
}
return resultat
}
the apikey is free for up to 500 requests a day. https://rapidapi.com/alphavantage/api/alpha-vantage
no, not possible with GOOGLEFINANCE. you can get only the daily value which is usually from 16:00:00
your only other option is to find some website (which doesn't use JavaScript) that holds values you wish for and scrape it into google sheets
Solution1 : You can use Yahoo Finance to retrieve the information you want
function getHistoric(url){
var source = UrlFetchApp.fetch(url).getContentText()
var jsonString = source.match(/(?<=root.App.main = ).*(?=}}}})/g) + '}}}}'
var data = JSON.parse(jsonString).context.dispatcher.stores.HistoricalPriceStore.prices
var result = []
data.forEach(function(elem){
result.push([elem.date,elem.open,elem.high,elem.low,elem.close])
})
return result
}
https://docs.google.com/spreadsheets/d/1Kly5-Vu5jBfrl6xFljdICFJW369X-OCjB22z3Ouzt4Y/copy
Solution#2 : you can build your own data based on yahoo finance https://docs.google.com/spreadsheets/d/1QlqpPkIMjE8_jT6kNME1cLrMmQZ9cSzG-SR2Jjivvqo/edit?usp=sharing
//Mike Steelson
var histo = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('historic')
var code = histo.getRange('B1').getValue()
//put a trigger on historic
function historic(){
if (testDateHour()==true) {histo.appendRow([new Date(),marketPrice(code)])}
}
function marketPrice(code) {
var source = UrlFetchApp.fetch('https://finance.yahoo.com/quote/'+code).getContentText()
var data = JSON.parse(source.match(/(?<=root.App.main = ).*(?=}}}})/g) + '}}}}')
return data.context.dispatcher.stores.StreamDataStore.quoteData[code].regularMarketPrice.raw
}
function testDateHour(){
var d = new Date();
// not on sunday and saturday and between 10am and 4pm
if (d.getDay()!=0 && d.getDay()!=6 && d.getHours()>=10 && d.getHours()<=16) {return true}else{return false}
}
Configure your local settings (PST) + update if necessary the period when you want to retrieve the information. Then put the trigger (1min)

Send an invitation to attendees' email through Spreadsheet and Google Calendar API

First of all, I don't have any coding knowledge/background, so I don't know if it is appropriate to ask for advices here, and also this is my first post here. I usually look for some codes on the internet that could find my needs, update it to fit my data and done.
So, right now I am setting a shared platform in my organization to allow people to register as either a presenter or participant of sharing sessions.
The session are all pre-created, and they have to pick in the list. After registering, the data are available in a spreadsheet and I have the code to add these registered person for the sessions.
However my issue is, they are added as guests of the event, but don't receive an invitation for this event. Here is the script:
function Presenterscalendar() {
var cal,i,iCalId,row,sheet,thisEvent,presenter,title,email;
var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName("Presenters");
var dataRange = sheet.getRange("A2:G1000");
var data = dataRange.getValues();
cal = CalendarApp.getDefaultCalendar();
for (i in data) {
row = data[i];
presenter = row[1];
title = row[3];
tstart = row[2];
iCalId = row[4];
email = row[6];
thisEvent = cal.getEventSeriesById(iCalId);
if (thisEvent) {
thisEvent.setTitle(title);
thisEvent.setDescription('A session presented by '+presenter);
thisEvent.addGuest(email)
}
}
}
I looked for other script in order to send the invitations to all attendees of each session in the calendar:
function sendInvite(calendarId, eventId, email) {
var calendarId = 'test#test.com';
var vss = SpreadsheetApp.getActive();
var vS = vss.getSheetByName('Presenters');
var dataRange = vS.getRange("A2:H1000");
var data = dataRange.getValues();
for (i in data) {
row = data[i];
presenter = row[1];
title = row[3];
tstart = row[1];
iCalId = row[4];
mail = row[6];
var eventId = vS.getRange("e2:e1000").getValue();
var eid = eventId.split("#")[0]; // Added;
var event = Calendar.Events.get(calendarId, eid);
var attendees = event.attendees;
if(event.attendees) {
event.attendees.push({
email: email
});
} else {
event.attendees = new Array({email:email});
}
event = Calendar.Events.patch(event, calendarId, eid, {
sendupdates: "all"
});
}
}
This works if I just put a static email for ex ({email:"test#google.com"}), but when kept as is it says "missing attendees mail". Eventually, what I would like to is either:
The script to get all the events in the calendar and send the notifications to new attendees registered (update)
The script to get the data from the spreadsheet (where I have in 1 column the email of the attendee -1 row = 1 attendee-) and send the notification to new attendees
I did allow Calendar API for the script and the Google Cloud platform already.
I wonder if you could help me on this, I tried to replicate what I found on the internet, but my limited knowledge on coding doesn't allow me to go further...
Thanks a lot !
The optional query parameters for an event patch are case sensitive
Thus, you need to modify
sendupdates: "all"
to
sendUpdates: "all"

Getting data from database and filtering it by nullable string in ASP.Net MVC and Entity Framwork

I have Computers table in my database and it is sent to controller in view model (vm here).
I send some filter with query string and want to filter Computers table data with these filters which is NOT NULL.
For example:
If producer is sent, filter by producer,
If producer and memoryType is sent, filter by producer and memoryType.
Code:
//GET: Product/notebooks
[Route("Product/Notebooks")]
public ActionResult Notebooks(string producer, string os, string memoryType, string memory, string displayType, string processorType, string ram, string vc)
{
ViewBag.Producer = producer;
ViewBag.OS = os;
ViewBag.MemoryType = memoryType;
ViewBag.Memory = memory;
ViewBag.DisplayType = displayType;
ViewBag.ProcessorType = processorType;
ViewBag.RAM = ram;
ViewBag.VC = vc;
var vm = Methods.Methodss.createHIVM();
return View(vm);
}
createHIVM(); method here and working everywhere:
public static HomeIndexVM createHIVM()
{
ProtelEntities dbProtel = new ProtelEntities();
var phones = dbProtel.Phones.ToList();
var producers = dbProtel.Producers.ToList();
var computers = dbProtel.Computers.ToList();
var sliders = dbProtel.Sliders.ToList();
var contact = dbProtel.Contacts.FirstOrDefault();
var memoryTypes = dbProtel.MemoryTypes.ToList();
var memories = dbProtel.Memories.ToList();
var rams = dbProtel.RAM.ToList();
var cameras = dbProtel.Cameras.ToList();
var displaytypes = dbProtel.DisplayTypes.ToList();
var OS = dbProtel.OS.ToList();
var osversions = dbProtel.OSVersions.ToList();
var proCategories = dbProtel.ProCategory.ToList();
var processorTypes = dbProtel.ProcessorTypes.ToList();
var simTypes = dbProtel.SimTypes.ToList();
var vcCategories = dbProtel.VCCategories.ToList();
var vcSubcategories = dbProtel.VCSubcategories.ToList();
var vcMemories = dbProtel.VCMemories.ToList();
var vm = new HomeIndexVM
{
Computers = computers,
Phones = phones,
Producers = producers,
Sliders = sliders,
Contact = contact,
Cameras = cameras,
VCSubcategories = vcSubcategories,
VCMemories = vcMemories,
VCCategories = vcCategories,
SimTypes = simTypes,
DisplayTypes = displaytypes,
Memories = memories,
MemoryTypes = memoryTypes,
OS = OS,
OSVersions = osversions,
ProCategories = proCategories,
ProcessorTypes = processorTypes,
RAMs = rams
};
return vm;
}
In this case I have tu apply many many if conditionals. I don't know how to deal with it
As the old saying goes. "How do you eat an elephant? The same as everything else, one bite at a time."
You've got a big method with conditions that apply to several lookups. Some conditions will apply to several. So break it up. You won't be doing yourself any favors with class and method names like "Methods" and "Methods.Methodss"
public class EquipmentLookupService
{
private readonly AppDbContext _context = null;
public EquipmentLookupService(AppDbContext context)
{
_context = context ?? throw new ArgumentNullException("context");
}
public IEnumerable<Computer> GetComputers(string manufacturer, string processor)
{
var query = _context.Computers.AsQueryable();
if(!string.IsNullOrEmpty(manufacturer))
query = query.Where(x => x.Manufacturer == manufacturer);
if(!string.IsNullOrEmpty(processor))
query = query.Where(x => x.Processor == processor);
return query.ToList();
}
}
Then your controller action changes more to something like:
var vm = new HomeIndexVM
{
Computers = EquipmentLookupService.GetComputers(manufacturer, processor),
Phones = EquipmentLookupService.GetPhones(manufacturer),
// etc...
};
return View(vm);
As a very basic starting example. You can create methods to load each type of lookup and add whatever conditions apply to each lookup.
Linq queries can contain conditional statements like:
query = _context.Computers.Where(x => (manufacturer == null || x.Manufacturer == manufacturer) && (processor == null || x.Processor == processor));
which might seem like less code, however I don't recommend using conditional code like this inside Linq expressions. Firstly, it can be much harder to read and can hide logic errors with misplaced parenthesis or operations. Secondly, it gets built down into SQL leading to larger, more complex SQL statements for conditions that simply don't need to be applied. In the previous example, the conditional check is kept in code, so criteria is only added to the generated SQL statements if they are needed.
The key to writing efficient (fast) Linq is to avoid prematurely executing an expression such as doing a ToList() before adding conditions. This ends up returning a lot of unnecessary data from the database to the server, requiring time and memory before the data is filtered.

Passing a value to jasper ireport designer

Since Japersoft ireport designer 5.6.0 doesn't support displaying a current date in arabic (as far as i know), i thought why not create a current arabic date in my application and pass it in my url to jasper ireport designer to display it in the report design in a parameter.
But my solution didn't work, maybe i did something wrong, or there is an alternative solution.
Any help on this please?
var months = ["يناير", "فبراير", "مارس", "إبريل", "مايو", "يونيو",
"يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"];
var days =["اﻷحد","اﻷثنين","الثلاثاء","اﻷربعاء","الخميس","الجمعة","السبت"];
var date = new Date();
var monthAR = months[date.getMonth()];
var dayAR = days[date.getDay()];
var yearAR = date.getFullYear();
var numberAR = date.getDate();
var arabicdate = dayAR+" "+numberAR+" "+monthAR+" "+yearAR;
var arDate = arabicdate;

starttime changes on CalendarRule when I insert it into work hours in CRM

When I submit a CalendarRule to CRM's work hours, the StartTime changes just before it is submitted to the database. I submit the CalendarRule through the code below. The submitted StartTime differ by -2 hours. I suspect this has something to do with the fact that I live in +1 GMT timezone and our clocks are set to dayligt time savings.
var calendarFrequenceRule = new CalendarRule
{
Duration = 24 * 60, //24 hours
ExtentCode = 1,
StartTime = start.Date,
Pattern =
new CalendarRulePattern
{
ByDay = new List<DayOfWeek> {start.DayOfWeek},
Interval = 1,
Frequency = CalendarRulePattern.FrequencyEnum.WEEKLY
}.ToString(),
Rank = 0,
TimeZoneCode = userSettings.TimeZoneCode,
InnerCalendarId = new EntityReference(Calendar.EntityLogicalName, innerCalendarId),
};
calendarRules.Clear();
calendarRules.Add(calendarFrequenceRule);
userCalendarEntity.CalendarRules = calendarRules;
OrganizationService.Update(userCalendarEntity);
var calendarTimeRule = new CalendarRule
{
//Name = name,
//Description = name,
Duration = (int)(end - start).TotalMinutes,
Effort = 1.0,
IsSimple = true,
Offset = (int)(start - start.Date).TotalMinutes,
Rank = 0,
TimeCode = (int)TimeCode.Available,
SubCode = (int)SubCode.Schedulable,
TimeZoneCode = -1,
CalendarId = new EntityReference(Calendar.EntityLogicalName, innerCalendarId),
};
calendarRules.Add(calendarTimeRule);
newInnerCalendar.CalendarRules = new List<CalendarRule> {calendarTimeRule};
OrganizationService.Update(newInnerCalendar);
When I retrieve the time again through the code below the time is off by 4 hours. I've checked that all users have their time zone settings set to the same time zone - but to no avail. When I look at the database I can see that the time zone submitted through code is the same as the calendar rules I've insert through the GUI.
Code to retrieve the CalendarRule:
var user = OrganizationService.Retrieve<SystemUser>(userId);
var expandCalendarRequest = new ExpandCalendarRequest
{
CalendarId = user.CalendarId.Id,
Start = start,
End = end,
};
var response = OrganizationService.Execute<ExpandCalendarResponse>(expandCalendarRequest);
return response.result;
Anytime you insert a DateTime into CRM using the SDK or the Odata endpoint, it assumes that it's UTC. If you update a field via javascript, it will assume it's in the time of the current users. I'm not sure what case you're currently working with, but always work with UTC unless you're editing fields in the actual form.
See this answer: https://stackoverflow.com/a/22787954/227436 for an overview of working with Time in CRM.
This answer has a function that maybe useful in your case as well:
https://stackoverflow.com/a/11367508/227436

Resources