Module: LoyverseApi::Endpoints::Receipts
- Included in:
- Client
- Defined in:
- lib/loyverse_api/endpoints/receipts.rb
Instance Method Summary collapse
-
#create_receipt(receipt_date:, store_id:, line_items:, payments:, receipt_type: "SALE", employee_id: nil, customer_id: nil, note: nil, source: "API") ⇒ Hash
Create a new receipt.
-
#create_refund(receipt_number, refund_date:, line_items:, payments:, employee_id: nil, note: nil) ⇒ Hash
Create a refund for a receipt.
-
#get_receipt(receipt_number) ⇒ Hash
Get a specific receipt by receipt number.
-
#list_receipts(limit: 100, **options) ⇒ Hash
List receipts.
Instance Method Details
#create_receipt(receipt_date:, store_id:, line_items:, payments:, receipt_type: "SALE", employee_id: nil, customer_id: nil, note: nil, source: "API") ⇒ Hash
Create a new receipt
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/loyverse_api/endpoints/receipts.rb', line 54 def create_receipt( receipt_date:, store_id:, line_items:, payments:, receipt_type: "SALE", employee_id: nil, customer_id: nil, note: nil, source: "API" ) body = { receipt_date: format_time(receipt_date), receipt_type: receipt_type, store_id: store_id, line_items: line_items, payments: payments, source: source } body[:employee_id] = employee_id if employee_id body[:customer_id] = customer_id if customer_id body[:note] = note if note post("receipts", body: body) end |
#create_refund(receipt_number, refund_date:, line_items:, payments:, employee_id: nil, note: nil) ⇒ Hash
Create a refund for a receipt
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/loyverse_api/endpoints/receipts.rb', line 88 def create_refund(receipt_number, refund_date:, line_items:, payments:, employee_id: nil, note: nil) body = { refund_date: format_time(refund_date), line_items: line_items, payments: payments } body[:employee_id] = employee_id if employee_id body[:note] = note if note post("receipts/#{receipt_number}/refund", body: body) end |
#get_receipt(receipt_number) ⇒ Hash
Get a specific receipt by receipt number
7 8 9 |
# File 'lib/loyverse_api/endpoints/receipts.rb', line 7 def get_receipt(receipt_number) get("receipts/#{receipt_number}") end |
#list_receipts(limit: 100, **options) ⇒ Hash
List receipts
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/loyverse_api/endpoints/receipts.rb', line 25 def list_receipts(limit: 100, **) params = { limit: limit, receipt_numbers: [:receipt_numbers] ? Array([:receipt_numbers]).join(",") : nil, since_receipt_number: [:since_receipt_number], before_receipt_number: [:before_receipt_number], store_id: [:store_id], source: [:source], cursor: [:cursor], updated_at_min: format_time([:updated_at_min]), updated_at_max: format_time([:updated_at_max]), created_at_min: format_time([:created_at_min]), created_at_max: format_time([:created_at_max]) }.compact get("receipts", params: params) end |