editing vendor
This commit is contained in:
parent
c2619f50f9
commit
71727b58a7
3 changed files with 44 additions and 9 deletions
|
|
@ -6,6 +6,7 @@ import datetime
|
|||
import os
|
||||
import openpyxl
|
||||
import time
|
||||
import calendar
|
||||
|
||||
def get_uploads_path() -> str:
|
||||
path1 = 'C:/Users/Lenovo/Desktop/BudgetingApp/app/static/uploadable/'
|
||||
|
|
@ -18,10 +19,25 @@ def get_uploads_path() -> str:
|
|||
|
||||
@app.route('/')
|
||||
def home():
|
||||
this_year = datetime.datetime.now().date().year
|
||||
this_month = datetime.datetime.now().date().month
|
||||
# Get the current date
|
||||
now = datetime.datetime.now()
|
||||
|
||||
all_line_items = db.session.execute(select(LineItem)).all()
|
||||
# Get the first day of the current month and subtract one day to get the last day of the previous month
|
||||
first_day_of_current_month = datetime.datetime(now.year, now.month, 1)
|
||||
last_day_of_previous_month = first_day_of_current_month - datetime.timedelta(days=1)
|
||||
|
||||
# Get the first day of the previous month
|
||||
first_day_of_previous_month = datetime.datetime(last_day_of_previous_month.year, last_day_of_previous_month.month, 1)
|
||||
|
||||
# Convert both datetime objects to timestamps
|
||||
first_day_timestamp = first_day_of_previous_month.timestamp()
|
||||
last_day_timestamp = datetime.datetime(last_day_of_previous_month.year, last_day_of_previous_month.month, last_day_of_previous_month.day, 23, 59, 59).timestamp()
|
||||
|
||||
all_line_items = db.session.execute(select(LineItem).where(LineItem.date > first_day_timestamp, LineItem.date < last_day_timestamp)).all()
|
||||
for li in all_line_items:
|
||||
dt_object = datetime.datetime.fromtimestamp(li[0].date)
|
||||
date_string = dt_object.strftime('%Y-%m-%d')
|
||||
li[0].date = date_string
|
||||
vendors = db.session.execute(select(Vendor)).all()
|
||||
budget_categories = db.session.execute(select(BudgetCategory)).all()
|
||||
files = os.listdir(get_uploads_path())
|
||||
|
|
|
|||
|
|
@ -1,13 +1,23 @@
|
|||
const delButtons = document.getElementsByClassName('del-button');
|
||||
|
||||
const reassignButtons = document.getElementsByClassName('reassign-button');
|
||||
|
||||
async function deleteCategory(id){
|
||||
console.log(id)
|
||||
var result = await fetch(`/delete_budget_category/${id}`, {method:'POST'});
|
||||
var data = await result.json();
|
||||
document.getElementById(`${id}-row`).remove();
|
||||
}
|
||||
|
||||
function startEditMode(id){
|
||||
for(let i = 0; i < reassignButtons.length; i++){
|
||||
reassignButtons[i].disabled = true;
|
||||
}
|
||||
document.addEventListener('')
|
||||
const vendor = document.getElementById(`vendor-line-${id}`);
|
||||
var placeholderText = vendor.innerText
|
||||
vendor.innerText = ''
|
||||
var inputElem = document.createElement("input");
|
||||
inputElem.value = placeholderText;
|
||||
vendor.appendChild(inputElem);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", (event) => {
|
||||
for(let i = 0; i < delButtons.length; i++){
|
||||
|
|
@ -15,4 +25,9 @@ document.addEventListener("DOMContentLoaded", (event) => {
|
|||
deleteCategory(parseInt(e.target.id))
|
||||
})
|
||||
}
|
||||
for(let i = 0; i < reassignButtons.length; i++){
|
||||
reassignButtons[i].addEventListener('click', e => {
|
||||
startEditMode(parseInt(e.target.id))
|
||||
})
|
||||
}
|
||||
});
|
||||
|
|
@ -52,10 +52,12 @@
|
|||
<th scope="col">Parent LineItem ID</th>
|
||||
<th scope="col">Amount</th>
|
||||
<th scope="col">Currency Type</th>
|
||||
<th scope="col">Vendor ID</th>
|
||||
<th scope="col">Vendor</th>
|
||||
<th scope="col">Date</th>
|
||||
<th scope="col">Confirmation Code</th>
|
||||
<th scope="col">Note</th>
|
||||
<th scope="col">Reassign Vendor</th>
|
||||
<th scope="col">Split Line?</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
@ -65,10 +67,12 @@
|
|||
<th scope="row">{{li[0].parent_line_item_id}}</th>
|
||||
<th scope="row">{{li[0].amount}}</th>
|
||||
<th scope="row">{{li[0].currency_type}}</th>
|
||||
<th scope="row">{{li[0].get_vendor()[0]}}</th>
|
||||
<th scope="row" id="vendor-line-{{li[0].id}}">{{li[0].get_vendor()[0]}}</th>
|
||||
<th scope="row">{{li[0].date}}</th>
|
||||
<th scope="row">{{li[0].confirmation_code}}</th>
|
||||
<th scope="row">{{li[0].note}}</th>
|
||||
<th scope="row"><button id="{{li[0].id}}" class="btn btn-primary reassign-button">Click to reassign vendor</button></th>
|
||||
<th scope="row"><a class="btn btn-primary" href="#">Click to split line</a></th>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue