Getting Error In Journal Entry Quickbooks - quickbooks

I am trying to add a journal entry. But it returns like an error
Uncaught IdsException: [0]: 2014-01-29 08:13:07 - D:\DummyApps\v3-php-sdk-2.0.1\v3-php-sdk-2.0.1\DataService\DataService.php - 341 - CheckNullResponseAndThrowException -
Response Null or Empty thrown in D:\DummyApps\v3-php-sdk-2.0.1\v3-php-sdk-2.0.1\Core\CoreHelper.php on line 95'
I am using QuickBooks PHP SDK. My code is below:
// Prep Data Services
$dataService = new DataService($serviceContext);
if (!$dataService)
exit("Problem while initializing DataService.\n");
$linedet = new IPPJournalEntryLineDetail();
$linedet->PostingType = 'Credit';
$linedet->AccountRef = 9;
$line = new IPPLine();
$line->Id = 0;
$line->Description = 'test journal';
$line->Amount = 2.00;
$line->DetailType= 'test ';
$line->JournalEntryLineDetail = $linedet;
$linedet2 = new IPPJournalEntryLineDetail();
$linedet2->PostingType = 'Debit';
$linedet2->AccountRef = 9;
$line2 = new IPPLine();
$line2->Id = 1;
$line2->Description = 'test journal';
$line2->Amount = 2.00;
$line2->DetailType= 'test ';
$line2->JournalEntryLineDetail = $linedet2;
// Add a journal
$journalObj = new IPPJournalEntry();
$journalObj->SyncToken = '1';
$journalObj->DocNumber = '1';
$journalObj->TxnDate = '2014-12-30';
$journalObj->RefNumber = 't123';
$journalObj->PrivateNote = 'Just testing';
$journalObj->Line = array($line, $line2);
$journalObj->Adjustment = TRUE;
$journalObj->IsAdjustment = TRUE;
$resultingObj = $dataService->Add($journalObj );
Please help me....I am stuck here.
Thanks in Advance

I found the error here.
The 'DetailType' in the line object must have 'JournalEntryLineDetail'

Related

How to check if enabling custom invoice numbers results in duplicate invoice Numbers

I am working on integrating quick books with mvc and I have to work on one task which is to check if enabling custom invoice numbers results in duplicate Invoice .
I have tried creating invoice in quick books
public Invoice PostInvoice(InvoiceViewModel model)
{
Intuit.Ipp.Data.Invoice invoice = new Intuit.Ipp.Data.Invoice();
invoice.Deposit = new Decimal(0.00);
invoice.DepositSpecified = true;
invoice.DocNumber = "QBOInvoice" + DateTime.Now.ToString("MMddHHmmss");
invoice.CustomerRef = new ReferenceType { Value = model.qboCustomer.Id };
// invoice.CustomerMemo = new MemoRef { Value = reference };
invoice.DueDate = DateTime.UtcNow.Date;
invoice.DueDateSpecified = true;
invoice.TotalAmtSpecified = true;
invoice.ApplyTaxAfterDiscount = false;
invoice.ApplyTaxAfterDiscountSpecified = true;
invoice.PrintStatus = PrintStatusEnum.NotSet;
invoice.PrintStatusSpecified = true;
invoice.EmailStatus = EmailStatusEnum.NotSet;
invoice.EmailStatusSpecified = true;
invoice.BalanceSpecified = true;
invoice.TxnDate = DateTime.UtcNow.Date;
invoice.TxnDateSpecified = true;
invoice.ShipAddr = model.Address;
invoice.BillAddr = model.Address; //new PhysicalAddress() { Line1 = "BillMohali", Line2 = "Sector 70 ", City = "Mohali", PostalCode = "160071" };
//invoice.ShipAddr = new PhysicalAddress() {Line1="Mohali", Line2="Sector 70 ",City="Mohali",PostalCode="160071" };
//invoice.BillAddr = new PhysicalAddress() { Line1 = "BillMohali", Line2 = "Sector 70 ", City = "Mohali", PostalCode = "160071" };
Intuit.Ipp.Data.Line line = new Intuit.Ipp.Data.Line();
SalesItemLineDetail lineSalesItemLineDetail = new SalesItemLineDetail();
List<Intuit.Ipp.Data.Line> lineList = new List<Intuit.Ipp.Data.Line>();
foreach (var item in model.qbolineitems)
{
lineSalesItemLineDetail = new SalesItemLineDetail();
line = new Intuit.Ipp.Data.Line();
//Line Sales Item Line Detail - ServiceDate
lineSalesItemLineDetail.ServiceDate = DateTime.Now.Date;
lineSalesItemLineDetail.ServiceDateSpecified = true;
lineSalesItemLineDetail.Qty = item.invoiceitem.quantity.Value;
lineSalesItemLineDetail.QtySpecified = true;
lineSalesItemLineDetail.ItemRef = new ReferenceType { Value = item.item.qboItemCode.Value.ToString(), name = item.item.qboItemName };
lineSalesItemLineDetail.AnyIntuitObject = item.invoiceitem.SalePrice.Value / item.invoiceitem.quantity.Value;
lineSalesItemLineDetail.ItemElementName = ItemChoiceType.UnitPrice;
line.AnyIntuitObject = lineSalesItemLineDetail;
line.Description = item.item.qboItemName;
line.Amount = item.invoiceitem.SalePrice.Value;
line.AmountSpecified = true;
// line.Id = item.item.qboItemCode.Value.ToString();
line.DetailType = LineDetailTypeEnum.SalesItemLineDetail;
line.DetailTypeSpecified = true;
//if (_connect.Country == "US")
//{
lineSalesItemLineDetail.TaxInclusiveAmt = item.invoiceitem.SalePrice.Value;
lineSalesItemLineDetail.TaxCodeRef = new ReferenceType { Value = "TAX" };
//}
//else
//{
//_connect = (Connect)Session["Connect"];
// objQBO = new QBOWrapper("jagjeetkr7#gmail.com", Request.Url.GetLeftPart(UriPartial.Authority) + "/Home/Callback", _connect, true);
//var taxcode = objQBO.getTaxCodeList().Where(x => x.Active).FirstOrDefault();
//lineSalesItemLineDetail.TaxCodeRef = new ReferenceType { Value = taxcode.Id };
//var dis = item.invoiceitem.SalePrice.Value / (Convert.ToDecimal(taxcode.SalesTaxRateList.TaxRateDetail[0].TaxRateRef.Value) + 1);
//line.Amount = item.invoiceitem.SalePrice.Value - dis;
//lineSalesItemLineDetail.TaxInclusiveAmt = item.invoiceitem.SalePrice.Value;
lineSalesItemLineDetail.TaxInclusiveAmtSpecified = false;
invoice.GlobalTaxCalculationSpecified = false;
invoice.GlobalTaxCalculation = GlobalTaxCalculationEnum.NotApplicable;
//SendInsideFunctionEmail("Failed to create surcharge invoice for : " + reference, "Please create a surcharge invoice manually and send a receipt to the customer. Also,please assign the tax code for this account selected in qbo.", _generalSettings.AccountsEmail);
// }
lineList.Add(line);
}
//invoice.TotalAmt = new Decimal(0.90);
//invoice.Balance = new Decimal(0.90);
// xlic.Add(li);
invoice.TotalAmt = model.Total;
invoice.Balance = model.BalanceDue;
invoice.Line = lineList.ToArray();
_connect = (Connect)Session["Connect"];
objQBO = new QBOWrapper("jagjeetkr7#gmail.com", Request.Url.GetLeftPart(UriPartial.Authority) + "/Home/Callback", _connect, true);
//objQBO = new QBOWrapper("jagjeetkr7#gmail.com", Request.Url.GetLeftPart(UriPartial.Authority) + "/Home/Callback", _connect, true);
invoice = objQBO.CreateInvoice(invoice);
return invoice;
}
I expect that generating custom invoice numbers results in duplicate invoice but not finding a way to implement that

Set new placement in Group Criterion via API

How can I add new placement (website, for example www.example.com) in AdGroup using AdWords API?
I have found
AdGroupCriterionService->mutate,
but I need to know ID of website
$adGroupCriterion->criterion = new Criterion($criterionId);
So my question:
How I can found ID for any website or exist another way to add new Placement in AdGroup?
I found an answer:
$adGroupService = $user->GetService('AdGroupCriterionService', 'v201509');
$AdGroupCriterionOperation = new AdGroupCriterionOperation();
$AdGroupCriterionOperation->operator = 'ADD';
$AdGroupCriterion = new BiddableAdGroupCriterion();
$AdGroupCriterion->adGroupId = $adGroupId;
$AdGroupCriterion->criterionUse = 'BIDDABLE';
$AdGroupCriterion->AdGroupCriterionType = 'PLACEMENT';
$Placement = new Placement();
$Placement->id = null;
$Placement->CriterionType = 'PLACEMENT';
$Placement->type = 'PLACEMENT';
$Placement->url = $url;
$AdGroupCriterion->criterion = $Placement;
$AdGroupCriterionOperation->operand = $AdGroupCriterion;
$operations = array($AdGroupCriterionOperation);
// Make the mutate request.
$result = $adGroupService->mutate($operations);

error when add multiple OBX segments to NHapi.Model.V25.Group.VXU_V04_ORDER

I am working on creating HL7 VXU V04 type message using NHapi V2.5.
Below is the required message outcome( from NIST site:http://hl7v2-iz-testing.nist.gov/mu-immunization/)
The issue I am running into is how to create four OBX segments("NHapi.Model.V25.Segment.OBX ") and add it to the "NHapi.Model.V25.Group.VXU_V04_ORDER" ?
Below is my code, Line#5 works, it create multiple ORDER but if i try to do the same to create multiple OBSERVATION (Line#8), I get the below error:
"Can't create repetition #1 of Structure OBSERVATION - this Structure is non-repeating"
As per HL7 specifications OBSERVATION is repeating structure, Anyone please help here?
Any pointers or any suggestions are greatly appreciated.
NHapi.Model.V25.Message.VXU_V04 vxuMsg = new VXU_V04();
PipeParser parser = new PipeParser();
for (int i = 0; i < person.Immunizations.Count; i++)
{
NHapi.Model.V25.Group.VXU_V04_ORDER orc = (NHapi.Model.V25.Group.VXU_V04_ORDER)vxuMsg.GetStructure("ORDER", i);
for (int j = 0; j < 2; j++)
{
NHapi.Model.V25.Group.VXU_V04_OBSERVATION observation = (NHapi.Model.V25.Group.VXU_V04_OBSERVATION)orc.GetStructure("OBSERVATION", j);
NHapi.Model.V25.Segment.OBX obx1 = (NHapi.Model.V25.Segment.OBX)obx.GetStructure("OBX");
}
NHapi.Model.V25.Segment.RXA im = orc.RXA;
NHapi.Model.V25.Segment.ORC oc = orc.ORC;
NHapi.Model.V25.Segment.RXR rxr = orc.RXR;
}
Required message outcome
MSH|^~\&|Test EHR Application|X68||NIST Test Iz Reg|201207010822||VXU^V04^VXU_V04|NIST-IZ-001.00|P|2.5.1|||AL|ER
PID|1||D26376273^^^NIST MPI^MR||Snow^Madelynn^Ainsley^^^^L|Lam^Morgan|20070706|F||2076-8^Native Hawaiian or Other Pacific Islander^CDCREC|32 Prescott Street Ave^^Warwick^MA^02452^USA^L||^PRN^PH^^^657^5558563|||||||||2186-5^non Hispanic or Latino^CDCREC
PD1|||||||||||02^Reminder/Recall - any method^HL70215|||||A|20120701|20120701
NK1|1|Lam^Morgan^^^^^L|MTH^Mother^HL70063|32 Prescott Street Ave^^Warwick^MA^02452^USA^L|^PRN^PH^^^657^5558563
ORC|RE||IZ-783274^NDA|||||||I-23432^Burden^Donna^A^^^^^NIST-AA-1||57422^RADON^NICHOLAS^^^^^^NIST-AA-1^L
RXA|0|1|20120814||140^Influenza, seasonal, injectable, preservative free^CVX|0.5|mL^MilliLiter [SI Volume Units]^UCUM||00^New immunization record^NIP001|7832-1^Lemon^Mike^A^^^^^NIST-AA-1|^^^X68||||Z0860BB|20121104|CSL^CSL Behring^MVX|||CP|A
RXR|C28161^Intramuscular^NCIT|LD^Left Arm^HL70163
OBX|1|CE|64994-7^Vaccine funding program eligibility category^LN|1|V05^VFC eligible - Federally Qualified Health Center Patient (under-insured)^HL70064||||||F|||20120701|||VXC40^Eligibility captured at the immunization level^CDCPHINVS
OBX|2|CE|30956-7^vaccine type^LN|2|88^Influenza, unspecified formulation^CVX||||||F
OBX|3|TS|29768-9^Date vaccine information statement published^LN|2|20120702||||||F
OBX|4|TS|29769-7^Date vaccine information statement presented^LN|2|20120814||||||F
Dim vxuMsg As NHapi.Model.V25.Message.VXU_V04 = New VXU_V04()
Dim orc As NHapi.Model.V25.Group.VXU_V04_ORDER = DirectCast(vxuMsg.GetStructure("ORDER", 0), NHapi.Model.V25.Group.VXU_V04_ORDER)
Dim observation As NHapi.Model.V25.Group.VXU_V04_OBSERVATION = orc.GetOBSERVATION(0) 'DirectCast(orc.GetStructure("OBSERVATION", 0), NHapi.Model.V25.Group.VXU_V04_OBSERVATION)
Dim orderobservation As VXU_V04_ORDER = vxuMsg.GetORDER(0)
Dim obx1 As NHapi.Model.V25.Segment.OBX = DirectCast(observation.GetStructure("OBX"), NHapi.Model.V25.Segment.OBX)
obx1 = orderobservation.GetOBSERVATION(0).OBX
obx1.SetIDOBX.Value = "1"
obx1.ValueType.Value = "CE"
obx1.ObservationIdentifier.Identifier.Value = "64994-7"
obx1.ObservationIdentifier.Text.Value = "Vaccine funding program eligibility category"
obx1.ObservationIdentifier.NameOfCodingSystem.Value = "LN"
obx1.ObservationSubID.Value = "1"
Dim ce As New CE(oru01)
ce.Identifier.Value = "V05"
ce.Text.Value = "VFC eligible - Federally Qualified Health Center Patient(under-insured)"
ce.NameOfCodingSystem.Value = "HL70064"
obx1.GetObservationValue(0).Data = ce
obx1.ObservationResultStatus.Value = "F"
obx1.DateTimeOfTheObservation.Time.Value = "20120701"
obx1.GetObservationMethod(0).Identifier.Value = "VXC40"
obx1.GetObservationMethod(0).Text.Value = "Eligibility captured at the immunization level"
obx1.GetObservationMethod(0).NameOfCodingSystem.Value = "CDCPHINVS"
Dim obx2 As NHapi.Model.V25.Segment.OBX = obx1
obx2 = orderobservation.GetOBSERVATION(1).OBX
obx2.SetIDOBX.Value = "2"
obx2.ValueType.Value = "CE"
obx2.ObservationIdentifier.Identifier.Value = "30956-7"
obx2.ObservationIdentifier.Text.Value = "vaccine type"
obx2.ObservationIdentifier.NameOfCodingSystem.Value = "LN"
obx2.ObservationSubID.Value = "2"
Dim ce2 As New CE(oru01)
ce2.Identifier.Value = "88"
ce2.Text.Value = "Influenza, unspecified formulation"
ce2.NameOfCodingSystem.Value = "CVX"
obx2.GetObservationValue(0).Data = ce2
obx2.ObservationResultStatus.Value = "F"
Dim obx3 As NHapi.Model.V25.Segment.OBX = obx1 'DirectCast(observation.GetStructure("OBX"), NHapi.Model.V251.Segment.OBX)
obx3 = orderobservation.GetOBSERVATION(2).OBX
obx3.SetIDOBX.Value = "3"
obx3.ValueType.Value = "TS"
obx3.ObservationIdentifier.Identifier.Value = "29768-9"
obx3.ObservationIdentifier.Text.Value = "Date vaccine information statement published"
obx3.ObservationIdentifier.NameOfCodingSystem.Value = "LN"
obx3.ObservationSubID.Value = "2"
Dim ts3 As New TS(oru01)
ts3.Time.Value = "20120702"
obx3.GetObservationValue(0).Data = ts3
obx3.ObservationResultStatus.Value = "F"

quickbooks online sdk create invoice

I am using the quickbooks sdk to connect with a quickbook online account. I am able to connect a get data like customers and invoice without a problem. But I am unable to create an invoice using the sdk. Here is my code:
$token = unserialize($_SESSION['token']);
$requestValidator = new OAuthRequestValidator(
$token['oauth_token'], $token['oauth_token_secret'], OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);
$realmId = $_SESSION['realmId'];
$serviceType = $_SESSION['dataSource'];
$serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator);
$dataService = new DataService($serviceContext);
//create an invoice
$invoiceObj = new IPPInvoice();
$invoiceObj->CustomerRef = 5;
$invoiceObj->Amount = 12.00;
$invoiceObj->DocNumber = 9999;
$invoiceObj->TaxnDate = "2014-05-01";
$Line = new IPPline();
$Line->DetailType ='SalesItemLineDetail';
//$Line->Amount = 10;
$Line->setDescription = 'Test description goes here.';
$saleItemLineDetail = new IPPSalesItemLineDetail();
$saleItemLineDetail->ItemRef = 1;
$saleItemLineDetail->Quantity = 1;
$saleItemLineDetail->UnitPrice = 10.00;
$line->SalesItemLineDetail = $saleItemLineDetail;
$invoiceObj->Line = $line;
$resultingInvoiceObj = $dataService->Add($invoiceObj);
When a run this an invoice isn't created and I get this error:
Fatal error: Uncaught IdsException: [0]: 2014-05-02 17:26:08 - /home/randy/test_apps/v3-php-sdk-2.0.4/DataService/DataService.php - 340 - CheckNullResponseAndThrowException - Response Null or Empty thrown in /home/randy/test_apps/v3-php-sdk-2.0.4/Core/CoreHelper.php on line 95
I don't think the Line data is getting added correctly. How do I correctly add line data or is it something else?
Thanks
You have to pass customer id as string as follows
$invoiceObj->CustomerRef = 5;
Below is working sample code
Sample Code

delphi ole excel container, save file

what is the syntax for this c++ question in Delphi?
After using an oleContainer, and trying to do SaveDocumentAs which didn't work. I thought this might be a good alternative.
update: thank you for the translation, however the excel file goes curropted after the call
var
ExcelOle: TOleContainer;
begin
ExcelOLE.CreateObjectFromFile(FileName, False);
ExcelOle.OleObject.application.workbooks[1].save;
end;
Simply create an Ole Object:
uses ComObj, Excel;
var Excel: OleVariant;
Excel := CreateOleObject('EXCEL.Application');
Excel.Application.Workbooks.Add;
Excel.Application.Workbooks[1].SaveAs('c:\test.xlsx', xlWorkbookDefault); // or xlOpenXMLWorkbook (51)
Excel.Application.Quit;
Excel.pas
unit Excel;
interface
uses Windows, Activex;
// originally from Excel97.pas
// XlFileFormat constants
type
XlFileFormat = TOleEnum;
const
xlAddIn = $00000012;
xlCSV = $00000006;
xlCSVMac = $00000016;
xlCSVMSDOS = $00000018;
xlCSVWindows = $00000017;
xlDBF2 = $00000007;
xlDBF3 = $00000008;
xlDBF4 = $0000000B;
xlDIF = $00000009;
xlExcel2 = $00000010;
xlExcel2FarEast = $0000001B;
xlExcel3 = $0000001D;
xlExcel4 = $00000021;
xlExcel5 = $00000027;
xlExcel7 = $00000027;
xlExcel9795 = $0000002B;
xlExcel4Workbook = $00000023;
xlIntlAddIn = $0000001A;
xlIntlMacro = $00000019;
xlWorkbookNormal = $FFFFEFD1;
xlSYLK = $00000002;
xlTemplate = $00000011;
xlCurrentPlatformText = $FFFFEFC2;
xlTextMac = $00000013;
xlTextMSDOS = $00000015;
xlTextPrinter = $00000024;
xlTextWindows = $00000014;
xlWJ2WD1 = $0000000E;
xlWK1 = $00000005;
xlWK1ALL = $0000001F;
xlWK1FMT = $0000001E;
xlWK3 = $0000000F;
xlWK4 = $00000026;
xlWK3FM3 = $00000020;
xlWKS = $00000004;
xlWorks2FarEast = $0000001C;
xlWQ1 = $00000022;
xlWJ3 = $00000028;
xlWJ3FJ3 = $00000029;
xlExcel12 =50;
xlExcel8 = 56;
xlHtml = 44;
xlOpenXMLAddIn = 55;
xlOpenXMLTemplate = 54;
xlOpenXMLTemplateMacroEnabled = 53;
xlOpenXMLWorkbook = 51;
xlOpenXMLWorkbookMacroEnabled = 52;
xlTemplate8 = 17;
xlUnicodeText = 42;
xlWebArchive = 45;
xlWorkbookDefault = 51;
xlXMLSpreadsheet = 46;
implementation
end.

Resources