forked from Kispi/Core
feat(webapp): add seed capital to state portal
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
cd5c7d1569
commit
f1e7c0b514
2 changed files with 66 additions and 2 deletions
|
@ -152,6 +152,22 @@
|
|||
<TableCellsIcon class="h-5 w-5" />
|
||||
Stammdaten importieren
|
||||
</button>
|
||||
<div>
|
||||
<span>Startkapital auszahlen:</span>
|
||||
<div class="flex gap-2">
|
||||
<AtomCurrencyInput
|
||||
v-model="seedCapital"
|
||||
class="w-1/2"
|
||||
placeholder="Startkapital"
|
||||
/>
|
||||
<button
|
||||
class="btn grow"
|
||||
@click="verifySeedCapitalModal?.show()"
|
||||
>
|
||||
Auszahlen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="importPending"
|
||||
|
@ -169,6 +185,22 @@
|
|||
<span>Daten wurden erfolgreich importiert.</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="capitalPending"
|
||||
class="toast z-10"
|
||||
>
|
||||
<div class="alert alert-info">
|
||||
<span>Startkapital wird überwiesen. Bitte warten...</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="capitalDone"
|
||||
class="toast z-10"
|
||||
>
|
||||
<div class="alert alert-success">
|
||||
<span>Startkapital wurden erfolgreich überwiesen.</span>
|
||||
</div>
|
||||
</div>
|
||||
</AtomCard>
|
||||
<MoleculeErrorModal
|
||||
id="error-modal"
|
||||
|
@ -176,13 +208,21 @@
|
|||
v-model="errorMsg"
|
||||
title="Fehler beim Importieren bei folgenden Datensätzen"
|
||||
/>
|
||||
<MoleculeVerifyModal
|
||||
id="verify-seed-capital-modal"
|
||||
ref="verifySeedCapitalModal"
|
||||
title="Startkapital auszahlen"
|
||||
@confirm="paySeedCapital"
|
||||
>
|
||||
<p>Wirklich jedem Bürger ein Startkapital von {{ CurrencyService.toString((seedCapital ?? 0) * 100) }} auszahlen?</p>
|
||||
</MoleculeVerifyModal>
|
||||
</OrganismAuthWrapper>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { SettingsResponse } from '../../types/pocketbase.types';
|
||||
import { SettingsResponse, TransactionsResponse } from '../../types/pocketbase.types';
|
||||
import { AccountService } from '../../services/account.service';
|
||||
import { CompanyService } from '../../services/company.service';
|
||||
import { SettingsService } from '../../services/settings.service';
|
||||
|
@ -207,9 +247,13 @@ import OrganismAuthWrapper from '../organisms/OrganismAuthWrapper.vue';
|
|||
import MoleculeImportDataModal from '../molecules/MoleculeImportDataModal.vue';
|
||||
import MoleculeErrorModal from '../molecules/MoleculeErrorModal.vue';
|
||||
import { DateService } from '../../services/date.service';
|
||||
import MoleculeVerifyModal from '../molecules/MoleculeVerifyModal.vue';
|
||||
import { CurrencyService } from '../../services/currency.service';
|
||||
import { BankService } from '../../services/bank.service';
|
||||
|
||||
const importAccountsModal = ref<InstanceType<typeof MoleculeImportDataModal>>();
|
||||
const importCompaniesModal = ref<InstanceType<typeof MoleculeImportDataModal>>();
|
||||
const verifySeedCapitalModal = ref<InstanceType<typeof MoleculeVerifyModal>>();
|
||||
const errorModal = ref<InstanceType<typeof MoleculeErrorModal>>();
|
||||
const minWage = ref<number>();
|
||||
const incomeTax = ref<number>();
|
||||
|
@ -221,7 +265,10 @@ const settingsSaveSuccess = ref<boolean>(false);
|
|||
const settingsSaveError = ref<boolean>(false);
|
||||
const importPending = ref<boolean>(false);
|
||||
const importDone = ref<boolean>(false);
|
||||
const capitalPending = ref<boolean>(false);
|
||||
const capitalDone = ref<boolean>(false);
|
||||
const errorMsg = ref<string>();
|
||||
const seedCapital = ref<number>();
|
||||
const createdCompanies = ref<{ name: string, password: string }[]>([]);
|
||||
const serverTime = ref<Date>();
|
||||
|
||||
|
@ -336,6 +383,23 @@ async function saveSettings() {
|
|||
}, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
async function paySeedCapital() {
|
||||
capitalPending.value = true;
|
||||
verifySeedCapitalModal.value?.close();
|
||||
const accounts = await AccountService.getAccounts();
|
||||
const promises: Promise<TransactionsResponse>[] = [];
|
||||
accounts.forEach((account) => {
|
||||
promises.push(BankService.addTransaction(account.id, (seedCapital.value ?? 0), 'Startkapital'));
|
||||
});
|
||||
await Promise.all(promises);
|
||||
capitalPending.value = false;
|
||||
capitalDone.value = true;
|
||||
const timeout = setTimeout(() => {
|
||||
capitalDone.value = false;
|
||||
clearTimeout(timeout);
|
||||
}, 5000);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
|
@ -20,7 +20,7 @@ export class BankService {
|
|||
public static async addTransaction(accountId: string,
|
||||
amount: number,
|
||||
type: TransactionType | string,
|
||||
accountType: AccountType = AccountType.ACCOUNT,
|
||||
accountType = AccountType.ACCOUNT,
|
||||
): Promise<TransactionsResponse> {
|
||||
let label = '';
|
||||
switch (type) {
|
||||
|
|
Loading…
Reference in a new issue