Use Account structure in ImportEngine instead of simply id for unresolved accounts (more information can be given)
Remove "Operating expenses" default category and add "Car" in replacement
This commit is contained in:
parent
9b91448492
commit
ec3fa8d7d5
|
@ -352,7 +352,7 @@ void KissCount::ChangeName(const wxString& name)
|
|||
|
||||
// To enable translation during xgettext
|
||||
wxString default_cats[] = {
|
||||
_("Fix"), _("Groceries"), _("Hobbies"), _("Operating expense"),
|
||||
_("Fix"), _("Groceries"), _("Hobbies"), _("Car"),
|
||||
_("Unexpected"), _("Other")
|
||||
};
|
||||
|
||||
|
@ -383,7 +383,7 @@ void KissCount::NewUser(const wxString& name)
|
|||
AddCategory(cat);
|
||||
cat.parent = wxT("0") ; cat.name = wxT("Hobbies") ; cat.backcolor = OWN_GREEN; cat.forecolor = *wxBLACK; cat.fix_cost = false;
|
||||
AddCategory(cat);
|
||||
cat.parent = wxT("0") ; cat.name = wxT("Operating exepense") ; cat.backcolor = OWN_GREEN; cat.forecolor = *wxBLACK; cat.fix_cost = false;
|
||||
cat.parent = wxT("0") ; cat.name = wxT("Car") ; cat.backcolor = OWN_GREEN; cat.forecolor = *wxBLACK; cat.fix_cost = false;
|
||||
AddCategory(cat);
|
||||
cat.parent = wxT("0") ; cat.name = wxT("Unexpected") ; cat.backcolor = OWN_GREEN; cat.forecolor = *wxBLACK; cat.fix_cost = false;
|
||||
AddCategory(cat);
|
||||
|
|
|
@ -25,6 +25,7 @@ void GrisbiImportEngine::LoadAccount(GrisbiImportEngine* _this, const char** att
|
|||
{
|
||||
int i;
|
||||
wxString account_number, name, id, key;
|
||||
Account ac;
|
||||
|
||||
for (i=0; attrs[i]; i+=2)
|
||||
{
|
||||
|
@ -53,7 +54,9 @@ void GrisbiImportEngine::LoadAccount(GrisbiImportEngine* _this, const char** att
|
|||
}
|
||||
|
||||
_this->_accounts[id] = wxT("unknown-") + account_number;
|
||||
_this->_unresolvedAccounts.push_back(account_number);
|
||||
ac.number = account_number;
|
||||
ac.name = name;
|
||||
_this->_unresolvedAccounts.push_back(ac);
|
||||
}
|
||||
|
||||
void GrisbiImportEngine::LoadCategory(GrisbiImportEngine* _this, const char** attrs)
|
||||
|
|
|
@ -282,7 +282,7 @@ void ImportEngine::MatchPattern(wxString& originalKey, Operation& op)
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<wxString> ImportEngine::ParseFile()
|
||||
std::vector<Account> ImportEngine::ParseFile()
|
||||
{
|
||||
return _unresolvedAccounts;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
virtual bool HandleFile(const wxString& path, User* user, Database* db, KissCount* kiss)=0;
|
||||
|
||||
// Parse the file and return accounts that doesn't match
|
||||
virtual std::vector<wxString> ParseFile();
|
||||
virtual std::vector<Account> ParseFile();
|
||||
|
||||
// Final Step
|
||||
virtual std::vector<Operation>* GetOperations(std::map<wxString, wxString>& accounts);
|
||||
|
@ -67,7 +67,7 @@ protected:
|
|||
|
||||
std::map<wxString, wxString> _accounts;
|
||||
std::map<wxString, wxString> _categories;
|
||||
std::vector<wxString> _unresolvedAccounts;
|
||||
std::vector<Account> _unresolvedAccounts;
|
||||
std::vector<wxString> _unresolvedCategories;
|
||||
std::vector<Operation> _operations;
|
||||
std::map<wxString, wxString> _descriptions;
|
||||
|
|
|
@ -26,6 +26,7 @@ int OFXImportEngine::account_cb(const struct OfxAccountData data, void * account
|
|||
int i;
|
||||
OFXImportEngine* _this = (OFXImportEngine*) account_data;
|
||||
wxString account_number = wxString(data.account_number, wxConvUTF8);
|
||||
Account ac;
|
||||
|
||||
_this->_curAccount = wxT("");
|
||||
|
||||
|
@ -44,7 +45,8 @@ int OFXImportEngine::account_cb(const struct OfxAccountData data, void * account
|
|||
if (!_this->_curAccount.Len())
|
||||
{
|
||||
_this->_curAccount = _this->_accounts[account_number] = wxT("unknown-") + account_number;
|
||||
_this->_unresolvedAccounts.push_back(account_number);
|
||||
ac.number = account_number;
|
||||
_this->_unresolvedAccounts.push_back(ac);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -66,10 +66,11 @@ ImportPanel::ImportPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent
|
|||
vbox->Add(hbox, 0);
|
||||
|
||||
_accountsGrid = new wxGrid(this, wxID_ANY);
|
||||
_accountsGrid->CreateGrid(0, 2);
|
||||
_accountsGrid->CreateGrid(0, 3);
|
||||
_accountsGrid->SetRowLabelSize(0);
|
||||
_accountsGrid->SetColLabelValue(0, _("File account"));
|
||||
_accountsGrid->SetColLabelValue(1, _("Internal account"));
|
||||
_accountsGrid->SetColLabelValue(1, _("Account name"));
|
||||
_accountsGrid->SetColLabelValue(2, _("Internal account"));
|
||||
_accountsGrid->Fit();
|
||||
|
||||
wxStaticBoxSizer* staticBoxSizer = new wxStaticBoxSizer (staticAccount, wxVERTICAL);
|
||||
|
@ -134,7 +135,7 @@ void ImportPanel::OnFileEnter(wxCommandEvent& WXUNUSED(event))
|
|||
|
||||
void ImportPanel::ProcessFile()
|
||||
{
|
||||
std::vector<wxString> accounts;
|
||||
std::vector<Account> accounts;
|
||||
User* user = _kiss->GetUser();
|
||||
int i;
|
||||
wxGridCellChoiceEditor* accountEditor;
|
||||
|
@ -174,16 +175,16 @@ void ImportPanel::ProcessFile()
|
|||
|
||||
_buttonLoadOperations->Enable();
|
||||
|
||||
// std::cout << "Insert " << accounts.size() << " rows\n";
|
||||
_accountsGrid->AppendRows(accounts.size());
|
||||
|
||||
for (i=0; i<(int)accounts.size(); i++)
|
||||
{
|
||||
_accountsGrid->SetCellValue(i, 0, accounts[i]);
|
||||
_accountsGrid->SetCellValue(i, 0, accounts[i].number);
|
||||
_accountsGrid->SetReadOnly(i, 0);
|
||||
_accountsGrid->SetCellValue(i, 1, userAccounts[0]);
|
||||
_accountsGrid->SetCellValue(i, 1, accounts[i].name);
|
||||
_accountsGrid->SetCellValue(i, 2, userAccounts[0]);
|
||||
|
||||
_accountsGrid->SetCellEditor(i, 1, accountEditor);
|
||||
_accountsGrid->SetCellEditor(i, 2, accountEditor);
|
||||
}
|
||||
|
||||
_accountsGrid->AutoSize();
|
||||
|
@ -212,7 +213,7 @@ void ImportPanel::OnLoadOperations(wxCommandEvent& WXUNUSED(event))
|
|||
nbAccounts = 0;
|
||||
for(i=0; i<_accountsGrid->GetNumberRows(); i++)
|
||||
{
|
||||
if (_accountsGrid->GetCellValue(i, 1) == _("Create one"))
|
||||
if (_accountsGrid->GetCellValue(i, 2) == _("Create one"))
|
||||
nbAccounts++;
|
||||
}
|
||||
|
||||
|
@ -227,9 +228,12 @@ void ImportPanel::OnLoadOperations(wxCommandEvent& WXUNUSED(event))
|
|||
|
||||
for(i=0; i<_accountsGrid->GetNumberRows(); i++)
|
||||
{
|
||||
if (_accountsGrid->GetCellValue(i, 1) == _("Create one"))
|
||||
if (_accountsGrid->GetCellValue(i, 2) == _("Create one"))
|
||||
{
|
||||
account.name = _accountsGrid->GetCellValue(i, 0);
|
||||
if (_accountsGrid->GetCellValue(i, 1).Length())
|
||||
account.name = _accountsGrid->GetCellValue(i, 1);
|
||||
else
|
||||
account.name = _accountsGrid->GetCellValue(i, 0);
|
||||
account.number = _accountsGrid->GetCellValue(i, 0);
|
||||
account.shared = false;
|
||||
account.blocked = false;
|
||||
|
|
Loading…
Reference in New Issue
Block a user