Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions app/controllers/accounting_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ def banktransfers
@banktransfers = xero_client.accounting_api.get_bank_transfers(current_user.active_tenant_id, opts).bank_transfers
end

def batchpayments_get_one
batchpayment = xero_client.accounting_api.get_batch_payments(current_user.active_tenant_id).batch_payments.first
batchpaymentId = batchpayment.batch_payment_id

@batchpayments = xero_client.accounting_api.get_batch_payment(current_user.active_tenant_id, batchpaymentId).batch_payments
render :batchpayments
end

def batchpayments
@batchpayments = xero_client.accounting_api.get_batch_payments(current_user.active_tenant_id).batch_payments
end
Expand All @@ -369,8 +377,9 @@ def batchpayments_create
enable_payments_to_account: ["==", true]
}
}

bank_account = xero_client.accounting_api.get_accounts(current_user.active_tenant_id, opts).accounts.sample

#see above where type is expense and enable payments to account is true
currency = org.first.base_currency
invoices = {
invoices: [
Expand All @@ -382,16 +391,16 @@ def batchpayments_create
},
line_items: [
{
description: "Acme Tires Desc",
description: "Acme Tyres Description",
quantity: 32.0,
unit_amount: BigDecimal("20.99"),
unit_amount: BigDecimal("10.50"),
account_code: bank_account.code,
tax_type: XeroRuby::Accounting::TaxType::INPUT
# tax_type: XeroRuby::Accounting::TaxType::INPUT
}
],
date: "2019-03-11",
due_date: "2018-12-10",
reference: "Website Design",
date: "2022-09-14",
due_date: "2022-09-14",
reference: "Website Design and Consultancy",
status: XeroRuby::Accounting::Invoice::AUTHORISED
}
]
Expand Down
5 changes: 5 additions & 0 deletions app/views/layouts/_accounting_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@
<span class="menu-collapsed">Get (all)</span>
</a>
</div>
<div id="batchpayments" class="collapse sidebar-submenu" data-parent="#accounting">
<a id="accounting_batchpayments_get_one" href="/batchpayments_get_one" class="list-group-item list-group-item-action bg-dark text-white">
<span class="menu-collapsed">Get (one)</span>
</a>
</div>
<div id="batchpayments" class="collapse sidebar-submenu" data-parent="#accounting">
<a id="accounting_batchpayments_create" href="/batchpayments_create" class="list-group-item list-group-item-action bg-dark text-white">
<span class="menu-collapsed">Create</span>
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
get '/banktransfers', to: 'accounting#banktransfers'

get '/batchpayments', to: 'accounting#batchpayments'
get '/batchpayments_get_one', to: 'accounting#batchpayments_get_one'
get '/batchpayments_create', to: 'accounting#batchpayments_create'

get '/brandingthemes', to: 'accounting#brandingthemes'
Expand Down