Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Interfaces/DBM/clsTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ clsTable::clsTable(const QString& _domain,
///name type extraValidator defaultValue updatableBy isSortable isFilterable isSelfIdentifier isVirtual isPrimaryKey isSelectable renameAs
this->BaseCols.append(clsORMField(CURRENT_TIMESTAMP + "()", S(TAPI::DateTime_t), QFV, QNull, UPNone, false, false, false, true, false, true, CURRENT_TIMESTAMP));

// TargomanDebug(5).noLabel() << "register clsTable derived:" << Schema + "." + Name;

clsTable::Registry.insert(Schema + "." + Name, this);
}

Expand Down Expand Up @@ -159,6 +161,8 @@ void clsTable::prepareFiltersList() {
if (this->AllCols.size())
return;

// TargomanDebug(5).noLabel() << "prepareFiltersList:" << this->Schema + "." + this->Name;

foreach (clsORMField Col, this->BaseCols) {
if (Col.isPrimaryKey())
++this->CountOfPKs;
Expand Down
6 changes: 3 additions & 3 deletions Interfaces/ORM/intfActionLogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ using namespace Targoman::API::AAA;
namespace Targoman::API::ORM {

intfActionLogs::intfActionLogs(
const QString& _schema,
const QString& _name
const QString& _module,
const QString& _schema
) :
intfSQLBasedModule(
_module,
_schema,
_name,
tblActionLogs::Name,
tblActionLogs::Private::ORMFields,
tblActionLogs::Private::Relations,
Expand Down
6 changes: 3 additions & 3 deletions Interfaces/ORM/intfActionLogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ class intfActionLogs : public intfSQLBasedModule

public:
intfActionLogs(
const QString& _schema,
const QString& _name
);
const QString& _module,
const QString& _schema
);

protected slots:
QVariant ORMGET("Get Action Logs.")
Expand Down
6 changes: 3 additions & 3 deletions Interfaces/ORM/intfMigrations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ using namespace Targoman::API::AAA;
namespace Targoman::API::ORM {

intfMigrations::intfMigrations(
const QString& _schema,
const QString& _name
const QString& _module,
const QString& _schema
) :
intfSQLBasedModule(
_module,
_schema,
_name,
tblMigrations::Name,
tblMigrations::Private::ORMFields,
tblMigrations::Private::Relations,
Expand Down
6 changes: 3 additions & 3 deletions Interfaces/ORM/intfMigrations.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ class intfMigrations : public intfSQLBasedModule

public:
intfMigrations(
const QString &_schema,
const QString &_name
const QString& _module,
const QString& _schema
);

private slots:
Expand Down Expand Up @@ -115,7 +115,7 @@ protected: \

//put this macro into module class constructor (.cpp)
#define TARGOMAN_API_IMPLEMENT_MIGRATIONS(_module, _schema) \
this->_Migrations .reset(&Migrations ::instance()); \
this->_Migrations.reset(&Migrations::instance()); \
this->addSubModule(this->_Migrations.data());

/****************************************************/
Expand Down
18 changes: 9 additions & 9 deletions Interfaces/ObjectStorage/ORM/ObjectStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ void stuProcessUploadQueueInfo::fromVariantMap(const QVariantMap& _info) {
/******************************************************************/
/******************************************************************/
intfUploadFiles::intfUploadFiles(
const QString &_schema,
const QString &_name
const QString& _module,
const QString& _schema
) :
intfSQLBasedModule(
_module,
_schema,
_name,
tblUploadFiles::Name,
tblUploadFiles::Private::ORMFields,
tblUploadFiles::Private::Relations,
Expand All @@ -73,12 +73,12 @@ QVariant IMPL_ORMGET(intfUploadFiles) {
/******************************************************************/
/******************************************************************/
intfUploadGateways::intfUploadGateways(
const QString &_schema,
const QString &_name
const QString& _module,
const QString& _schema
) :
intfSQLBasedModule(
_module,
_schema,
_name,
tblUploadGateways::Name,
tblUploadGateways::Private::ORMFields,
tblUploadGateways::Private::Relations,
Expand Down Expand Up @@ -113,12 +113,12 @@ bool IMPL_ORMDELETE(intfUploadGateways) {
/******************************************************************/
/******************************************************************/
intfUploadQueue::intfUploadQueue(
const QString &_schema,
const QString &_name
const QString& _module,
const QString& _schema
) :
intfSQLBasedModule(
_module,
_schema,
_name,
tblUploadQueue::Name,
tblUploadQueue::Private::ORMFields,
tblUploadQueue::Private::Relations(_schema),
Expand Down
12 changes: 6 additions & 6 deletions Interfaces/ObjectStorage/ORM/ObjectStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ class intfUploadFiles : public intfSQLBasedModule

public:
intfUploadFiles(
const QString &_schema,
const QString &_name
const QString& _module,
const QString& _schema
);

struct stuObjectStorageConfigs
Expand Down Expand Up @@ -371,8 +371,8 @@ class intfUploadGateways : public intfSQLBasedModule

public:
intfUploadGateways(
const QString &_schema,
const QString &_name
const QString& _module,
const QString& _schema
);

private slots:
Expand All @@ -388,8 +388,8 @@ class intfUploadQueue : public intfSQLBasedModule

public:
intfUploadQueue(
const QString &_schema,
const QString &_name
const QString& _module,
const QString& _schema
);

private slots:
Expand Down
8 changes: 4 additions & 4 deletions Interfaces/ObjectStorage/ObjectStorageManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ void ObjectStorageManager::applyGetFileUrlInQuery(
INTFAPICALLBOOM_IMPL &APICALLBOOM_PARAM,
ORMSelectQuery &_query,
Targoman::API::ObjectStorage::ORM::intfUploadFiles &_uploadFiles,
Targoman::API::ObjectStorage::ORM::intfUploadQueue &_uploadQueue,
Targoman::API::ObjectStorage::ORM::intfUploadGateways &_uploadGateways,
Targoman::API::ObjectStorage::ORM::intfUploadQueue &_uploadQueue,
const QString &_foreignTableName,
const QString &_foreignTableUploadedFileIDFieldName
) {
Expand Down Expand Up @@ -510,12 +510,12 @@ void ObjectStorageManager::applyGetFileUrlInQuery(
.else_("CONCAT(g.ugwEndpointUrl, '/', g.ugwBucket, '/', f.uflPath, '/', f.uflStoredFileName)"),
uflFullFileUrl)

.innerJoin(/*TBL_uploadFiles->name()*/ _uploadFiles, "f",
.leftJoin(/*TBL_uploadFiles->name()*/ _uploadFiles, "f",
{ "f", tblUploadFiles::Fields::uflID,
enuConditionOperator::Equal,
_foreignTableName, _foreignTableUploadedFileIDFieldName })

.nestedInnerJoin(_uploadQueue.GetSelectQuery(APICALLBOOM_PARAM)
.nestedLeftJoin(_uploadQueue.GetSelectQuery(APICALLBOOM_PARAM)
.addCol(DBExpression::VALUE(R"(
ROW_NUMBER()
OVER (
Expand All @@ -535,7 +535,7 @@ void ObjectStorageManager::applyGetFileUrlInQuery(
.andCond({ "q.row_num", enuConditionOperator::Equal, 1 })
)

.innerJoin(_uploadGateways, "g",
.leftJoin(_uploadGateways, "g",
{ "g", tblUploadGateways::Fields::ugwID,
enuConditionOperator::Equal,
"q", tblUploadQueue::Fields::uqu_ugwID })
Expand Down
2 changes: 1 addition & 1 deletion Interfaces/ObjectStorage/ObjectStorageManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ class ObjectStorageManager
INTFAPICALLBOOM_DECL &APICALLBOOM_PARAM,
ORMSelectQuery &_query,
Targoman::API::ObjectStorage::ORM::intfUploadFiles &_uploadFiles,
Targoman::API::ObjectStorage::ORM::intfUploadQueue &_uploadQueue,
Targoman::API::ObjectStorage::ORM::intfUploadGateways &_uploadGateways,
Targoman::API::ObjectStorage::ORM::intfUploadQueue &_uploadQueue,
const QString &_foreignTableName,
const QString &_foreignTableUploadedFileIDFieldName
);
Expand Down
19 changes: 19 additions & 0 deletions Modules/Account/functionalTest/testAccount.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,9 @@ private slots:
{ "receiptDate", "2022/03/04" },
{ "amount", 14'000 },
{ "note", "this is note for offline payment 2" },
},
{
{ "file", "../../README.md" },
}
);

Expand Down Expand Up @@ -1086,6 +1089,22 @@ private slots:
}
}

void listOfflinePayments() {
QT_TRY {
QVariant Result = callAdminAPI(
RESTClientHelper::GET,
"Account/OfflinePayments",
{},
{}
);

QVERIFY(Result.isValid());

} QT_CATCH (const std::exception &exp) {
QTest::qFail(exp.what(), __FILE__, __LINE__);
}
}
private:
void UserWallets_transfer() {
QT_TRY {
QVariant Result = callUserAPI(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* Migration File: m20220719_153445_AAA_create_OfflinePaymentClaims_attachments.sql */
/* CAUTION: don't forget to use {{dbprefix}} for schemas */

USE `{{dbprefix}}{{Schema}}`;

ALTER TABLE `tblOfflinePaymentClaims`
ADD COLUMN `ofpcReceiptImage_uflID` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `ofpcNotes`,
ADD CONSTRAINT `FK_tblOfflinePaymentClaims_tblUploadFiles` FOREIGN KEY (`ofpcReceiptImage_uflID`) REFERENCES `tblUploadFiles` (`uflID`) ON UPDATE NO ACTION ON DELETE NO ACTION
;

ALTER TABLE `tblOfflinePayments`
ADD COLUMN `ofpReceiptImage_uflID` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `ofpNotes`,
ADD CONSTRAINT `FK_tblOfflinePayments_tblUploadFiles` FOREIGN KEY (`ofpReceiptImage_uflID`) REFERENCES `tblUploadFiles` (`uflID`) ON UPDATE NO ACTION ON DELETE NO ACTION
;
45 changes: 37 additions & 8 deletions Modules/Account/moduleSrc/Account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
//#include "Interfaces/ORM/APIQueryBuilders.h"
#include "Interfaces/ORM/intfAlerts.h"

#include "Interfaces/ObjectStorage/ObjectStorageManager.h"
#include "Interfaces/ObjectStorage/Gateways/gtwNFS.h"
#include "Interfaces/ObjectStorage/Gateways/gtwAWSS3.h"
using namespace Targoman::API::ObjectStorage;

#include "Interfaces/Helpers/PhoneHelper.h"
#include "Interfaces/Helpers/SecurityHelper.h"
#include "Interfaces/Helpers/RESTClientHelper.h"
Expand Down Expand Up @@ -137,12 +142,14 @@ tmplConfigurable<FilePath_t> Account::InvalidPasswordsFile (
/*****************************************************************/
TARGOMAN_IMPL_API_MODULE(Account)
TARGOMAN_API_MODULE_DB_CONFIG_IMPL(Account, AAASchema);
TARGOMAN_API_OBJECTSTORAGE_CONFIG_IMPL(Account, AAASchema)

Account::Account() :
intfSQLBasedWithActionLogsModule(AccountDomain, AAASchema)
{
TARGOMAN_API_IMPLEMENT_MIGRATIONS(Account, AAASchema)
TARGOMAN_API_IMPLEMENT_ACTIONLOG(Account, AAASchema)
TARGOMAN_API_IMPLEMENT_OBJECTSTORAGE(Account, AAASchema)

this->addSubModule(&ActiveSessions::instance());
this->addSubModule(&APITokens::instance());
Expand Down Expand Up @@ -1470,7 +1477,8 @@ quint64 IMPL_REST_POST(Account, claimOfflinePayment, (
quint32 _amount,
// NULLABLE_TYPE(quint64) voucherID,
quint64 _walID,
QString _note
QString _note,
TAPI::stuFileInfo _file
)) {
/*if (NULLABLE_HAS_VALUE(voucherID)) {
QJsonObject VoucherInfo = QJsonObject::fromVariantMap(SelectQuery(Voucher::instance())
Expand All @@ -1495,21 +1503,39 @@ quint64 IMPL_REST_POST(Account, claimOfflinePayment, (
QFV.unicodeAlNum(true).maxLenght(50).validate(_receiptCode, "receiptCode");

QVariantMap CreateParams = {
{ "ofpcBank", _bank },
{ "ofpcReceiptCode", _receiptCode },
{ "ofpcReceiptDate", _receiptDate },
{ "ofpcAmount", _amount },
{ tblOfflinePaymentClaims::Fields::ofpcBank, _bank },
{ tblOfflinePaymentClaims::Fields::ofpcReceiptCode, _receiptCode },
{ tblOfflinePaymentClaims::Fields::ofpcReceiptDate, _receiptDate },
{ tblOfflinePaymentClaims::Fields::ofpcAmount, _amount },
};

if ((_note.isNull() == false) && (_note.trimmed().length() > 0))
CreateParams.insert("ofpcNotes", _note.trimmed());
CreateParams.insert(tblOfflinePaymentClaims::Fields::ofpcNotes, _note.trimmed());

/*if (NULLABLE_HAS_VALUE(voucherID))
CreateParams.insert("ofpc_vchID", NULLABLE_VALUE(voucherID));
CreateParams.insert(tblOfflinePaymentClaims::Fields::ofpc_vchID, NULLABLE_VALUE(voucherID));
*/

if (_walID > 0)
CreateParams.insert("ofpcTarget_walID", _walID);
CreateParams.insert(tblOfflinePaymentClaims::Fields::ofpcTarget_walID, _walID);

if (_file.Size > 0) {
try {
quint64 UploadedFileID = ObjectStorageManager::saveFile(
APICALLBOOM_PARAM,
UploadFiles::instance(),
UploadQueue::instance(),
UploadGateways::instance(),
_file,
"offlinePayment"
);
if (UploadedFileID > 0)
CreateParams.insert(tblOfflinePaymentClaims::Fields::ofpcReceiptImage_uflID, UploadedFileID);

} catch (std::exception &exp) {
TargomanDebug(5, "ObjectStorageManager::saveFile(" << _file.Name << "):" << exp.what());
}
}

return OfflinePaymentClaims::instance().Create(APICALLBOOM_PARAM,
TAPI::ORMFields_t(CreateParams));
Expand Down Expand Up @@ -1629,6 +1655,9 @@ Targoman::API::AAA::stuVoucher IMPL_REST_POST(Account, approveOfflinePayment, (
if (NULLABLE_HAS_VALUE(OfflinePaymentClaimDTO.ofpcTarget_walID))
CreateParams.insert(tblOfflinePayments::Fields::ofpTarget_walID, NULLABLE_VALUE(OfflinePaymentClaimDTO.ofpcTarget_walID));

if (NULLABLE_HAS_VALUE(OfflinePaymentClaimDTO.ofpcReceiptImage_uflID))
CreateParams.insert(tblOfflinePayments::Fields::ofpReceiptImage_uflID, NULLABLE_VALUE(OfflinePaymentClaimDTO.ofpcReceiptImage_uflID));

quint64 PaymentID = OfflinePayments::instance().Create(APICALLBOOM_PARAM,
TAPI::ORMFields_t(CreateParams));

Expand Down
7 changes: 6 additions & 1 deletion Modules/Account/moduleSrc/Account.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "Interfaces/ORM/intfActionLogs.h"
#include "Interfaces/ORM/intfMigrations.h"
#include "Interfaces/ObjectStorage/ORM/ObjectStorage.h"
#include "libTargomanCommon/Configuration/tmplConfigurable.h"
#include "Interfaces/API/intfSQLBasedWithActionLogsModule.h"
#include "Interfaces/AAA/AAA.hpp"
Expand All @@ -43,6 +44,7 @@ namespace Targoman::API::AccountModule {

TARGOMAN_MIGRATIONS_PREPARENT;
TARGOMAN_ACTIONLOG_PREPARENT;
TARGOMAN_OBJECTSTORAGE_PREPARENT;

class Account : public intfSQLBasedWithActionLogsModule
{
Expand All @@ -53,6 +55,7 @@ class Account : public intfSQLBasedWithActionLogsModule
TARGOMAN_DEFINE_API_MODULE(Account);
TARGOMAN_API_DEFINE_MIGRATIONS(Account, AAASchema);
TARGOMAN_API_DEFINE_ACTIONLOG(Account, AAASchema);
TARGOMAN_API_DEFINE_OBJECTSTORAGE(Account, AAASchema);

public:
static Targoman::Common::Configuration::tmplConfigurable<FilePath_t> InvalidPasswordsFile;
Expand Down Expand Up @@ -405,7 +408,8 @@ private slots:
quint32 _amount,
// NULLABLE_TYPE(quint64) _voucherID = NULLABLE_NULL_VALUE,
quint64 _walID = 0,
QString _note = {}
QString _note = {},
TAPI::stuFileInfo _file = {}
),
"Claim offline payment by user."
"Set vchID to null just for charging wallet, otherwise after increasing the wallet, the voucher will be paid"
Expand Down Expand Up @@ -521,6 +525,7 @@ private slots:

TARGOMAN_MIGRATIONS_POSTPARENT(Account, AAASchema);
TARGOMAN_ACTIONLOG_POSTPARENT(Account, AAASchema);
TARGOMAN_OBJECTSTORAGE_POSTPARENT(Account, AAASchema);

} //namespace Targoman::API::AccountModule

Expand Down
Loading