ironed out patching failure
This commit is contained in:
parent
f150fe84f2
commit
cfbd7c1550
2 changed files with 37 additions and 15 deletions
23
bruno/Common Cents/Expenses/LOC PATCH Expense Full.bru
Normal file
23
bruno/Common Cents/Expenses/LOC PATCH Expense Full.bru
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
meta {
|
||||||
|
name: LOC PATCH Expense Full
|
||||||
|
type: http
|
||||||
|
seq: 6
|
||||||
|
}
|
||||||
|
|
||||||
|
patch {
|
||||||
|
url: {{localBaseUrl}}/expenses/0708e7f7-3a2a-4b93-81da-38954925ca78
|
||||||
|
body: json
|
||||||
|
auth: inherit
|
||||||
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"date": "2025-12-15",
|
||||||
|
"cents": 888,
|
||||||
|
"categoryId": "1",
|
||||||
|
"merchantId": "1",
|
||||||
|
"subcategoryIds": ["2"],
|
||||||
|
"tagIds": ["2"],
|
||||||
|
"description": "PATCHED Desc."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -59,7 +59,7 @@ export class ExpensesService {
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
create(createExpenseDto: CreateExpenseDto) {
|
public create(createExpenseDto: CreateExpenseDto) {
|
||||||
const expense = {
|
const expense = {
|
||||||
id: randomUUID(),
|
id: randomUUID(),
|
||||||
date: new Date(createExpenseDto.date),
|
date: new Date(createExpenseDto.date),
|
||||||
|
|
@ -75,31 +75,30 @@ export class ExpensesService {
|
||||||
return this.mapExpense(expense);
|
return this.mapExpense(expense);
|
||||||
}
|
}
|
||||||
|
|
||||||
findAll() {
|
public findAll() {
|
||||||
return this.expenses.map((expense) => {
|
return this.expenses.map((expense) => {
|
||||||
return this.mapExpense(expense);
|
return this.mapExpense(expense);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
findOne(id: string) {
|
public findOne(id: string) {
|
||||||
const expense = this.getExpense(id);
|
const expense = this.getExpense(id);
|
||||||
return expense ? this.mapExpense(expense) : undefined;
|
return expense ? this.mapExpense(expense) : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
update(id: string, updateExpenseDto: UpdateExpenseDto) {
|
public update(id: string, updateExpenseDto: UpdateExpenseDto) {
|
||||||
const index = this.expenses.findIndex((expense) => expense.id === id);
|
let index;
|
||||||
if (index) {
|
const expense = this.expenses.find((exp, idx) => {
|
||||||
const expense = this.expenses[index];
|
if (exp.id === id) {
|
||||||
|
index = idx;
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (expense && index) {
|
||||||
this.expenses[index] = {
|
this.expenses[index] = {
|
||||||
...expense,
|
...expense,
|
||||||
...updateExpenseDto
|
...updateExpenseDto
|
||||||
// date: updateExpenseDto.date ?? expense.date,
|
|
||||||
// cents: updateExpenseDto.cents ?? expense.cents,
|
|
||||||
// categoryId: updateExpenseDto.categoryId ?? expense.categoryId,
|
|
||||||
// merchant: updateExpenseDto.merchantId ?? expense.merchantId,
|
|
||||||
// subcategoryIds: updateExpenseDto.subcategoryIds ?? expense.subcategoryIds,
|
|
||||||
// tagIds: updateExpenseDto.tagIds ?? expense.tagIds,
|
|
||||||
// description: updateExpenseDto.description ?? expense.description
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.mapExpense(this.expenses[index]);
|
return this.mapExpense(this.expenses[index]);
|
||||||
|
|
@ -108,7 +107,7 @@ export class ExpensesService {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(id: string) {
|
public remove(id: string) {
|
||||||
this.expenses = this.expenses.filter((expense) => expense.id !== id);
|
this.expenses = this.expenses.filter((expense) => expense.id !== id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue