Skip to content

Commit

Permalink
Royalty calculation (#28)
Browse files Browse the repository at this point in the history
Royalty calculation added
  • Loading branch information
matijakolaric committed Jun 17, 2020
1 parent 86febad commit 0da0b5e
Show file tree
Hide file tree
Showing 19 changed files with 1,267 additions and 49 deletions.
4 changes: 2 additions & 2 deletions dmp_project/settings.py
Expand Up @@ -93,7 +93,6 @@

USE_TZ = True


STATIC_URL = os.getenv('STATIC_URL', '/static/')

STATIC_ROOT = os.getenv('STATIC_ROOT', os.path.join(BASE_DIR, 'static'))
Expand All @@ -116,7 +115,8 @@
for row in reader),
key=lambda row: row[1])


LOGIN_URL = '/login/'

DATA_UPLOAD_MAX_NUMBER_FIELDS = None

# The name of the publisher. Use no comma in the name!
Expand Down
7 changes: 7 additions & 0 deletions dmp_project/static/admin/js/papaparse.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions dmp_project/urls.py
Expand Up @@ -16,10 +16,12 @@
from django.contrib import admin
from django.urls import path
from django.conf import settings
from music_publisher.royalty_calculation import RoyaltyCalculationView

urlpatterns = [
# admin moved to root
path('', admin.site.urls),
path('royalty_calculation/', RoyaltyCalculationView.as_view(), name='royalty_calculation'),
]

admin.site.site_header = settings.PUBLISHER_NAME
Expand Down
5 changes: 4 additions & 1 deletion docs/conf.py
Expand Up @@ -100,7 +100,10 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_extra_path = ['googleb5723862796807b2.html']
html_extra_path = [
'googleb5723862796807b2.html',
'work_import_template.csv'
]

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
Expand Down
5 changes: 3 additions & 2 deletions docs/manual.rst
Expand Up @@ -15,11 +15,12 @@ For version *20.7 Endemic*.
manual_writers
manual_cwr
manual_ack
manual_dataimport
manual_royaltycalculations
manual_recordings
manual_labels
manual_artists
manual_labels
manual_releases
manual_libraries
manual_dataimport


58 changes: 33 additions & 25 deletions docs/manual_dataimport.rst
@@ -1,8 +1,7 @@
Importing Data
==============================

Simple musical works can be imported from a CSV file. This advanced functionality is considered
**experimental**.
Simple musical works can be imported from a CSV file.

Caveats
-------------------
Expand All @@ -12,64 +11,73 @@ _______________________

Data imports should not be regarded as a part of the standard work flow and should not be performed by
staff users.
Many failsafes, present during the manual data input and editing, are not available during data imports.
Therefore, the default user groups ``Publishing Staff`` and ``Publishing Audit`` don't allow importing.

There is no way to undo a successful import other than by restoring your database from a
backup. If you don't know how to back up and restore your database, do not import data!
Failsafes, present during the manual data input and editing, may not be available during data imports.

.. warning:: There is no way to undo a successful import other than by restoring your database from a backup. If you don't know how to back up and restore your database, do not import data!

What is being imported?
_______________________

The import process will *add* works, including alternative titles, writers, artists, libraries
and library releases.

No data is changed, with only one exception. A general agreement for an existing writer may be set and a
society-assigned agreement number may be added.
No data is ever *modified*, with only one exception. A general agreement for an existing writer may be
set and a society-assigned agreement number may be added.

Why are errors reported?
_________________________

If data in the file is incomplete or conflicting with data in the database (or other data in the
same file), an error will be thrown. Not all errors are returned in a user-friendly way.
same file), an error will be thrown. Not all errors shown in a user-friendly way.

When an error is thrown, no changes to the database occur.
.. note:: When an error is thrown, no changes to the database occur.

Work IDs
________

The template contains ``Work ID`` column. If you never gave your works your own IDs, leave this blank.
The template contains ``Work ID`` column. If you never assigned IDs to works, leave this blank.
The system will generate work IDs. Note that this is *not* the ID given by your society or any third party.

On the other hand, work IDs must be maintained when moving from one software to another. Failing to do so
may overwrite your existing registrations at collecting societies or create duplicates.

.. warning:: Not assigning work IDs when required will lead to double registrations and other issues.

.. warning:: Assigning wrong work IDs will lead to registrations cancelling each other.

How to import?
------------------------------

Creating a template
______________________________
Obtaining and extending the template
__________________________________________________

First, you are advised to create a template. To do that, export several works as CSV,
as described in :ref:`exporting_csv`.
Download `CSV Template <work_import_template.csv>`_.
You can edit it in Excel or another spreadsheet tool.

Open the file in your spreadsheet editor and save in the native format. Then delete the data and save again.
Use the first file as an example and the second one as a template.
It contains 4 columns for alternate titles, as well as
4 column sets for writers and 4 column sets for artists.

Repeating column groups for alternate titles, writers and artists are created so that the selected data can fit.
You can create additional columns by copying the column group and giving it a different counter.
(Alt Title 1, Alt Title 2, Writer 1, Writer 2, Artist 1, Artist 2). There is no limit to the number of column groups.
For another writer column set, add all of:
``Writer 5 Last``, ``Writer 5 First``, ``Writer 5 IPI``, ``Writer 5 PRO``, ``Writer 5 Role``,
``Writer 5 Share``, ``Writer 5 Controlled``, ``Writer 5 SAAN``

