Class: Waveapps::Invoice
- Inherits:
-
Object
- Object
- Waveapps::Invoice
- Defined in:
- lib/waveapps/invoice.rb
Constant Summary collapse
- ListInvoicesQuery =
Waveapps::Api::Client.parse <<-'GRAPHQL' query( $businessId: ID!, $page: Int!, $pageSize: Int!, $sort: [InvoiceSort!]!, $status: InvoiceStatus, $customerId: ID, $currency: CurrencyCode, $sourceId: ID, $invoiceDateStart: Date, $invoiceDateEnd: Date, $modifiedAtAfter: DateTime, $modifiedAtBefore: DateTime) { business(id: $businessId) { id isClassicInvoicing invoices(page: $page, pageSize: $pageSize, sort: $sort, status: $status, customerId: $customerId, currency: $currency, sourceId: $sourceId, invoiceDateStart: $invoiceDateStart, invoiceDateEnd: $invoiceDateEnd, modifiedAtAfter: $modifiedAtAfter, modifiedAtBefore: $modifiedAtBefore) { pageInfo { currentPage totalPages totalCount } edges { node { id createdAt modifiedAt pdfUrl viewUrl status title subhead invoiceNumber invoiceDate poNumber customer { id name # Can add additional customer fields here } currency { code } dueDate amountDue { value currency { symbol } } amountPaid { value currency { symbol } } taxTotal { value currency { symbol } } total { value currency { symbol } } exchangeRate footer memo disableCreditCardPayments disableBankPayments itemTitle unitTitle priceTitle amountTitle hideName hideDescription hideUnit hidePrice hideAmount items { product { id name # Can add additional product fields here } description quantity price subtotal { value currency { symbol } } total { value currency { symbol } } account { id name subtype { name value } # Can add additional account fields here } taxes { amount { value } salesTax { id name # Can add additional sales tax fields here } } } lastSentAt lastSentVia lastViewedAt } } } } } GRAPHQL
- CreateInvoiceQuery =
Waveapps::Api::Client.parse <<-'GRAPHQL' mutation ($input: InvoiceCreateInput!) { invoiceCreate(input: $input) { didSucceed inputErrors { message code path } invoice { id createdAt modifiedAt pdfUrl viewUrl status title subhead invoiceNumber invoiceDate poNumber customer { id name # Can add additional customer fields here } currency { code } dueDate amountDue { value currency { symbol } } amountPaid { value currency { symbol } } taxTotal { value currency { symbol } } total { value currency { symbol } } exchangeRate footer memo disableCreditCardPayments disableBankPayments itemTitle unitTitle priceTitle amountTitle hideName hideDescription hideUnit hidePrice hideAmount items { product { id name # Can add additional product fields here } description quantity price subtotal { value currency { symbol } } total { value currency { symbol } } account { id name subtype { name value } # Can add additional account fields here } taxes { amount { value } salesTax { id name # Can add additional sales tax fields here } } } lastSentAt lastSentVia lastViewedAt } } } GRAPHQL
- DeleteInvoiceQuery =
Waveapps::Api::Client.parse <<-'GRAPHQL' mutation ($input: InvoiceDeleteInput!) { invoiceDelete(input: $input) { didSucceed inputErrors { code message path } } } GRAPHQL
- SendInvoiceQuery =
Waveapps::Api::Client.parse <<-'GRAPHQL' mutation ($input: InvoiceSendInput!) { invoiceSend(input: $input) { didSucceed inputErrors { message code path } } } GRAPHQL
- ApproveInvoiceQuery =
Waveapps::Api::Client.parse <<-'GRAPHQL' mutation ($input: InvoiceApproveInput!) { invoiceApprove(input: $input) { didSucceed inputErrors { message code path } } } GRAPHQL
- MarkSentInvoiceQuery =
Waveapps::Api::Client.parse <<-'GRAPHQL' mutation ($input: InvoiceMarkSentInput!) { invoiceMarkSent(input: $input) { didSucceed inputErrors { message code path } } } GRAPHQL
Class Method Summary collapse
- .approve_invoice(invoice_id:) ⇒ Object
- .create_invoice(status: "DRAFT", currency: nil, title: nil, invoice_number: nil, po_number: nil, invoice_date: nil, exchange_rate: nil, due_date: nil, memo: nil, footer: nil, disable_amex_payments: nil, disable_credit_card_payments: nil, disable_bank_payments: nil, item_title: nil, unit_title: nil, price_title: nil, amount_title: nil, hide_name: nil, hide_description: nil, hide_unit: nil, hide_price: nil, hide_amount: nil, items:, business_id:, customer_id:) ⇒ Object
- .delete_invoice(invoice_id:) ⇒ Object
- .list_invoices(page: 1, page_size: 10, sort: [ "CREATED_AT_DESC"], status: nil, customer_id: nil, currency: nil, source_id: nil, invoice_date_start: nil, invoice_date_end: nil, modified_at_after: nil, modified_at_before: nil, business_id:) ⇒ Object
- .mark_as_sent(sent_at: nil, send_method:, invoice_id:) ⇒ Object
- .send_invoice(subject: "", message: "", attach_pdf: false, invoice_id:, to:) ⇒ Object
Class Method Details
.approve_invoice(invoice_id:) ⇒ Object
399 400 401 402 403 404 405 406 407 408 |
# File 'lib/waveapps/invoice.rb', line 399 def self.approve_invoice(invoice_id: ) response = Waveapps::Api::Client.query(ApproveInvoiceQuery, variables: { input: { invoiceId: invoice_id } }) if response.data && response.data.invoice_approve return response.data.invoice_approve end Waveapps::Api.handle_errors(response, :invoice_approve) end |
.create_invoice(status: "DRAFT", currency: nil, title: nil, invoice_number: nil, po_number: nil, invoice_date: nil, exchange_rate: nil, due_date: nil, memo: nil, footer: nil, disable_amex_payments: nil, disable_credit_card_payments: nil, disable_bank_payments: nil, item_title: nil, unit_title: nil, price_title: nil, amount_title: nil, hide_name: nil, hide_description: nil, hide_unit: nil, hide_price: nil, hide_amount: nil, items:, business_id:, customer_id:) ⇒ Object
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/waveapps/invoice.rb', line 272 def self.create_invoice( status: "DRAFT", currency: nil, title: nil, invoice_number: nil, po_number: nil, invoice_date: nil, exchange_rate: nil, due_date: nil, memo: nil, footer: nil, disable_amex_payments: nil, disable_credit_card_payments: nil, disable_bank_payments: nil, item_title: nil, unit_title: nil, price_title: nil, amount_title: nil, hide_name: nil, hide_description: nil, hide_unit: nil, hide_price: nil, hide_amount: nil, items:, business_id:, customer_id: ) response = Waveapps::Api::Client.query( CreateInvoiceQuery, variables: { input: { businessId: business_id, customerId: customer_id, items: items.map do |pid| { productId: pid[:product_id], quantity: pid[:quantity], description: pid[:description], unitPrice: pid[:unit_price], taxes: pid[:taxes] && pid[:taxes].map do |tax| { salesTaxId: tax[:sales_tax_id], amount: tax[:amount] } end } end, status: status, currency: currency, title: title, invoiceNumber: invoice_number, poNumber: po_number, invoiceDate: invoice_date, exchangeRate: exchange_rate, dueDate: due_date, memo: memo, footer: , disableAmexPayments: disable_amex_payments, disableCreditCardPayments: disable_credit_card_payments, disableBankPayments: disable_bank_payments, itemTitle: item_title, unitTitle: unit_title, priceTitle: price_title, amountTitle: amount_title, hideName: hide_name, hideDescription: hide_description, hideUnit: hide_unit, hidePrice: hide_price, hideAmount: hide_amount } }) if response.data && response.data.invoice_create return response.data.invoice_create end Waveapps::Api.handle_errors(response, :invoice_create) end |
.delete_invoice(invoice_id:) ⇒ Object
344 345 346 347 348 349 350 351 352 353 |
# File 'lib/waveapps/invoice.rb', line 344 def self.delete_invoice(invoice_id:) response = Waveapps::Api::Client.query(DeleteInvoiceQuery, variables: { input: { invoiceId: invoice_id } }) if response.data && response.data.invoice_delete return response.data.invoice_delete end Waveapps::Api.handle_errors(response, :invoice_delete) end |
.list_invoices(page: 1, page_size: 10, sort: [ "CREATED_AT_DESC"], status: nil, customer_id: nil, currency: nil, source_id: nil, invoice_date_start: nil, invoice_date_end: nil, modified_at_after: nil, modified_at_before: nil, business_id:) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/waveapps/invoice.rb', line 135 def self.list_invoices(page: 1, page_size: 10, sort: [ "CREATED_AT_DESC"], status: nil, customer_id: nil, currency: nil, source_id: nil, invoice_date_start: nil, invoice_date_end: nil, modified_at_after: nil, modified_at_before: nil, business_id: ) response = Waveapps::Api::Client.query( ListInvoicesQuery, variables: { businessId: business_id, page: page, pageSize: page_size, sort: sort, status: status, customerId: customer_id, currency: currency, sourceId: source_id, invoiceDateStart: invoice_date_start, invoiceDateEnd: invoice_date_end, modifiedAtAfter: modified_at_after, modifiedAtBefore: modified_at_before }) if response.data && response.data.business && response.data.business return response.data.business.invoices end Waveapps::Api.handle_errors(response, :business) end |
.mark_as_sent(sent_at: nil, send_method:, invoice_id:) ⇒ Object
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'lib/waveapps/invoice.rb', line 423 def self.mark_as_sent(sent_at: nil, send_method: , invoice_id: ) response = Waveapps::Api::Client.query( MarkSentInvoiceQuery, variables: { input: { invoiceId: invoice_id, sentAt: sent_at, sendMethod: send_method } }) if response.data && response.data.invoice_mark_sent return response.data.invoice_mark_sent end Waveapps::Api.handle_errors(response, :invoice_mark_sent) end |
.send_invoice(subject: "", message: "", attach_pdf: false, invoice_id:, to:) ⇒ Object
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
# File 'lib/waveapps/invoice.rb', line 368 def self.send_invoice(subject: "", message: "", attach_pdf: false, invoice_id:, to: ) response = Waveapps::Api::Client.query( SendInvoiceQuery, variables: { input: { invoiceId: invoice_id, to: to, attachPDF: attach_pdf, subject: subject, message: } }) if response.data && response.data.invoice_send return response.data.invoice_send end Waveapps::Api.handle_errors(response, :invoice_send) end |