diff --git a/my-app/src/lib/server/api.ts b/my-app/src/lib/server/api.ts
index 027d1df..e330030 100644
--- a/my-app/src/lib/server/api.ts
+++ b/my-app/src/lib/server/api.ts
@@ -84,6 +84,13 @@ export const spendingService = {
: post('spending', data, getAuthHeader(cookies)),
list: (groupId: Id, cookies: Cookies) => get(`group/${groupId}/spending`, getAuthHeader(cookies))
};
+export const paymentService = {
+ save: (data: Payment, cookies: Cookies) =>
+ data.id > 0
+ ? put(`payment/${data.id}`, data, getAuthHeader(cookies))
+ : post('payment', data, getAuthHeader(cookies)),
+ list: (groupId: Id, cookies: Cookies) => get(`group/${groupId}/payment`, getAuthHeader(cookies))
+};
export const budgetService = {
save: (data: Budget, cookies: Cookies) =>
data.id > 0
diff --git a/my-app/src/lib/svgs.ts b/my-app/src/lib/svgs.ts
index e292ed2..fca9883 100644
--- a/my-app/src/lib/svgs.ts
+++ b/my-app/src/lib/svgs.ts
@@ -14,3 +14,6 @@ export const CAUTION_SVG =
export const WARNING_SVG =
'';
+
+export const ARROW_DOLLAR_SVG =
+ '';
diff --git a/my-app/src/routes/api/members/+server.ts b/my-app/src/routes/api/members/+server.ts
new file mode 100644
index 0000000..8759a8d
--- /dev/null
+++ b/my-app/src/routes/api/members/+server.ts
@@ -0,0 +1,8 @@
+import { groupService } from '$lib/server/api';
+import type { RequestHandler } from './$types';
+
+export const GET: RequestHandler = async ({ url, cookies }) => {
+ const groupId = url.searchParams.get('groupId') || 0;
+ const body = await groupService.listAllMembers(+groupId, cookies);
+ return new Response(JSON.stringify(body));
+};
diff --git a/my-app/src/routes/groups/aggregations/[[id=integer]]/+page.server.ts b/my-app/src/routes/groups/aggregations/[[id=integer]]/+page.server.ts
index e8ca539..a6180f8 100644
--- a/my-app/src/routes/groups/aggregations/[[id=integer]]/+page.server.ts
+++ b/my-app/src/routes/groups/aggregations/[[id=integer]]/+page.server.ts
@@ -15,22 +15,28 @@ export const actions: Actions = {
const data = await request.formData();
const dateIni = new Date(data.get('dateIni') as string);
const dateFin = new Date(data.get('dateFin') as string);
-
+
const spendings: Spending[] = await spendingService.list(id, cookies);
- const filteredSpendings = spendings.filter((spending: Spending) => {
- const spendingDate = new Date(spending.date.slice(0,10)); //removing timezone
+ const filteredSpendings = spendings.filter((spending: Spending) => {
+ const spendingDate = new Date(spending.date.slice(0, 10)); //removing timezone
return spendingDate >= dateIni && spendingDate <= dateFin;
});
- const totalSum = filteredSpendings.reduce((sum: number, spending: Spending) => sum + spending.amount, 0);
+ const totalSum = filteredSpendings.reduce(
+ (sum: number, spending: Spending) => sum + spending.amount,
+ 0
+ );
- const sumPerCategory = filteredSpendings.reduce((acc: { [x: number]: number; }, spending: Spending) => {
- acc[spending.category_id] = (acc[spending.category_id] || 0) + spending.amount;
- return acc;
- }, {});
+ const sumPerCategory = filteredSpendings.reduce(
+ (acc: { [x: number]: number }, spending: Spending) => {
+ acc[spending.category_id] = (acc[spending.category_id] || 0) + spending.amount;
+ return acc;
+ },
+ {}
+ );
- return {
+ return {
totalSum,
sumPerCategory
};
diff --git a/my-app/src/routes/groups/aggregations/[[id=integer]]/+page.svelte b/my-app/src/routes/groups/aggregations/[[id=integer]]/+page.svelte
index 7a263c3..d65dcec 100644
--- a/my-app/src/routes/groups/aggregations/[[id=integer]]/+page.svelte
+++ b/my-app/src/routes/groups/aggregations/[[id=integer]]/+page.svelte
@@ -10,17 +10,14 @@
const last_week = new Date();
last_week.setDate(now.getDay() - 7);
- let initDate = last_week.toJSON()
- let finDate = now.toJSON()
+ let initDate = last_week.toJSON();
+ let finDate = now.toJSON();
- function getCategoryName(id: number): string {
- return data.categories.filter(
- (category: Category) => {
- return category.id == id
- }
- )[0].name
+ function getCategoryName(id: Number): string {
+ return data.categories.filter((category: Category) => {
+ return category.id == id;
+ })[0].name;
}
-
diff --git a/my-app/src/routes/groups/movements/[id=integer]/+page.server.ts b/my-app/src/routes/groups/movements/[id=integer]/+page.server.ts
index 548ca68..1ef3e58 100644
--- a/my-app/src/routes/groups/movements/[id=integer]/+page.server.ts
+++ b/my-app/src/routes/groups/movements/[id=integer]/+page.server.ts
@@ -1,4 +1,10 @@
-import { budgetService, categoryService, groupService, spendingService } from '$lib/server/api';
+import {
+ budgetService,
+ categoryService,
+ groupService,
+ paymentService,
+ spendingService
+} from '$lib/server/api';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ cookies, params }) => {
@@ -7,13 +13,15 @@ export const load: PageServerLoad = async ({ cookies, params }) => {
const spendings: Spending[] = await spendingService.list(id, cookies);
const budgets: Budget[] = await budgetService.list(id, cookies);
const categories: Category[] = await categoryService.list(id, cookies);
+ const payments: Payment[] = await paymentService.list(id, cookies);
+ const members: User[] = await groupService.listAllMembers(id, cookies);
const categoryBalances: CategoryBalance[] = computeBalancesPerCategory(
spendings,
budgets,
categories
);
- return { group, spendings, budgets, categories, categoryBalances };
+ return { group, spendings, payments, budgets, categories, members, categoryBalances };
};
function computeBalancesPerCategory(
diff --git a/my-app/src/routes/groups/movements/[id=integer]/+page.svelte b/my-app/src/routes/groups/movements/[id=integer]/+page.svelte
index 9da0716..b80afd1 100644
--- a/my-app/src/routes/groups/movements/[id=integer]/+page.svelte
+++ b/my-app/src/routes/groups/movements/[id=integer]/+page.svelte
@@ -1,11 +1,14 @@
+
+
+ {title} - Nuevo Pago
+
+
+
+
+Registrando Pago
+
diff --git a/my-app/src/types.d.ts b/my-app/src/types.d.ts
index 72e2ddc..1819f0f 100644
--- a/my-app/src/types.d.ts
+++ b/my-app/src/types.d.ts
@@ -36,6 +36,14 @@ declare global {
amount: number;
date: string;
};
+ type Payment = {
+ id: Id;
+ group_id: Id;
+ from_id: Id;
+ to_id: Id;
+ amount: number;
+ date: string;
+ };
type Invite = {
id: Id;
sender_id: Id;