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):
def delete_envelop(self, 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):
"""Generate a unique incremental id to display"""
c_db = CouchDB(arg_db='envelops')
......@@ -172,7 +176,7 @@ class CagetteEnvelops(models.Model):
else:
# Get the oldest check envelops, limited by the number of checks
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)
# If only 1 check to save
......
......@@ -27,7 +27,7 @@ def archive_envelop(request):
res_envelop = ""
envelop = json.loads(request.body.decode())
# save each partner payment
for partner_id in envelop['envelop_content']:
# If payment_id in payment details: payment already saved. Skip saving.
......@@ -75,8 +75,8 @@ def archive_envelop(request):
coop_logger.error("Cannot attach payment error message to member : %s", str(e))
try:
# Delete envelop from couchdb
res_envelop = m.delete_envelop(envelop)
# archive envelop from couchdb
res_envelop = m.archive_envelop(envelop)
except Exception as e:
res_envelop = "error"
......
......@@ -53,9 +53,17 @@ class Command(BaseCommand):
byTypeMapFunction = '''function(doc) {
emit(doc.type);
}'''
byTypeNotArchiveMapFunction = '''function(doc) {
if(doc.archive != true){
emit(doc.type);
}
}'''
views = {
"by_type": {
"map": byTypeMapFunction
},
"by_type_not_archive": {
"map": byTypeNotArchiveMapFunction
}
}
self.createView(dbConn, "index", views)
......
......@@ -39,6 +39,18 @@
</div>
</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>
<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