Revision 68b991bc snf-astakos-app/astakos/quotaholder/commission.py

b/snf-astakos-app/astakos/quotaholder/commission.py
38 38

  
39 39
    @staticmethod
40 40
    def assertions(holding):
41
        assert(holding.imported_min <= holding.imported_max)
41
        assert(holding.usage_min <= holding.usage_max)
42 42

  
43 43
    @classmethod
44 44
    def _prepare(cls, holding, quantity, check=True):
......
80 80

  
81 81
    @classmethod
82 82
    def _prepare(cls, holding, quantity, check=True):
83
        imported_max = holding.imported_max
84
        new_imported_max = imported_max + quantity
83
        usage_max = holding.usage_max
84
        new_usage_max = usage_max + quantity
85 85

  
86 86
        limit = holding.limit
87
        if check and new_imported_max > limit:
87
        if check and new_usage_max > limit:
88 88
            holder = holding.holder
89 89
            resource = holding.resource
90 90
            m = ("%s has not enough capacity of %s." % (holder, resource))
......
92 92
            raise NoCapacityError(m,
93 93
                                  provision=provision,
94 94
                                  limit=limit,
95
                                  usage=imported_max)
95
                                  usage=usage_max)
96 96

  
97
        holding.imported_max = new_imported_max
97
        holding.usage_max = new_usage_max
98 98
        holding.save()
99 99

  
100 100
    @classmethod
101 101
    def _finalize(cls, holding, quantity):
102
        holding.imported_min += quantity
102
        holding.usage_min += quantity
103 103
        holding.save()
104 104

  
105 105

  
......
107 107

  
108 108
    @classmethod
109 109
    def _prepare(cls, holding, quantity, check=True):
110
        imported_min = holding.imported_min
111
        new_imported_min = imported_min - quantity
110
        usage_min = holding.usage_min
111
        new_usage_min = usage_min - quantity
112 112

  
113
        if check and new_imported_min < 0:
113
        if check and new_usage_min < 0:
114 114
            holder = holding.holder
115 115
            resource = holding.resource
116 116
            m = ("%s attempts to release more %s than it contains." %
......
118 118
            provision = cls.provision(holding, quantity, importing=False)
119 119
            raise NoQuantityError(m,
120 120
                                  provision=provision,
121
                                  available=imported_min)
121
                                  available=usage_min)
122 122

  
123
        holding.imported_min = new_imported_min
123
        holding.usage_min = new_usage_min
124 124
        holding.save()
125 125

  
126 126
    @classmethod
127 127
    def _finalize(cls, holding, quantity):
128
        holding.imported_max -= quantity
128
        holding.usage_max -= quantity
129 129
        holding.save()
130 130

  
131 131

  

Also available in: Unified diff