2
0
mirror of https://github.com/frappe/books.git synced 2024-09-19 19:19:02 +00:00
books/models
Mildred Ki'Lya 2bffcda8ff feat: #755 Accounting for taxes on payments
When defining taxes, it is possible to define an additional payment
account that will be used during payments to move taxes from the
original tax account to this new payment tax account. This allows to
account for taxes only when payment is received.

Now payments can reference tax summary objects that will reference the
two accounts to move funds between when the payment is committed. Reuse
some of the Invoice code to generate these tax summary objects.
2023-12-22 10:07:47 +01:00
..
baseModels feat: #755 Accounting for taxes on payments 2023-12-22 10:07:47 +01:00
inventory fix: expectedAmount calculation 2023-12-04 14:42:57 +05:30
regionalModels/in chore: fix all fixable eslint errors in remaining non vue files 2023-06-22 14:22:54 +05:30
Transactional chore: fix all fixable eslint errors in remaining non vue files 2023-06-22 14:22:54 +05:30
exchangeRate.ts refactor: move ledgerPosting to models 2022-05-23 16:18:22 +05:30
helpers.ts fix(ux): unhide paymentType condition 2023-11-17 12:12:35 +05:30
index.ts feat: pos settings 2023-12-04 14:38:13 +05:30
README.md refactor: rename 'frappe' to 'fyo' outside src 2022-05-23 16:18:22 +05:30
types.ts feat: pos settings 2023-12-04 14:38:13 +05:30

Models

The models root folder contains all the model files, i.e. files containing all the models. Models here, refers to the classes that handle the data, its validation and updation and a bunch of other stuff.

Each model directly or indirectly extends the Doc class from fyo/model/doc.ts so for more info check that file and the associated types in fyo/model/types.ts.

A model class can used even if the class body has no content, for example PurchaseInvoiceItem. Else the model used will default to using Doc. The class can also be used to provide type information for the field types else they default to the catch all DocValue example:

class Todo extends Doc {
  title?: string;
  date?: Date;
  completed?: boolean;
}

While this has obvious advantages, the drawback is if the underlying fieldtype changes this too will have to be changed.

The data stored by the models is decided by the schema passed to it's constructor. Check schemas/README.md for info on this.

Adding Stuff

When adding stuff to models/** make sure that it isn't importing any Vue code or other frontend specific code globally. This is cause model file tests will directly use the the Fyo class and will be run using mocha on node.

Importing frontend code will break all the tests. This also implies that one should be wary about transitive dependencies.

It should also not import the Fyo object (singleton) from src, where ever fyo is required in models it should be passed to it.

Note: Frontend specific code can be imported but they should be done so, only using dynamic imports i.e. await import('...').

Regional Models

Regional models should as far as possible extend the base model and override what's required.

They should then be imported dynamicall and returned from getRegionalModels in models/index.ts on the basis of countryCode.