Class: Waveapps::Invoice
- Inherits:
-
Object
- Object
- Waveapps::Invoice
- Defined in:
- lib/waveapps.rb
Constant Summary collapse
- ListInvoicesQuery =
Waveapps::Client.parse " query($businessId: ID!, $page: Int!, $pageSize: Int!) {\n business(id: $businessId) {\n id\n isClassicInvoicing\n invoices(page: $page, pageSize: $pageSize) {\n pageInfo {\n currentPage\n totalPages\n totalCount\n }\n edges {\n node {\n id\n createdAt\n modifiedAt\n pdfUrl\n viewUrl\n status\n title\n subhead\n invoiceNumber\n invoiceDate\n poNumber\n customer {\n id\n name\n # Can add additional customer fields here\n }\n currency {\n code\n }\n dueDate\n amountDue {\n value\n currency {\n symbol\n }\n }\n amountPaid {\n value\n currency {\n symbol\n }\n }\n taxTotal {\n value\n currency {\n symbol\n }\n }\n total {\n value\n currency {\n symbol\n }\n }\n exchangeRate\n footer\n memo\n disableCreditCardPayments\n disableBankPayments\n itemTitle\n unitTitle\n priceTitle\n amountTitle\n hideName\n hideDescription\n hideUnit\n hidePrice\n hideAmount\n items {\n product {\n id\n name\n # Can add additional product fields here\n }\n description\n quantity\n price\n subtotal {\n value\n currency {\n symbol\n }\n }\n total {\n value\n currency {\n symbol\n }\n }\n account {\n id\n name\n subtype {\n name\n value\n }\n # Can add additional account fields here\n }\n taxes {\n amount {\n value\n }\n salesTax {\n id\n name\n # Can add additional sales tax fields here\n }\n }\n }\n lastSentAt\n lastSentVia\n lastViewedAt\n }\n }\n }\n }\n }\n"
- CreateInvoiceQuery =
Waveapps::Client.parse " mutation ($input: InvoiceCreateInput!) {\n invoiceCreate(input: $input) {\n didSucceed\n inputErrors {\n message\n code\n path\n }\n invoice {\n id\n createdAt\n modifiedAt\n pdfUrl\n viewUrl\n status\n title\n subhead\n invoiceNumber\n invoiceDate\n poNumber\n customer {\n id\n name\n # Can add additional customer fields here\n }\n currency {\n code\n }\n dueDate\n amountDue {\n value\n currency {\n symbol\n }\n }\n amountPaid {\n value\n currency {\n symbol\n }\n }\n taxTotal {\n value\n currency {\n symbol\n }\n }\n total {\n value\n currency {\n symbol\n }\n }\n exchangeRate\n footer\n memo\n disableCreditCardPayments\n disableBankPayments\n itemTitle\n unitTitle\n priceTitle\n amountTitle\n hideName\n hideDescription\n hideUnit\n hidePrice\n hideAmount\n items {\n product {\n id\n name\n # Can add additional product fields here\n }\n description\n quantity\n price\n subtotal {\n value\n currency {\n symbol\n }\n }\n total {\n value\n currency {\n symbol\n }\n }\n account {\n id\n name\n subtype {\n name\n value\n }\n # Can add additional account fields here\n }\n taxes {\n amount {\n value\n }\n salesTax {\n id\n name\n # Can add additional sales tax fields here\n }\n }\n }\n lastSentAt\n lastSentVia\n lastViewedAt\n }\n }\n}\n"
- DeleteInvoiceQuery =
Waveapps::Client.parse " mutation ($input: InvoiceDeleteInput!) {\n invoiceDelete(input: $input) {\n didSucceed\n inputErrors {\n code\n message\n path\n }\n }\n }\n"
Class Method Summary collapse
-
.create_invoice(items:, business_id:, customer_id:) ⇒ Object
“input”: { “businessId”: “<BUSINESS_ID>”, “customerId”: “<CUSTOMER_ID>”, “items”: [ { “productId”: “<PRODUCT_ID>” } ] } }.
- .delete_invoice(id) ⇒ Object
- .list_invoices(page: 1, page_size: 10, business_id:) ⇒ Object
Class Method Details
.create_invoice(items:, business_id:, customer_id:) ⇒ Object
“input”: {
"businessId": "<BUSINESS_ID>",
"customerId": "<CUSTOMER_ID>",
"items": [
{
"productId": "<PRODUCT_ID>"
}
]
}
}
291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/waveapps.rb', line 291 def self.create_invoice(items: , business_id: , customer_id: ) Waveapps::Client.query(CreateInvoiceQuery, variables: { input: { businessId: business_id, customerId: customer_id, items: items.map { |pid| { productId: pid[:product_id], quantity: pid[:quantity], description: pid[:description], unitPrice: pid[:unit_price] }} } }) end |
.delete_invoice(id) ⇒ Object
319 320 321 322 |
# File 'lib/waveapps.rb', line 319 def self.delete_invoice(id) result = Waveapps::Client.query(DeleteInvoiceQuery, variables: {input: { id: id}}) result.data end |
.list_invoices(page: 1, page_size: 10, business_id:) ⇒ Object
154 155 156 157 158 159 160 |
# File 'lib/waveapps.rb', line 154 def self.list_invoices(page: 1, page_size: 10, business_id:) result = Waveapps::Client.query(ListInvoicesQuery, variables: { businessId: business_id, page: page, pageSize: page_size }).data return nil if result.nil? result.business.invoices.edges.map {|n| n.node} end |