GithubHelp home page GithubHelp logo

eggheadgames / app_earnings Goto Github PK

View Code? Open in Web Editor NEW
9.0 9.0 6.0 196 KB

Process Google Play, Amazon Android app store csv report files into a text json summary by application and in-app purchase.

License: MIT License

Ruby 100.00%

app_earnings's People

Contributors

andrehjr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

app_earnings's Issues

validate that Amazon Report and Payment file cover the same date ranges

Currently it's possible to run:

app_earnings amazon EarningsReport-Mar-1-2014-Mar-31-2014.csv PaymentReport-Mar-1-2014-April-4-2014.csv

And get ouput that seems plausible. However, there are no payments in the PaymentReport that match dates in the EarningsReport. Please fail with a message saying that the dates don't match (and what dates they are) as this is a point of frequent confusion. E.g. an error like:

Incompatible data ranges. The file EarningsReport-Mar-1-2014-Mar-31-2014.csv summary has dates from 3/1/2014,3/31/2014. The PaymentReport-Mar-1-2014-April-4-2014.csv has dates from 2/1/2014,2/28/2014.

This should be easy to detect using the Summary section of the Payment report.

Yoko

  • Earn money online app

Amazon refund amount not handled

In my latest EarningsReport, I have a refund amount in GBP, like this:

Amazon.co.uk,3/1/2014,3/31/2014,"1234",-2,99.99,GBP,(1.67),GBP,0.00,GBP,98.32,GBP

The final amount in my report is off by the exactly the amount of 1.67 GBP when converted at the exchange rate given in the corresponding PaymentReport. It appears that the refunds column is being ignored completely in this scenario and hence the total doesn't match at the end. (Interestingly, perhaps, there are 2 refunds mentioned in the report details, but again, perhaps they aren't being calculated? Not sure ...)

Handle missing `Product id` and `Sku id` codes in Google reports

As of Feb/March 2017, Google Play Payment reports are missing the Product id and Sku id fields. This is only for lines where the sales report code starts with "GPA".

The lack of these fields makes generating Google Play reports either fail outright, or not attribute all sales correctly.

I've worked around this as follows:

  1. Create a list of product ids & sku ids from a previous play report as follows:
    a. install csvkit - https://csvkit.readthedocs.io/en/749/
    b. run the following command on a previous play report file that has all possible products and skus:
grep -v GPA PlayApps_xxxxxx.csv | 
csvcut -c 7,8,10 | 
sort -u | 
grep -v "Product Title" | 
sed -e '1s/^/Product Title,Product id,Sku id\'$'\n/' >map-names.csv
  1. Hack the source code of app_earnings/google_play/parse.rb so it reads as follows:
require 'csv'

module AppEarnings::GooglePlay
  # Converts a csv file to a hash.
  class Parser
    attr_accessor :file_name

    def initialize(file_name)
      load_fixup
      @file_name = file_name
    end

    def extract
      @extracted_data = []
      options = { headers: true, header_converters: :symbol }

      CSV.foreach(@file_name, options) do |row|
        hash_row = row.to_hash
        hash_row = do_fixup(hash_row) if hash_row[:product_id].nil?
        @extracted_data << hash_row
      end
      @extracted_data
    end

    def load_fixup
      @fixup_table = []
      options = { headers: true, header_converters: :symbol }

      CSV.foreach("map-names.csv", options) do |row|
        @fixup_table << row.to_hash
      end
    end

    def do_fixup(row)
      fix = @fixup_table.select {|f| f[:product_title] == row[:product_title]}[0]
      row[:product_id] = fix[:product_id]
      row[:sku_id] = fix[:sku_id]
      row
    end
  end
end

That's it.

Hopefully Google stop producing files like this. Otherwise, I'll make an effort to clean this up and merge it into the code in a more elegant fashion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.