Skip to content

Cannot update a bill with attachment without losing the attachment #3312

@meta-panic

Description

@meta-panic

Akaunting version

3.1.19

PHP version

8.1.33

Operating system

windows 11

Steps to reproduce

  1. create a bill via request with sending attachment as multipart-form:
curl --request POST \
  --url 'http:///%7B%7Bakaunting_url%7D%7D/documents?type=bill&category_id=1&document_number=BILL-00001&search=type%3Abill&status=draft&issued_at=2021-10-21T11%3A33%3A44%2004%3A00&due_at=2021-10-21T11%3A33%3A46%2004%3A00&account_id=1&currency_code=USD&currency_rate=1&notes=This%2520is%2520note%2520for%2520invoice&contact_id=47&contact_name=wefwefwefwef&amount=2.2' \
  --header 'authorization: Basic f3tha2F2bnRpbmdfZW1haWx9fTp7e2FrYXVudGluZ19wYXNzd29yZH29' \
  --header 'content-type: multipart/form-data' \
  --header 'x-company: 1' \
  --form 'attachment[0][filename]=file.png' \
  --form 'attachment[0]=@C:\Users\<path_to_file>\<filename>.jpg'

2.update the bill's name via request without sending multipart-form with attachment:

curl --request PUT \
  --url 'http:///%7B%7Bakaunting_url%7D%7D/documents/216?type=bill&search=type%3Abill&status=draft&issued_at=2025-07-30T19%3A53%3A41.000Z&due_at=2025-07-30T19%3A53%3A42.000Z&amount=0&_method=PATCH&category_id=1&document_number=updated-from_bruno&currency_code=USD&currency_rate=1&contact_id=47&contact_name=wefwefwefwef&items%5B0%5D%5Bitem_id%5D=1&items%5B0%5D%5Bname%5D=Service&items%5B0%5D%5Bquantity%5D=1&items%5B0%5D%5Bprice%5D=12&items%5B0%5D%5Btotal%5D=12&items%5B0%5D%5Bdiscount%5D=0&items%5B0%5D%5Bdescription%5D=This%20is%20custom%20item%20description&items=' \
  --header 'authorization: Basic f3tha2F2bnRpbmdfZW1haWx9fTp7e2FrYXVudGluZ19wYXNzd29yZH29' \
  --header 'content-type: multipart/form-data' \
  --header 'x-company: 1'

or using POST method with _method=PATCH query parameter

Expected result

Bill's name(or other property) changed. The attachment persists

Actual result

Bill's name(or other property) changed. The attachment is gone

update_attachment_bug.mp4

Additional comments

No response

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions