Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header DefaultPriceTypeCode isn't used when no PriceTypeCode found in Product #4

Closed
rlee-uls opened this issue Feb 12, 2021 · 5 comments

Comments

@rlee-uls
Copy link

rlee-uls commented Feb 12, 2021

Hello jaerith,

First off, i want to thank you for this amazing project. It has made parsing ONIX legacy and 3.0 files with ease. I've had to make some additions to the ONIX 3 parsing, which was easy to do.

I was wondering if you have an idea on how to refer to the header DefaultPriceTypeCode when no PriceTypeCode is found in the Product segment?

For example...

                    bHasUSDPrice =
                        TmpSupplyDetail.OnixPriceList.Any(x => x.HasSoughtPriceTypeCode() && (x.CurrencyCode == "USD"));

Returns false because PriceType is -1...

    public bool HasSoughtPriceTypeCode()
    {
        return CONST_SOUGHT_PRICE_TYPES.Contains(this.PriceType);
    }

Yet, there is a default Price Type in the Header.

Thank you.

@jaerith
Copy link
Owner

jaerith commented Feb 12, 2021

Hi Ordio,

First, thanks for the compliments! They are appreciated, and I'm glad that this project has helped you.

At my work, we don't apply the header defaults automatically to the products. In fact, we apply (i.e., set) the default values conditionally, in a step between initializing the parser and then reading the products. However, I do see your point. For most people, it would probably be beneficial to apply the defaults automatically.

That should be an easy enhancement. When I have some extra hours in the next few days, I'll try to make that change and then update this thread, in order to let you know that it's there.

@rlee-uls
Copy link
Author

Hi Jaerith,

No worries. Take your time.

I have one publisher that sends their data without the price type in the data, and only in the header. For this publisher, I can re-run the data import anytime.

I am curious on how you set the default values conditionally (between initializing the parser and reading the products)?

Thank you!

@jaerith
Copy link
Owner

jaerith commented Feb 16, 2021

Hi Ordio,

I've uploaded some changes that should take care of your problem. You might want to merge them with your fork. Also, you can turn on/off this new code with the optional ShouldApplyDefaults property on the Parser class.

To answer your question, we iterate through the products on a first pass, applying the default values based on conditions. Then, we iterate through the products on a second pass when we need to read them.

Let me know if it works!

@rlee-uls
Copy link
Author

HI Jaerith,

I've updated the changes you've made and everything is updating exactly as it should. Thank you very much!

I was wondering if the same thing will apply to 3.0 as well?

(I also have another question that is partially realted to the header, but not to this... is there another way for me to contact you?)

Thank you.

@jaerith
Copy link
Owner

jaerith commented Feb 17, 2021

Hi Ordio,

Yes, default values should be applied in the case of 3.0 files as well.

Generally, I like the questions to be here, so that other users can find them (along with the answers). But, yes, you can send questions to my email address. I'd rather not post the actual email address here, but I will give a tip: you can usually find the email address of anyone on Github through the API call:

https://api.github.com/users/{user}/events/public

I've reached out and made connections to a few people that way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants