Add support for Vendor -> Quickbooks Bank Accounts field

this feels a bit hacky yet, but had to introduce some new mechanisms
to allow for extra template stuff while avoiding adding a new
vendors/edit (etc.) template in this project, since we are using a
view supplement..ugh
This commit is contained in:
Lance Edgar 2024-04-16 18:23:49 -05:00
parent ddeb4545a6
commit 7e08dd0f89
3 changed files with 277 additions and 1 deletions

View file

@ -0,0 +1,86 @@
## -*- coding: utf-8; -*-
<script type="text/javascript">
${form.component_studly}Data.quickbooksBankAccountShowDialog = false
${form.component_studly}Data.quickbooksBankAccountEditing = null
${form.component_studly}Data.quickbooksBankAccountStore = null
${form.component_studly}Data.quickbooksBankAccountNumber = null
${form.component_studly}Data.quickbooksBankAccountStoreOptions = ${json.dumps(store_options)|n}
${form.component_studly}.methods.quickbooksBankAccountCreate = function() {
this.quickbooksBankAccountEditing = null
this.quickbooksBankAccountStore = null
this.quickbooksBankAccountNumber = null
this.quickbooksBankAccountShowDialog = true
}
${form.component_studly}.methods.quickbooksBankAccountEdit = function(row) {
this.quickbooksBankAccountEditing = row
this.quickbooksBankAccountStore = row.store_uuid
this.quickbooksBankAccountNumber = row.account_number
this.quickbooksBankAccountShowDialog = true
this.$nextTick(() => {
this.$refs.quickbooksBankAccountNumber.focus()
})
}
${form.component_studly}.computed.quickbooksBankAccountSaveDisabled = function(row) {
if (!this.quickbooksBankAccountStore) {
return true
}
if (!this.quickbooksBankAccountNumber) {
return true
}
return false
}
${form.component_studly}.computed.quickbooksBankAccountsFinal = function() {
return JSON.stringify(this.quickbooksBankAccountsData)
}
${form.component_studly}.methods.quickbooksBankAccountSave = function() {
if (this.quickbooksBankAccountEditing) {
this.quickbooksBankAccountEditing.store_uuid = this.quickbooksBankAccountStore
this.quickbooksBankAccountEditing.account_number = this.quickbooksBankAccountNumber
this.quickbooksBankAccountShowDialog = false
} else {
if (this.quickbooksBankAccountIsStoreDefined(this.quickbooksBankAccountStore)) {
alert("An account number is already defined for that store!")
} else {
this.quickbooksBankAccountsData.push({
store_uuid: this.quickbooksBankAccountStore,
store: this.quickbooksBankAccountGetStoreDisplay(this.quickbooksBankAccountStore),
account_number: this.quickbooksBankAccountNumber,
})
this.quickbooksBankAccountShowDialog = false
}
}
}
${form.component_studly}.methods.quickbooksBankAccountIsStoreDefined = function(uuid) {
for (let account of this.quickbooksBankAccountsData) {
if (account.store_uuid == uuid) {
return true
}
}
return false
}
${form.component_studly}.methods.quickbooksBankAccountGetStoreDisplay = function(uuid) {
for (let store of this.quickbooksBankAccountStoreOptions) {
if (store.uuid == uuid) {
return store.display
}
}
}
${form.component_studly}.methods.quickbooksBankAccountDelete = function(row) {
if (confirm("Really delete this account number?")) {
let i = this.quickbooksBankAccountsData.indexOf(row)
this.quickbooksBankAccountsData.splice(i, 1)
this.quickbooksBankAccountShowDialog = false
}
}
</script>

View file

@ -0,0 +1,58 @@
## -*- coding: utf-8; -*-
<div style="display: flex;">
<span style="flex-grow: 1;"></span>
<b-button type="is-primary"
icon-pack="fas"
icon-left="plus"
@click="quickbooksBankAccountCreate()">
Add Account
</b-button>
</div>
${grid.render_table_element(data_prop='quickbooksBankAccountsData')|n}
<b-modal has-modal-card
:active.sync="quickbooksBankAccountShowDialog">
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title">Quickbooks Bank Account</p>
</header>
<section class="modal-card-body">
<b-field label="Store"
:type="{'is-danger': !quickbooksBankAccountStore}">
<b-select v-model="quickbooksBankAccountStore"
:disabled="quickbooksBankAccountEditing">
<option v-for="store in quickbooksBankAccountStoreOptions"
:key="store.uuid"
:value="store.uuid">
{{ store.display }}
</option>
</b-select>
</b-field>
<b-field label="Account Number"
:type="{'is-danger': !quickbooksBankAccountNumber}">
<b-input v-model="quickbooksBankAccountNumber"
ref="quickbooksBankAccountNumber" />
</b-field>
</section>
<footer class="modal-card-foot">
<b-button type="is-primary"
@click="quickbooksBankAccountSave()"
:disabled="quickbooksBankAccountSaveDisabled"
icon-pack="fas"
icon-left="save">
Update
</b-button>
<b-button @click="quickbooksBankAccountShowDialog = false">
Cancel
</b-button>
</footer>
</div>
</b-modal>