kima2/src/core/sale.cpp

16 lines
383 B
C++
Raw Normal View History

2018-07-12 13:34:17 +02:00
#include "sale.h"
#include <numeric>
2018-07-12 13:42:22 +02:00
void Sale::addArticle(std::shared_ptr<Article> articlePtr)
{
2018-07-12 14:39:08 +02:00
articlePtr->setSale(this);
2018-07-12 13:42:22 +02:00
articles_.push_back(articlePtr);
}
2018-07-12 13:34:17 +02:00
int Sale::sumInCents()
{
2018-07-12 13:42:22 +02:00
int sum = std::accumulate(articles_.begin(), articles_.end(), 0,
[](int a, std::shared_ptr<Article> b) { return a + b->getPrice(); });
return sum;
2018-07-12 13:34:17 +02:00
}