mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
fix: init pesa with correct currency
This commit is contained in:
parent
5ad858ede7
commit
595341c2aa
@ -6,8 +6,7 @@ import regionalModelUpdates from '../models/regionalModelUpdates';
|
||||
import postStart from '../server/postStart';
|
||||
import { DB_CONN_FAILURE } from './messages';
|
||||
import migrate from './migrate';
|
||||
import { getSavePath } from './utils';
|
||||
import { callInitializeMoneyMaker } from './utils';
|
||||
import { callInitializeMoneyMaker, getSavePath } from './utils';
|
||||
|
||||
export async function createNewDatabase() {
|
||||
const { canceled, filePath } = await getSavePath('books', 'db');
|
||||
@ -50,6 +49,7 @@ export async function connectToLocalDatabase(filePath) {
|
||||
return { connectionSuccess: false, reason: DB_CONN_FAILURE.CANT_CONNECT };
|
||||
}
|
||||
|
||||
// first init no currency, for migratory needs
|
||||
await callInitializeMoneyMaker();
|
||||
|
||||
try {
|
||||
@ -90,6 +90,9 @@ export async function connectToLocalDatabase(filePath) {
|
||||
|
||||
// set last selected file
|
||||
config.set('lastSelectedFilePath', filePath);
|
||||
|
||||
// second init with currency, normal usage
|
||||
await callInitializeMoneyMaker();
|
||||
return { connectionSuccess: true, reason: '' };
|
||||
}
|
||||
|
||||
|
@ -362,7 +362,7 @@ export async function getIsSetupComplete() {
|
||||
}
|
||||
|
||||
export async function getCurrency() {
|
||||
let currency = frappe?.AccoutingSettings?.currency ?? undefined;
|
||||
let currency = frappe?.AccountingSettings?.currency ?? undefined;
|
||||
|
||||
if (!currency) {
|
||||
try {
|
||||
@ -385,6 +385,10 @@ export async function callInitializeMoneyMaker(currency) {
|
||||
if (!currency && frappe.pesa) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currency && frappe.pesa().options.currency === currency) {
|
||||
return;
|
||||
}
|
||||
await frappe.initializeMoneyMaker(currency);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user