Y
Y
Yermek2019-08-22 07:05:11
Django
Yermek, 2019-08-22 07:05:11

How to organize accounting in django?

Hello! I am learning Django. Tutorial at office. site passed. Now I understand myself :)
I do the following: I want to implement a system for accounting for goods. Goods can be bought, capitalized from surplus, moved between warehouses, sold, written off in short supply.
Accordingly, there are models Good, Stock with one field name (char) for directories.
Documents consist of two models:
Document

  • date: DateTime
  • number: Char
  • stock: ForeignKey(Stock)

DocumentString
  • document: ForeignKey(Document)
  • good: ForeignKey(Good)>
  • count: Float
  • price: float
  • sum: Float

In order not to analyze a bunch of documents for reports, all goods movements should be displayed in one table, Register , where receipts and expenses are recorded. Actually, here I have a gag:
I can’t decide how best to link the document and register tables:
Option 1:
When using the ManyToMany link from the document, when overwriting the document, you must delete old motion records and create new ones, but the clear method only removes links, while not deleting the entries themselves from the register. Here I see the following actions:
  1. Override the document's save method. In him:
  2. Pull out the id of all register entries into an array
  3. Clear links using the Clear method
  4. Find all records from the register by id
  5. Delete them with the delete method
  6. Add new records according to document data

Option 2
  1. Add 2 fields to the register table: doc_type : Char, doc_id : int
  2. Override the document's save method. In him:
  3. Find all entries in Register resp. current document
  4. Delete them with the delete method
  5. Add new records according to document data

I ask the community to suggest, and if it's not difficult with arguments, which method is better, or advise another option

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Guest007, 2019-08-22
@Guest007

Let this same Register keep records of the movement of goods. Each of its records is an indication of what goods were moved, from where they moved and where. Well, the date / time and who moved it can also be added.
Everything. Register turns out such a log of events. There is no need to delete anything from there. There is no need to edit the post after the fact. These are the basics of accounting. You can always look at the analytics by product, by warehouse, by time (and by the person in charge, if that).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question