Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Cost of Goods Sold (COGS) report.

Cost of Goods Sold (COGS) report.

ismailfarooq1
Shopify Partner
3 0 2

Hi, everyone. I need help working with the Shopify APIs.

Basically, I want to generate (Cost of goods sold) COGS values for a store. I'm fetching all the orders for a store within a specific date. Then for each order, iterating through its products and fetching the variant using variant_id and then using the response from that to fetch inventory item AND then finally getting the cost of the item. The result so far has been perfect but my only problem is that it takes hours to finish the process. How can I speed this up? What are my options? Is there an easier way to generate a COGS report?

Replies 7 (7)

CloudlabSam
Shopify Partner
591 47 103

Why not use one of the many reporting apps available?

ismailfarooq1
Shopify Partner
3 0 2

Because we're creating a custom reporting application that's very specific. Also, because it's paid lol. We also don't have a Shopify Plus or Advanced to use the reporting features from Shopify.

 

CloudlabSam
Shopify Partner
591 47 103

The reporting apps are around $9/month and are completely customizable. You will spend hundreds of hours creating something yourself and end up with 5% of the capabilities. 

ismailfarooq1
Shopify Partner
3 0 2

I've already created a program that gets the COGS and it wasn't that difficult, to be honest, took around 19-20 hours. Regardless, I was hoping for a free solution since our custom app handles around 15 different accounts. If we bought a reporting add 9$ each it would cost us over 1500$ yearly which I think is alot considering we just need the COGS.

CloudlabSam
Shopify Partner
591 47 103

I guess it depends how much you value your time. Let's say $50/hour as a conservative number - you have already spent $1000. You have one semi-working report that can't be customized without spending more time/money. Most of the apps have a very generous free plan, which might even get you what you need.

 

But to answer your original question, I'd suggest looking at web hooks and storing the information that you are using to report on. Building the report each time will never scale.

HunkyBill
Shopify Partner
4853 60 568

Your approach has a few flaws, but in general, gets you close. If you wanted a cigar though, you'd have to account for a couple of things. Just getting the orders and line items for a date range is not going to be accurate, as you then have to account for refunds and cancellations. Have fun! Once you cull the crap out of those, you'll know precisely the line items that sold. Now you can get those cost prices via the inventory item. But note, you'll never be penny perfect here either, as you are asking for the cost price NOW, and not THEN, when the item sold. And you know how Shopify has no temporal features for inventory. So the fact is, the cost price now, say 72.45 for an item, may have actually been 68.99 back when the item sold. But you won't know that. So your COGS report is at best, a general exercise. Which, for the most part, is all anyone cares about.

If you wanted to do it faster, you likely could leverage some bulk export if you were lucky, but it seems doubtful as they do not nest deep enough.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
CloudlabSam
Shopify Partner
591 47 103

Exactly. These and another 100 things that will make this more difficult than you'd expect. The reporting apps have done all the hard work for you.