Endpoint: /api/ledgers/upload-ledger
Method: POST
Description: Uploads a ledger entry along with an associated invoice file.
Headers:
Content-Type: multipart/form-data
Body:
file
: Multipart file containing the invoice.ledger
: JSON object containing the ledger details.
Ledger DTO JSON Structure:
{
"item": "Item description",
"amount": 100.00,
"expenseDate": "2023-07-31",
"notes": "Additional notes"
}
true
if the upload was successful.false
if there was an error during the upload process.
Endpoint: /api/ledgers/get-all
Method: POST
Description: Retrieves a list of all ledger entries.
No parameters or body required.
- Returns a JSON array of all ledger entries.
Example Response:
[
{
"id": 1,
"item": "Office Supplies",
"amount": 150.75,
"expenseDate": "2024-07-31",
"invoiceUrl": "random_uuid_invoice.jpg",
"notes": "Purchased new office supplies"
},
...
]
Endpoint: /api/ledgers/invoice/{fileName}
Method: GET
Description: Retrieves the invoice file by its name.
Path Parameter:
fileName
: The name of the file to retrieve.
curl -X GET "https://api.utmcaps.com/api/ledgers/invoice/random_uuid_invoice.jpg"
- Returns the invoice file if it exists.
- 404 status code if the file does not exist or cannot be read.
- Endpoint:
/api/ledgers/del-ledger/{ledgerID}
- Method: GET
- Description: Deletes a ledger entry by its ID.
Path Parameter:
- ledgerID: The ID of the ledger entry to delete.
curl -X GET "https://api.utmcaps.com/api/ledgers/del-ledger/1"
No content even if the deletion was successful.
The LedgerDTO
is a Data Transfer Object used for transferring ledger information.
public class LedgerDTO {
private String item;
private BigDecimal amount;
private LocalDate expenseDate;
private String notes;
}
The Ledger
entity represents the ledger table in the database.
@Entity
@Table(name = "ledger")
public class Ledger {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false, name="item")
private String item;
@Column(nullable = false, name = "amount")
private BigDecimal amount;
@Column(nullable = false, name = "expense_date")
private LocalDate expenseDate;
@Column(name = "invoice_url")
private String invoiceUrl;
@Column(name = "notes")
private String notes;
}