Comments (10)
OK sounds good. I'll write up some tests and submit a pull request. Thanks for the fast responses.
from quickbooks-sync.
That is the magic code. The OwnerID of zero is reserved for custom fields. If you wanted to make it private data, you would use a GUID here, like this:
Yay for magic! Everybody loves magic. The types are controlled by the XML definition. Obviously, intuit likes to not follow it. I have changed it in the past, that's where we should start. I'll see how easy this one is.
from quickbooks-sync.
Leave it to Intuit, lol.
Would it be possible to add custom serialization to those properties instead, so it can serialize Guid.Empty
to "0" instead of {00000000-0000-0000-0000-000000000000}
?
from quickbooks-sync.
OK, I did another hack that didn't require changing the property type on the XSD generated types. I only did simple testing again, but your unit tests do pass, by modifying the GUIDTYPE
class with some "magic zero" handling:
public partial class GUIDTYPE : ITypeWrapper, IComparable<GUIDTYPE>, IXmlSerializable
{
protected Guid value;
// Support for Intuit's "magic code" for OwnerID of "0"
private bool _magicZero;
public GUIDTYPE()
{
this.value = Guid.Empty;
}
public GUIDTYPE(string value)
{
this.value = Parse(value);
if (value == "0") _magicZero = true;
}
public GUIDTYPE(Guid value)
{
this.value = value;
}
public override string ToString()
{
if (_magicZero && value == Guid.Empty)
{
return "0";
}
return value.ToString("B", CultureInfo.InvariantCulture);
}
public Guid ToGuid()
{
return value;
}
//...
public void ReadXml(System.Xml.XmlReader reader)
{
reader.MoveToContent();
var isEmptyElement = reader.IsEmptyElement;
reader.ReadStartElement();
if (!isEmptyElement)
{
var str = reader.ReadContentAsString();
_magicZero = str == "0";
value = Parse(str);
reader.ReadEndElement();
}
}
//...
}
With simple usage request.OwnerID = new [] { new GUIDTYPE("0") };
In theory, this would then still allow the same functionality in all other purposes, even still allowing {00000000-0000-0000-0000-000000000000}
to be parsed without then outputting "0", but I'm obviously not as familiar with the rest of your library to know what ramifications this might have.
from quickbooks-sync.
I think that's a good alternative, do you think you can submit a pull request with some unit tests?
from quickbooks-sync.
This could arguably be simpler by always returning 0
for Guid.Empty. Do you have any insight on if that would cause issues for other uses of GUIDTYPE
?
from quickbooks-sync.
I looked at all the usage of OwnerId and ... it's hard to tell how it should behave. Their documentation here: https://developer-static.intuit.com/qbSDK-current/Common/newOSR/index.html says
A GUIDTYPE value can be zero (0), or it can take the form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} where X is a hexadecimal digit. For example: {6B063959-81B0-4622-85D6-F548C8CCB517}
Now technically, 00000000-0000-0000-0000-000000000000 is a valid guid. So I think we should allow it. Especially if people started to use it, then we would break them.
So your magicZero idea code is a good idea.
from quickbooks-sync.
Make sure to not drop curling braces to keep consistency :)
from quickbooks-sync.
Pull request #27 made
from quickbooks-sync.
Merged.
Thanks!
from quickbooks-sync.
Related Issues (20)
- InvoiceAdd.InvoiceLineAdd items being reordered HOT 4
- Parsing amounts incorrectly from string to decimal HOT 18
- SoapCore 0.9.9 is not compatible with .NET core 3.1 HOT 3
- How can i Iterator for JournalEntryAddRqType. HOT 3
- Tracking iterator progress HOT 4
- Common Interfaces HOT 11
- Unexpected keys in EmployeePayrollInfo causing issues deserializing HOT 5
- Support QBXml 14. HOT 11
- Add support for Nullable=enable
- Upgrade to QbSync 2.3.0 causes MissingMethodException HOT 8
- Payment receipt template returns `true` for template type HOT 4
- decimal precision in QUANTYPE HOT 6
- QuickBooks Sync does not work with .NET 7 HOT 9
- Unable to add a new Application to the Web Connector in 3.1.0 HOT 21
- SONumber HOT 6
- XmlCodeExporter Missing HOT 1
- Authenticator Null Reference HOT 5
- UnitOfMeasureUnit is missing from ColDesc in reports.
- Upgrade from old version HOT 2
- Rate or RatePercent not being set on SalesOrderLineRet
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quickbooks-sync.