Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add delete and bulk delete functionality for invoices#386

Merged
apoorv1316 merged 5 commits intodevelopfrom
delete-invoice
May 23, 2022
Merged

Add delete and bulk delete functionality for invoices#386
apoorv1316 merged 5 commits intodevelopfrom
delete-invoice

Conversation

@apoorv1316
Copy link
Collaborator

@apoorv1316 apoorv1316 commented May 18, 2022

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.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Checklist:

  • I have manually tested all workflows
  • I have performed a self-review of my own code
  • I have added automated tests for my code

@github-actions
Copy link

github-actions bot commented May 18, 2022

Current Code Coverage Percent of this PR:

94.51 %

Files having coverage below 100%

Impacted Files Coverage
/app/controllers/subscriptions_controller.rb 66.67 %
/app/controllers/invoices_controller.rb 63.64 %
/app/models/invoice.rb 96.3 %
/app/models/client.rb 92.68 %
/app/policies/timezone_policy.rb 66.67 %
/app/policies/subscriptions_policy.rb 66.67 %
/app/controllers/invoices/payments_controller.rb 61.11 %
/app/services/report/filters.rb 87.88 %
/app/services/invoice_payment/checkout.rb 43.48 %
/app/services/invoice_payment/pdf_generation.rb 65.38 %
/app/controllers/internal_api/v1/timezones_controller.rb 37.5 %
/lib/countries_info.rb 0.0 %

Copy link
Contributor

@rohitjoshixyz rohitjoshixyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the action name be destroy?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@apoorv1316 We can add a destroy_multiple action in invoices_controller instead of creating a separate controller just for this.

cc: @rohitjoshixyz

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mohd-anas-ansari that action won't be RESTful

Copy link
Collaborator Author

@apoorv1316 apoorv1316 May 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these are invoice ids, rename it to invoiceIds

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@mohd-anas-ansari mohd-anas-ansari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@apoorv1316 Added a few suggestions.

  • Also, getting errors regarding modals because the folder name is changed to modals in develop. Please change it to Modals after rebase (after confirming we are not using modals anywhere`).

  • Checks are failing.

fetchInvoices: any;
}

const DeleteInvoice = ({ invoice, setShowDeleteDialog, fetchInvoices }: IProps) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BulkDeleteInvoices and DeleteInvoice can be combined in a single modal.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, It's good to have a single modal. Will create a separate PR for it.

<div className="flex">
<button
type="button"
onClick={()=> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the status of the selected invoices is sent/viewed? They can still be deleted. Is this the expected behaviour?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, only draft and declined invoices can be deleted.

# frozen_string_literal: true

class InternalApi::V1::Invoices::BulkDeletionController < InternalApi::V1::ApplicationController
def create
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@apoorv1316 We can add a destroy_multiple action in invoices_controller instead of creating a separate controller just for this.

cc: @rohitjoshixyz

@mohd-anas-ansari
Copy link
Contributor

@apoorv1316 LGTM. Please merge this PR.

@apoorv1316 apoorv1316 merged commit 8eb49b0 into develop May 23, 2022
@apoorv1316 apoorv1316 deleted the delete-invoice branch May 23, 2022 06:18
@pr-triage pr-triage bot added the PR: merged label May 23, 2022
vipulnsward pushed a commit that referenced this pull request Feb 15, 2026
* 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]”>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants