mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-05 04:31:49 +02:00
added reimbursement field in add bill form
This commit is contained in:
parent
d8b6355101
commit
f0ff918679
5 changed files with 35 additions and 0 deletions
|
@ -325,6 +325,7 @@ class BillForm(FlaskForm):
|
||||||
what = StringField(_("What?"), validators=[DataRequired()])
|
what = StringField(_("What?"), validators=[DataRequired()])
|
||||||
payer = SelectField(_("Who paid?"), validators=[DataRequired()], coerce=int)
|
payer = SelectField(_("Who paid?"), validators=[DataRequired()], coerce=int)
|
||||||
amount = CalculatorStringField(_("How much?"), validators=[DataRequired()])
|
amount = CalculatorStringField(_("How much?"), validators=[DataRequired()])
|
||||||
|
is_reimbursement = BooleanField("Reimbursement", default=False)
|
||||||
currency_helper = CurrencyConverter()
|
currency_helper = CurrencyConverter()
|
||||||
original_currency = SelectField(_("Currency"), validators=[DataRequired()])
|
original_currency = SelectField(_("Currency"), validators=[DataRequired()])
|
||||||
external_link = URLField(
|
external_link = URLField(
|
||||||
|
@ -344,6 +345,7 @@ class BillForm(FlaskForm):
|
||||||
amount=float(self.amount.data),
|
amount=float(self.amount.data),
|
||||||
date=self.date.data,
|
date=self.date.data,
|
||||||
external_link=self.external_link.data,
|
external_link=self.external_link.data,
|
||||||
|
is_reimbursement=self.is_reimbursement.data,
|
||||||
original_currency=str(self.original_currency.data),
|
original_currency=str(self.original_currency.data),
|
||||||
owers=Person.query.get_by_ids(self.payed_for.data, project),
|
owers=Person.query.get_by_ids(self.payed_for.data, project),
|
||||||
payer_id=self.payer.data,
|
payer_id=self.payer.data,
|
||||||
|
|
|
@ -159,6 +159,11 @@ class Project(db.Model):
|
||||||
monthly = defaultdict(lambda: defaultdict(float))
|
monthly = defaultdict(lambda: defaultdict(float))
|
||||||
for bill in self.get_bills_unordered().all():
|
for bill in self.get_bills_unordered().all():
|
||||||
monthly[bill.date.year][bill.date.month] += bill.converted_amount
|
monthly[bill.date.year][bill.date.month] += bill.converted_amount
|
||||||
|
=======
|
||||||
|
if (bill.is_reimbursement == False):
|
||||||
|
# if (not bill.what.startswith("R-")):
|
||||||
|
monthly[bill.date.year][bill.date.month] += bill.converted_amount
|
||||||
|
>>>>>>> Stashed changes
|
||||||
return monthly
|
return monthly
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -166,6 +166,7 @@
|
||||||
{{ input(form.date, inline=True) }}
|
{{ input(form.date, inline=True) }}
|
||||||
{{ input(form.what, inline=True) }}
|
{{ input(form.what, inline=True) }}
|
||||||
{{ input(form.payer, inline=True, class="form-control custom-select") }}
|
{{ input(form.payer, inline=True, class="form-control custom-select") }}
|
||||||
|
{{ input(form.is_reimbursement, inline=True) }}
|
||||||
<div data-toggle="tooltip" data-placement="top" title='{{ _("Simple operations are allowed, e.g. (18+36.2)/3") }}'>
|
<div data-toggle="tooltip" data-placement="top" title='{{ _("Simple operations are allowed, e.g. (18+36.2)/3") }}'>
|
||||||
{{ input(form.amount, inline=True) }}
|
{{ input(form.amount, inline=True) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -16,6 +16,11 @@
|
||||||
<td>{{ bill.ower }}</td>
|
<td>{{ bill.ower }}</td>
|
||||||
<td>{{ bill.receiver }}</td>
|
<td>{{ bill.receiver }}</td>
|
||||||
<td>{{ bill.amount|currency }}</td>
|
<td>{{ bill.amount|currency }}</td>
|
||||||
|
<!-- <td>
|
||||||
|
<a href="{{ url_for('.settle') }}" class="btn btn-primary " data-toggle="modal" data-keyboard="false" data-target="#bill-form">
|
||||||
|
Settle
|
||||||
|
</a>
|
||||||
|
</td> -->
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -747,6 +747,28 @@ def add_bill():
|
||||||
|
|
||||||
return render_template("add_bill.html", form=form)
|
return render_template("add_bill.html", form=form)
|
||||||
|
|
||||||
|
@main.route("/<project_id>/settle_bills/add", methods=["GET", "POST"])
|
||||||
|
def settle():
|
||||||
|
form = get_billform_for(g.project)
|
||||||
|
if request.method == "POST":
|
||||||
|
if form.validate():
|
||||||
|
# save last selected payer in session
|
||||||
|
session["last_selected_payer"] = form.payer.data
|
||||||
|
session.update()
|
||||||
|
|
||||||
|
db.session.add(form.export(g.project))
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
flash(_("The bill has been added"))
|
||||||
|
|
||||||
|
args = {}
|
||||||
|
if form.submit2.data:
|
||||||
|
args["add_bill"] = True
|
||||||
|
|
||||||
|
return redirect(url_for(".list_bills", **args))
|
||||||
|
|
||||||
|
return render_template("add_bill.html", form=form)
|
||||||
|
|
||||||
|
|
||||||
@main.route("/<project_id>/delete/<int:bill_id>", methods=["POST"])
|
@main.route("/<project_id>/delete/<int:bill_id>", methods=["POST"])
|
||||||
def delete_bill(bill_id):
|
def delete_bill(bill_id):
|
||||||
|
|
Loading…
Reference in a new issue