yuripeyamashita
commited on
Commit
•
76efe7b
1
Parent(s):
0de3336
Update app.py
Browse files
app.py
CHANGED
@@ -60,11 +60,28 @@ def api():
|
|
60 |
|
61 |
print(matrix)
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
raise ValueError("Action Success")
|
70 |
|
@@ -93,16 +110,11 @@ def api():
|
|
93 |
paid: float = 0.0
|
94 |
for _, value in quoted_msg_list.items():
|
95 |
paid += value.get("amount")
|
96 |
-
print(amount, paid)
|
97 |
|
98 |
if amount-paid <= 1 and payload.get("quoted_msg_id") == msg_id:
|
99 |
-
# s = f'{data.get("msg_text")} paid by {get_username(data.get("user_id"))}\n\n'
|
100 |
borrowers = []
|
101 |
for _, q_data in quoted_msg_list.items():
|
102 |
borrowers.append({"name": get_username(q_data.get("user_id")), "amount": q_data.get("amount")})
|
103 |
-
# s += f'{get_username(q_data.get("user_id"))} : {q_data.get("amount")}\n'
|
104 |
-
|
105 |
-
# send_text(payload.get("token"), s, data.get("quote_token"))
|
106 |
bubble = get_summary_bubble(data.get("msg_text"), get_username(data.get("user_id")), borrowers)
|
107 |
send_flex_text(payload.get("token"), bubble)
|
108 |
break
|
@@ -222,7 +234,7 @@ def get_summary_bubble(title: str, payer: str, borrowers: list):
|
|
222 |
},
|
223 |
{
|
224 |
"type": "text",
|
225 |
-
"text": f"${amount}",
|
226 |
"size": "sm",
|
227 |
"color": "#111111",
|
228 |
"align": "end"
|
|
|
60 |
|
61 |
print(matrix)
|
62 |
|
63 |
+
matrix_copy = [[0 for _ in range(len(matrix))] for _ in range(len(matrix))]
|
64 |
+
|
65 |
+
for i in range(len(matrix_copy)):
|
66 |
+
for j in range(len(matrix_copy)):
|
67 |
+
if i < j:
|
68 |
+
matrix_copy[i][j] = matrix[i][j] - matrix[j][i]
|
69 |
+
|
70 |
+
for r in matrix_copy:
|
71 |
+
print(r)
|
72 |
+
|
73 |
+
l = []
|
74 |
+
|
75 |
+
for i in range(len(matrix_copy)):
|
76 |
+
for j in range(len(matrix_copy)):
|
77 |
+
amount = matrix_copy[i][j]
|
78 |
+
if amount > 0:
|
79 |
+
l.append({"from": get_username(users[i]), "to": get_username(users[j]), "amount": amount})
|
80 |
+
if amount < 0:
|
81 |
+
l.append({"from": get_username(users[j]), "to": get_username(users[i]), "amount": -amount})
|
82 |
+
|
83 |
+
for r in l:
|
84 |
+
print(r)
|
85 |
|
86 |
raise ValueError("Action Success")
|
87 |
|
|
|
110 |
paid: float = 0.0
|
111 |
for _, value in quoted_msg_list.items():
|
112 |
paid += value.get("amount")
|
|
|
113 |
|
114 |
if amount-paid <= 1 and payload.get("quoted_msg_id") == msg_id:
|
|
|
115 |
borrowers = []
|
116 |
for _, q_data in quoted_msg_list.items():
|
117 |
borrowers.append({"name": get_username(q_data.get("user_id")), "amount": q_data.get("amount")})
|
|
|
|
|
|
|
118 |
bubble = get_summary_bubble(data.get("msg_text"), get_username(data.get("user_id")), borrowers)
|
119 |
send_flex_text(payload.get("token"), bubble)
|
120 |
break
|
|
|
234 |
},
|
235 |
{
|
236 |
"type": "text",
|
237 |
+
"text": f"${round(amount,2)}",
|
238 |
"size": "sm",
|
239 |
"color": "#111111",
|
240 |
"align": "end"
|