Marc,

First of all, thank you for your insights. I'll try to clarify things as
best as I can.

On Mon, Jul 18, 2011 at 7:21 PM, Marc Aymerich <glicer...@gmail.com> wrote:

>
>
> On Mon, Jul 18, 2011 at 10:54 PM, Andre Terra <andrete...@gmail.com>wrote:
>
>> Hello, django-users.
>>
>> I'm in need of some serious help on deciding how to design my next
>> project. Below is my attempt to describe the use case:
>>
>> *USE CASE*
>> I'm writing an accounting app that will be generating unique monthly
>> reports of the revenue results for a list of Accounts (model) in the
>> company.
>>
>> Each Account has a set of instances of Entry (model) with a Decimal value,
>> date and some text, as well as a FK to Account.
>>
>> These entries are uploaded through an (already coded) import function
>> which parses a .csv and, using DSE, inserts 1.5 million rows to the Entry
>> table. These entries also have an FK to Task (model) so I know which import
>> process generated them.
>>
>> Each month I want to allow an admin to pick a set of Accounts to be
>> displayed in the monthly report, which needs to be unique for obvious
>> reasons.
>>
>> *CODE
>> models.py
>> *http://dpaste.com/hold/570933/
>>
>> *example .csv file to be imported* (importing the file is already coded
>> and works 100% so far)*
>> *http://dpaste.com/hold/570934/*
>> *
>> *QUESTIONS*
>
> 1. Should I create another model named MonthlyReport with an M2M relation
>> to Accounts, and then add an 'is_active' flag so I know which one is the
>> official monthly report?
>
>
> Hi Andre, Could you elaborate a little more about the monthly reports?
> The admin pick up some arbitrary number of accounts and the app generates a
> global report for those accounts? or it should generate a discret report for
> each account?
>

Currently, there are about 200 accounts, but the entries for every month
only refer to a subset of them (about 50 each month). However, the entries
can refer to accounts that weren't referenced on the previous months,
including new accounts. Moreover, even though the entries refer to say, 50
accounts, the admin might only want to show the report for 40, or perhaps
display an extra account (that didn't get imported) with a hard coded value.
They might also want to manually enter a value for any account, if, for
example, something was missing in the original .csv or if the total value
was wrong.

Monthly Account values are derived from a sum of all the entries' values
that have an FK to that account in a given month.

Entries are 1.5 million rows/month, with small values, and accounts are
referenced hundreds of times in the .csv file, with the same date, user and
sometimes text. The value can vary, but not necessarily. So I do some
aggregation in the entries to get the account value.

These accounts are "groups" of entries that for accounting purpose have been
given a code. Think of it as a way of grouping different account
payables/receivables, so you have, say code M1023910240 for "subscriptions"
(+), D102512509 for "discounts" (-), M91212050592 for "SMS usage".


>
> 2. If so, how can I ensure there's only one official monthly report?
>> Perhaps setting is_active to False to all the other MonthlyReports that
>> carry the same month/year?
>>
>
>  what's the difference between "official monthly report" and  "unofficial"
> monthly record?
>

I wanted admins to be able to draft the report and have a final, published
report to go on the main page (this one would need to be unique for
month/year), so that they can switch back and forth between versions.


>
>> 3. How should I prevent users from importing the Entries more than once?
>> Forcing a deletion of entries for the same month as the imported entries is
>> a possible solution.. The .csv file should always be restricted to a single
>> month, but I guess I could write a check for that too, or expand the
>> deletion for every matching month.
>
>
> As you say, when a user upload a csv file you could check if your db
> already contains entries for the same month and if so, display a
> confirmation page warning the user that someone already uploaded the csv for
> the current month and if it's ok to delete the entries of the previous
> importat. (show some details: user/date/csv version|name/#entries and so on)
> .
>

The problem is I'm supposed to have millions of entries; all with the same
date, thousands for the same Account, hundreds with the same description and
perhaps dozens with the same value. I think I'm going with force-overwrite
for the month, at least for the time being.



Thanks again for your input!


Best regards,
André

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to