Note that this file has the same form as CSV exports, described in :ref:`exporting_csv`.

Filling out the template
______________________________

Open the spreadsheet template. Fill out the ``Registrations`` sheet. Save this sheet as CSV.
Fill out the template. Make sure to save as CSV.

Values in ``Writer PRO``, ``Writer Role`` and ``Writer Controlled`` columns must start with correct codes.

``Writer PRO`` must start with society code without the leading zero.
``10``, ``10 ASCAP``, ``10 - ASCAP`` or ``10 - BMI`` will all resolve as ASCAP. ``ASCAP`` without the code
will throw an error.

``Writer Role`` must start with one of ``C``, ``A``, ``CA``, ``AR``, ``TR`` or ``AD``.

Values in ``Writer PRO``, ``Writer Role`` and ``Writer Controlled`` columns must
start with correct codes. ``10``, ``10 ASCAP``, ``10 - ASCAP`` or ``10 - BMI`` will all resolve as ASCAP.
``ASCAP`` without the code will throw an error. You can get all the codes from the source or by creating a CSV export
example, as described before.
``Writer Controlled`` should be set to ``No``, ``Yes`` or ``General``.

Data upload
______________________________
Expand Down
48 changes: 48 additions & 0 deletions docs/manual_royaltycalculations.rst
@@ -0,0 +1,48 @@
Royalty Calculations
==============================

Introduction
-------------------

Publishers receive royalty statements and payments from collective
societies, DSPs, administrators, sub-publishers, etc.

Publishers usually keep only part of the revenues, while the rest is
distribute to clients.

For this, outgoing royalties must be calculated. These calculations are
the basis for outgoing statements and payments.

Django-Music-Publisher is fast and precise in calculating royalties. And
it does only this crucial part. Generation of outgoing royalty statements
can then be performed in more suitable tools, e.g. Excel.

Process overview
-----------------------------------------

A brief overview of the royalty calculation process will be given first.

Incoming CSV file is selected for upload and one of two algorithms is
selected. The visibility and possible options for other fields are
determined.

Preparing the ingoing CSV file
-----------------------------------------

Most of societies and other senders of royalty statements have an option
of sending them in CSV format. Other formats can be converted to CSV.

In some cases, you may wish to filter out some rows. E.g. some publishers
keep all of the revenue they receive for performance, as writers receive
their share through societies. In that case, remove all performance-related
rows from the CSV file.









Royalty cal
2 changes: 1 addition & 1 deletion docs/videos.rst
Expand Up @@ -13,7 +13,7 @@ Music Metadata Basics

<iframe width="704" height="396" src="https://www.youtube-nocookie.com/embed?listType=playlist&list=PLQ3e-DuNTFt9bXFv66UVhNi0hfvhgAK8x" frameborder="0" allowfullscreen="1">&nbsp;</iframe>

Total playlist duration is around 10 minutes.
Total playlist duration is around 20 minutes.


Music Publishing
Expand Down
1 change: 1 addition & 0 deletions docs/work_import_template.csv
@@ -0,0 +1 @@
"Work ID","Work Title","ISWC","Original Title","Library","CD Identifier","Alt Title 1","Alt Title 2","Alt Title 3","Alt Title 4","Writer 1 Last","Writer 1 First","Writer 1 IPI","Writer 1 PRO","Writer 1 Role","Writer 1 Share","Writer 1 Controlled","Writer 1 SAAN","Writer 2 Last","Writer 2 First","Writer 2 IPI","Writer 2 PRO","Writer 2 Role","Writer 2 Share","Writer 2 Controlled","Writer 2 SAAN","Writer 3 Last","Writer 3 First","Writer 3 IPI","Writer 3 PRO","Writer 3 Role","Writer 3 Share","Writer 3 Controlled","Writer 3 SAAN","Writer 4 Last","Writer 4 First","Writer 4 IPI","Writer 4 PRO","Writer 4 Role","Writer 4 Share","Writer 4 Controlled","Writer 4 SAAN","Artist 1 Last","Artist 1 First","Artist 1 ISNI","Artist 2 Last","Artist 2 First","Artist 2 ISNI","Artist 3 Last","Artist 3 First","Artist 3 ISNI","Artist 4 Last","Artist 4 First","Artist 4 ISNI"
17 changes: 17 additions & 0 deletions music_publisher/migrations/0006_auto_20200615_1026.py
@@ -0,0 +1,17 @@
# Generated by Django 3.0.6 on 2020-06-15 10:26

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('music_publisher', '0005_work__work_id'),
]

operations = [
migrations.AlterModelOptions(
name='work',
options={'ordering': ('-id',), 'permissions': (('can_process_royalties', 'Can perform royalty calculations'),), 'verbose_name': 'Musical Work'},
),
]
1 change: 1 addition & 0 deletions music_publisher/models.py
Expand Up @@ -450,6 +450,7 @@ class Work(TitleBase):
class Meta:
verbose_name = 'Musical Work'
ordering = ('-id',)
permissions = (('can_process_royalties', 'Can perform royalty calculations'),)

_work_id = models.CharField(
'Work ID', max_length=14, blank=True, null=True, unique=True,
Expand Down

0 comments on commit 0da0b5e

Please sign in to comment.