Add delete and bulk delete functionality for invoices#386
Add delete and bulk delete functionality for invoices#386apoorv1316 merged 5 commits intodevelopfrom
Conversation
Current Code Coverage Percent of this PR:94.51 %Files having coverage below 100%
|
rohitjoshixyz
left a comment
There was a problem hiding this comment.
Two questions, rest of the PR is mostly react code. Assign a frontend dev for review
| # frozen_string_literal: true | ||
|
|
||
| class InternalApi::V1::Invoices::BulkDeletionController < InternalApi::V1::ApplicationController | ||
| def create |
There was a problem hiding this comment.
Shouldn't the action name be destroy?
There was a problem hiding this comment.
@apoorv1316 We can add a destroy_multiple action in invoices_controller instead of creating a separate controller just for this.
cc: @rohitjoshixyz
There was a problem hiding this comment.
@rohitjoshixyz Destroy action is a member route and we want to use a collection route for bulk_delete that's why we are using create action.
There was a problem hiding this comment.
We can use collection route for delete as well by explicitly mentioning it in routes.rb
| const BulkDeleteInvoices = ({ invoices, setShowBulkDeleteDialog, fetchInvoices }: IProps) => { | ||
| const destroyInvoices = async invoices => { | ||
| try { | ||
| await invoicesApi.destroyBulk(invoices); |
There was a problem hiding this comment.
If these are invoice ids, rename it to invoiceIds
app/controllers/internal_api/v1/invoices/bulk_deletion_controller.rb
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
@apoorv1316 Added a few suggestions.
-
Also, getting errors regarding modals because the folder name is changed to
modalsindevelop. Please change it toModalsafter rebase (after confirming we are not usingmodalsanywhere`). -
Checks are failing.
| fetchInvoices: any; | ||
| } | ||
|
|
||
| const DeleteInvoice = ({ invoice, setShowDeleteDialog, fetchInvoices }: IProps) => { |
There was a problem hiding this comment.
BulkDeleteInvoices and DeleteInvoice can be combined in a single modal.
There was a problem hiding this comment.
Yeah, It's good to have a single modal. Will create a separate PR for it.
| <div className="flex"> | ||
| <button | ||
| type="button" | ||
| onClick={()=> { |
There was a problem hiding this comment.
What if the status of the selected invoices is sent/viewed? They can still be deleted. Is this the expected behaviour?
There was a problem hiding this comment.
No, only draft and declined invoices can be deleted.
| # frozen_string_literal: true | ||
|
|
||
| class InternalApi::V1::Invoices::BulkDeletionController < InternalApi::V1::ApplicationController | ||
| def create |
There was a problem hiding this comment.
@apoorv1316 We can add a destroy_multiple action in invoices_controller instead of creating a separate controller just for this.
cc: @rohitjoshixyz
|
@apoorv1316 LGTM. Please merge this PR. |
* add delete and bulk delete functionality * added test for delete invoice * edited the params name to be invoices_ids * add tests for bulk delet Co-authored-by: “Apoorv <“[email protected]”>
Notion card
https://www.notion.so/saeloun/6afc9500b2cc42af86be55f37894fb09?v=b4528f26f4424af7beaf036262796cb3&p=e35605f512904d658a0bb6c67cf3d8dc
Summary
Added delete and bulk delete invoices functionality
Type of change
Please delete options that are not relevant.
not work as expected)
How Has This Been Tested?
Checklist: