Fixes to the updates for the invpoice processing, Fix is a duplication error for admin_mark_invoice_paid
Release Inventarsystem / release-docker (push) Successful in 2m18s
Release Inventarsystem / release-docker (push) Successful in 2m18s
This commit is contained in:
+6
-7
@@ -93,6 +93,7 @@ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|||||||
import Web.modules.database.settings as cfg
|
import Web.modules.database.settings as cfg
|
||||||
from Web.modules.database.settings import MongoClient
|
from Web.modules.database.settings import MongoClient
|
||||||
from tenant import get_tenant_context, get_tenant_db, get_tenant_trial_status, purge_expired_trial_tenants
|
from tenant import get_tenant_context, get_tenant_db, get_tenant_trial_status, purge_expired_trial_tenants
|
||||||
|
from pymongo.errors import DuplicateKeyError
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__, static_folder='static') # Correctly set static folder
|
app = Flask(__name__, static_folder='static') # Correctly set static folder
|
||||||
@@ -8759,7 +8760,9 @@ def admin_create_invoice(borrow_id):
|
|||||||
def admin_mark_invoice_paid(borrow_id):
|
def admin_mark_invoice_paid(borrow_id):
|
||||||
"""Mark an existing invoice as paid."""
|
"""Mark an existing invoice as paid."""
|
||||||
if 'username' not in session:
|
if 'username' not in session:
|
||||||
flash('Ihnen ist es nicht gestattet auf dieser Internetanwendung, die eben besuchte Adrrese zu nutzen, versuchen sie es erneut nach dem sie sich mit einem berechtigten Nutzer angemeldet haben!', 'error')
|
flash(
|
||||||
|
'Ihnen ist es nicht gestattet auf dieser Internetanwendung, die eben besuchte Adrrese zu nutzen, versuchen sie es erneut nach dem sie sich mit einem berechtigten Nutzer angemeldet haben!',
|
||||||
|
'error')
|
||||||
return redirect(url_for('login'))
|
return redirect(url_for('login'))
|
||||||
|
|
||||||
current_permissions = us.get_effective_permissions(session['username'])
|
current_permissions = us.get_effective_permissions(session['username'])
|
||||||
@@ -8840,8 +8843,8 @@ def admin_mark_invoice_paid(borrow_id):
|
|||||||
|
|
||||||
|
|
||||||
@app.route('/admin/borrowings/<borrow_id>/invoice/pay', methods=['POST'])
|
@app.route('/admin/borrowings/<borrow_id>/invoice/pay', methods=['POST'])
|
||||||
def admin_mark_invoice_paid(borrow_id):
|
def admin_pay_invoice_extended(borrow_id): # <--- HIER GEÄNDERT (Eindeutiger Funktionsname)
|
||||||
"""Mark invoice as paid."""
|
"""Mark invoice as paid and complete borrowing if active."""
|
||||||
if 'username' not in session:
|
if 'username' not in session:
|
||||||
flash('Ihnen ist es nicht gestattet, versuchen sie es erneut nach Anmeldung!', 'error')
|
flash('Ihnen ist es nicht gestattet, versuchen sie es erneut nach Anmeldung!', 'error')
|
||||||
return redirect(url_for('login'))
|
return redirect(url_for('login'))
|
||||||
@@ -8870,7 +8873,6 @@ def admin_mark_invoice_paid(borrow_id):
|
|||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
update_fields = {'LastUpdated': now}
|
update_fields = {'LastUpdated': now}
|
||||||
|
|
||||||
# Rechnung auf bezahlt setzen
|
|
||||||
if invoice_data.get('paid') is not True:
|
if invoice_data.get('paid') is not True:
|
||||||
update_fields.update({
|
update_fields.update({
|
||||||
'InvoiceData.paid': True,
|
'InvoiceData.paid': True,
|
||||||
@@ -8878,14 +8880,12 @@ def admin_mark_invoice_paid(borrow_id):
|
|||||||
'InvoiceData.paid_by': session.get('username', ''),
|
'InvoiceData.paid_by': session.get('username', ''),
|
||||||
})
|
})
|
||||||
|
|
||||||
# Ausleihe abschließen, falls noch aktiv
|
|
||||||
if borrow_doc.get('Status') == 'active':
|
if borrow_doc.get('Status') == 'active':
|
||||||
update_fields['Status'] = 'completed'
|
update_fields['Status'] = 'completed'
|
||||||
update_fields['End'] = now
|
update_fields['End'] = now
|
||||||
|
|
||||||
ausleihungen.update_one({'_id': borrow_doc['_id']}, {'$set': update_fields})
|
ausleihungen.update_one({'_id': borrow_doc['_id']}, {'$set': update_fields})
|
||||||
|
|
||||||
# Logging
|
|
||||||
try:
|
try:
|
||||||
db['system_logs'].insert_one({
|
db['system_logs'].insert_one({
|
||||||
'type': 'invoice_paid',
|
'type': 'invoice_paid',
|
||||||
@@ -8918,7 +8918,6 @@ def admin_mark_invoice_paid(borrow_id):
|
|||||||
if client:
|
if client:
|
||||||
client.close()
|
client.close()
|
||||||
|
|
||||||
|
|
||||||
@app.route('/admin/items/<item_id>/repair', methods=['POST'])
|
@app.route('/admin/items/<item_id>/repair', methods=['POST'])
|
||||||
def mark_damage_repaired(item_id):
|
def mark_damage_repaired(item_id):
|
||||||
"""Mark item as repaired and make it available again."""
|
"""Mark item as repaired and make it available again."""
|
||||||
|
|||||||
Reference in New Issue
Block a user