Operations can now store account

This commit is contained in:
Quentin Snow 2023-01-17 14:33:09 -06:00
parent c036cc43dd
commit 98db5681d8
9 changed files with 28 additions and 12 deletions

View File

@ -10,4 +10,6 @@ void PaymentOperation::commit() {
//TODO This function will be called when the action needs to be done
}
PaymentOperation::PaymentOperation() = default;
PaymentOperation::PaymentOperation(std::string account) : account(std::move(account)) {
}

View File

@ -15,7 +15,7 @@ namespace Budget::OptHandlers {
public:
void commit() override;
explicit PaymentOperation();
explicit PaymentOperation(std::string account);
struct Flags : public Operation::Flags {
long double value;
@ -26,6 +26,8 @@ namespace Budget::OptHandlers {
Flags flags;
private:
std::string account;
};
}

View File

@ -12,4 +12,6 @@ void AccountOperation::commit() {
//TODO This function will be called when the action needs to be done
}
AccountOperation::AccountOperation() = default;
AccountOperation::AccountOperation(std::string account) : account(std::move(account)) {
}

View File

@ -14,7 +14,7 @@ namespace Budget::OptHandlers {
public:
void commit() override;
explicit AccountOperation();
explicit AccountOperation(std::string account);
struct Flags : public Operation::Flags {
bool del = false;
@ -24,6 +24,8 @@ namespace Budget::OptHandlers {
};
Flags flags;
private:
std::string account;
};
}

View File

@ -10,4 +10,6 @@ void CreateOperation::commit() {
//TODO This function will be called when the action needs to be done
}
CreateOperation::CreateOperation() = default;
CreateOperation::CreateOperation(std::string account) : account(std::move(account)) {
}

View File

@ -13,13 +13,15 @@ namespace Budget::OptHandlers {
public:
void commit() override;
explicit CreateOperation();
explicit CreateOperation(std::string account);
struct Flags : public Operation::Flags {
std::string description;
};
Flags flags;
private:
std::string account;
};
}

View File

@ -10,4 +10,6 @@ void EarnOperation::commit() {
//TODO This function will be called when the action needs to be done
}
EarnOperation::EarnOperation() = default;
EarnOperation::EarnOperation(std::string account) : account(std::move(account)) {
}

View File

@ -14,7 +14,7 @@ namespace Budget::OptHandlers {
public:
void commit() override;
explicit EarnOperation();
explicit EarnOperation(std::string account);
struct Flags : public Operation::Flags {
long double value;
@ -25,6 +25,8 @@ namespace Budget::OptHandlers {
Flags flags;
private:
std::string account;
};
}

View File

@ -65,7 +65,7 @@ void MainOptHandler::accountOptHandler(std::string account) {
{"description", no_argument, nullptr, 'D'},
};
auto acctOperation = std::make_unique<AccountOperation>();
auto acctOperation = std::make_unique<AccountOperation>(account);
while (true) {
int opt = getopt_long(argv.size(), argv.data(), "ha:c:e:p:dFvD", accountLongOpts, nullptr);
@ -117,7 +117,7 @@ void MainOptHandler::createOptHandler(std::string account) {
{"description", required_argument, nullptr, 'd'},
};
auto createOperation = std::make_unique<CreateOperation>();
auto createOperation = std::make_unique<CreateOperation>(account);
while (true) {
int opt = getopt_long(argv.size(), argv.data(), "ha:c:e:p:d:", createLongOpts, nullptr);
@ -162,7 +162,7 @@ void MainOptHandler::earnOptHandler(std::string account) {
{"date", required_argument, nullptr, 'D'},
};
auto earnOperation = std::make_unique<EarnOperation>();
auto earnOperation = std::make_unique<EarnOperation>(account);
while (true) {
int opt = getopt_long(argv.size(), argv.data(), "ha:c:e:p:v:d:r:D:", earnLongOpts, nullptr);
@ -233,7 +233,7 @@ void MainOptHandler::paymentOptHandler(std::string account) {
{"date", required_argument, nullptr, 'D'},
};
auto payOperation = std::make_unique<PaymentOperation>();
auto payOperation = std::make_unique<PaymentOperation>(account);
while (true) {
int opt = getopt_long(argv.size(), argv.data(), "ha:c:e:p:v:d:r:D", paymentLongOpts, nullptr);