source: rattail/rattail/db/model/batch/purchase.py @ 30538df

custorders
Last change on this file since 30538df was 30538df, checked in by Lance Edgar <ledgar@…>, 4 years ago

Overhaul the new batch framework...

Now rattail.batch is the home of all batch handler logic, and
rattail.db.model.batch is where all the models live. Lots of
related changes too...

  • Property mode set to 100644
File size: 2.5 KB
Line 
1# -*- coding: utf-8 -*-
2################################################################################
3#
4#  Rattail -- Retail Software Framework
5#  Copyright © 2010-2016 Lance Edgar
6#
7#  This file is part of Rattail.
8#
9#  Rattail is free software: you can redistribute it and/or modify it under the
10#  terms of the GNU Affero General Public License as published by the Free
11#  Software Foundation, either version 3 of the License, or (at your option)
12#  any later version.
13#
14#  Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
15#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16#  FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for
17#  more details.
18#
19#  You should have received a copy of the GNU Affero General Public License
20#  along with Rattail.  If not, see <http://www.gnu.org/licenses/>.
21#
22################################################################################
23"""
24Models for purchase order batches
25"""
26
27from __future__ import unicode_literals, absolute_import
28
29import sqlalchemy as sa
30from sqlalchemy.ext.declarative import declared_attr
31
32from rattail.db.model import Base, PurchaseBase, PurchaseItemBase, BatchMixin, BatchRowMixin
33
34
35class PurchaseBatch(BatchMixin, PurchaseBase, Base):
36    """
37    Hopefully generic batch used for entering new purchases into the system, etc.?
38    """
39    batch_key = 'purchase'
40    __tablename__ = 'purchase_batch'
41    __batchrow_class__ = 'PurchaseBatchRow'
42
43    @declared_attr
44    def __table_args__(cls):
45        return cls.__batch_table_args__() + cls.__purchase_table_args__()
46
47    complete = sa.Column(sa.Boolean(), nullable=True, doc="""
48    Flag to indicate whether the batch is complete.  This may be used to assist
49    with workflow when entering/executing new purchases.
50    """)
51
52
53class PurchaseBatchRow(BatchRowMixin, PurchaseItemBase, Base):
54    """
55    Row of data within a purchase batch.
56    """
57    __tablename__ = 'purchase_batch_row'
58    __batch_class__ = PurchaseBatch
59
60    @declared_attr
61    def __table_args__(cls):
62        return cls.__batchrow_table_args__() + cls.__purchaseitem_table_args__()
63
64    STATUS_OK                           = 1
65    STATUS_PRODUCT_NOT_FOUND            = 2
66    STATUS_COST_NOT_FOUND               = 3
67    STATUS_CASE_QUANTITY_UNKNOWN        = 4
68
69    STATUS = {
70        STATUS_OK                       : "ok",
71        STATUS_PRODUCT_NOT_FOUND        : "product not found",
72        STATUS_COST_NOT_FOUND           : "product found but not cost",
73        STATUS_CASE_QUANTITY_UNKNOWN    : "case quantity not known",
74    }
Note: See TracBrowser for help on using the repository browser.