Skip to content

Commit

Permalink
rename control
Browse files Browse the repository at this point in the history
  • Loading branch information
alensiljak committed Nov 24, 2024
1 parent e8a846d commit 66d0ca8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ import {
PlusCircle, User as IconUser, Trash
} from 'lucide-vue-next'
import { AccountService } from '../lib/accountsService'
import { getEmptyPostingIndex } from '../lib/xactUtils';
const router = useRouter()
const mainStore = useMainStore()
Expand Down Expand Up @@ -141,27 +142,6 @@ function formatNumber(value: number) {
return appService.formatNumber(value)
}
/**
* Find an empty posting, or create one.
*/
function getEmptyPostingIndex() {
if (!tx.value) {
throw new Error('No transaction loaded!')
}
for (let i = 0; i < tx.value.postings.length; i++) {
const posting = tx.value.postings[i]
if (!posting.account && !posting.amount && !posting.currency) {
return i
}
}
// not found. Create a new one.
const posting = new Posting()
tx.value.postings.push(posting)
return tx.value.postings.length - 1
}
/**
* Handle selection after a picker returned.
*/
Expand Down Expand Up @@ -189,7 +169,7 @@ async function handleEntitySelection() {
index = select.postingIndex
} else {
// redirected from account register, find an appropriate posting
index = getEmptyPostingIndex()
index = getEmptyPostingIndex(tx.value)
}
let posting = tx.value.postings[index]
Expand Down
22 changes: 22 additions & 0 deletions src/lib/xactUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Posting, Transaction } from 'src/model'

/**
* Find an empty posting, or create one.
*/
export function getEmptyPostingIndex(tx: Transaction) {
if (!tx) {
throw new Error('No transaction loaded!')
}

for (let i = 0; i < tx.postings.length; i++) {
const posting = tx.postings[i]
if (!posting.account && !posting.amount && !posting.currency) {
return i
}
}

// not found. Create a new one.
const posting = new Posting()
tx.postings.push(posting)
return tx.postings.length - 1
}
2 changes: 1 addition & 1 deletion src/pages/ScheduledTxEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</template>

<script setup lang="ts">
import TxEditor from '../components/TransactionEditor.vue'
import TxEditor from '../components/XactEditor.vue'
import ScheduleEditor from '../components/ScheduleEditor.vue'
import { computed, onMounted, provide } from 'vue'
import { toRaw } from 'vue'
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Transaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import { SettingKeys, settings } from 'src/lib/settings'
import { useQuasar } from 'quasar'
import { storeToRefs } from 'pinia'
import appService from '../appService'
import TxEditor from '../components/TransactionEditor.vue'
import TxEditor from '../components/XactEditor.vue'
import CashierDAL from '../store/dal'
import { Transaction } from 'src/model'
import CashierToolbar from 'src/components/CashierToolbar.vue'
Expand Down

0 comments on commit 66d0ca8

Please sign in to comment.