Code Monkey home page Code Monkey logo

campaign-reports's Introduction

Service for pairing requests and invoices

Installation:

There is no need to compile anything. Running

docker network create cvt-oss # just once
docker-compose up --build

will spawn postgres database and setup tables. If you want to go in dev mode, you can then populate it with testing data. admin and testuser will get created and adminadmin is testing password for both of them.

docker exec cvt-oss-web-reports ./manage.py loaddata initial

If you want production variant, use

docker exec -ti cvt-oss-web-reports ./manage.py createsuperuser

instead to create administrator interactively with safe password.

Administration interface is then accessible at http://localhost:8000/admin.

Configuration:

Use campaign_reports/settings.py settings for production or campaign_reports/settings_local.py for development. Most important setting is PDF_ANALYZER_URL which should point to running instance of FB invoice analyzer.

API:

http://localhost:8000/v1/ gives you a browsable API for getting requests and reports.

First you'll want to feed database with some data from parsed invoices. It has to be trigerred by e.g.

http http://127.0.0.1:8000/v1/invoice invoice_id=123

It expects, that PDF analyzer already parsed the PDF and data can be retrieved from there and return this response:

HTTP/1.1 200 OK
Allow: GET, POST, HEAD, OPTIONS
Content-Length: 26
Content-Type: application/json
Date: Sat, 15 Jun 2019 13:35:05 GMT
Server: WSGIServer/0.2 CPython/3.7.3
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN

{
    "analyzer_invoice_id": 1,
    "invoice_id": 5,
    "items": 2
}

If invoice already exists, it is overwritten by new data.

Now you can query reports for merged data from requests and invoices.

http  http://127.0.0.1:8000/v1/invoice/5/
HTTP/1.1 200 OK
Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Length: 282
Content-Type: application/json
Date: Sat, 15 Jun 2019 13:37:39 GMT
Server: WSGIServer/0.2 CPython/3.7.3
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN

{
    "campaigns": [
        {
            "requests": [
                {
                    "id": 3,
                    "approved": true
                }
            ],
            "name": "CampaignName1",
            "price": 1001.86
        },
        {
            "request": [
                {
                    "id": 3,
                    "similarity": 0.608696
                }
            ],
            "name": "CampaignName2",
            "price": 201.97
        }
    ],
    "dt_payment": "2019-01-19T15:56:00Z",
    "id": 5,
    "total": 101.0,
    "transaction_id": "sampleTransactionId"
}

For each campaign you can get following variants:

  1. It contains only one item with 'accepted' field. It means, that it was reviewed and it is 100% match of request and campaign.

  2. It contains 0-10 items ordere by 'similarity' field. It is textual similarity to diffrent requests and has to be reviewed by human.

Note, that you can filter list of all invoices based on dates. So, if you want to see invoices issued in 2019, run

http  'http://127.0.0.1:8000/v1/invoice/?min_date=2019-01-01&max_date=2020-01-01'

campaign-reports's People

Contributors

tkopecek avatar agiertli avatar

Watchers

James Cloos avatar

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.