Commit 5b449b09 by Etienne Freiss

Make old envelop visible

parent d378cd28
Pipeline #1770 failed with stage
in 1 minute 39 seconds
...@@ -111,6 +111,10 @@ class CagetteEnvelops(models.Model): ...@@ -111,6 +111,10 @@ class CagetteEnvelops(models.Model):
def delete_envelop(self, envelop): def delete_envelop(self, envelop):
return self.c_db.delete(envelop) return self.c_db.delete(envelop)
def archive_envelop(self, envelop):
envelop['archive'] = True
return self.c_db.dbc.update([envelop])
def generate_envelop_display_id(self): def generate_envelop_display_id(self):
"""Generate a unique incremental id to display""" """Generate a unique incremental id to display"""
c_db = CouchDB(arg_db='envelops') c_db = CouchDB(arg_db='envelops')
...@@ -172,7 +176,7 @@ class CagetteEnvelops(models.Model): ...@@ -172,7 +176,7 @@ class CagetteEnvelops(models.Model):
else: else:
# Get the oldest check envelops, limited by the number of checks # Get the oldest check envelops, limited by the number of checks
docs = [] docs = []
for item in c_db.dbc.view('index/by_type', key='ch', include_docs=True, limit=payment_data['checks_nb']): for item in c_db.dbc.view('index/by_type_not_archive', key='ch', include_docs=True, limit=payment_data['checks_nb']):
docs.append(item.doc) docs.append(item.doc)
# If only 1 check to save # If only 1 check to save
......
...@@ -75,8 +75,8 @@ def archive_envelop(request): ...@@ -75,8 +75,8 @@ def archive_envelop(request):
coop_logger.error("Cannot attach payment error message to member : %s", str(e)) coop_logger.error("Cannot attach payment error message to member : %s", str(e))
try: try:
# Delete envelop from couchdb # archive envelop from couchdb
res_envelop = m.delete_envelop(envelop) res_envelop = m.archive_envelop(envelop)
except Exception as e: except Exception as e:
res_envelop = "error" res_envelop = "error"
......
...@@ -53,9 +53,17 @@ class Command(BaseCommand): ...@@ -53,9 +53,17 @@ class Command(BaseCommand):
byTypeMapFunction = '''function(doc) { byTypeMapFunction = '''function(doc) {
emit(doc.type); emit(doc.type);
}''' }'''
byTypeNotArchiveMapFunction = '''function(doc) {
if(doc.archive != true){
emit(doc.type);
}
}'''
views = { views = {
"by_type": { "by_type": {
"map": byTypeMapFunction "map": byTypeMapFunction
},
"by_type_not_archive": {
"map": byTypeNotArchiveMapFunction
} }
} }
self.createView(dbConn, "index", views) self.createView(dbConn, "index", views)
......
...@@ -39,6 +39,18 @@ ...@@ -39,6 +39,18 @@
</div> </div>
</section> </section>
<section id="archive_cash">
<h2 class="txtcenter">Enveloppes de liquide archivées</h2>
<div id="archive_cash_envelops" class="flex-container flex-column-reverse">
</div>
</section>
<section id="archive_ch">
<h2 class="txtcenter">Enveloppes de chèques archivées</h2>
<div id="archive_ch_envelops" class="flex-container flex-column-reverse">
</div>
</section>
</section> </section>
<div id="templates" style="display:none;"> <div id="templates" style="display:none;">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment