Commit 31f048a2 authored by Martin Straka's avatar Martin Straka
Browse files

Added mandatory field checking for initiatory and reply message.

parent e0a18e71
......@@ -63,9 +63,6 @@ Item {
/* This property holds navigation arrows dimension of tabbar */
property int tabNavImageDimension: imageNavigateDimension * 0.5
/* This property holds message type for sending. */
property string dmType: ""
/* Return file name from file path */
function getFileNameFromPath(filePath) {
return filePath.replace(/^.*[\\\/]/, '')
......@@ -123,11 +120,11 @@ Item {
dmRecipientRefNumber.text = isdsEnvelope.dmSenderRefNumber
dmRecipientIdent.text = isdsEnvelope.dmSenderIdent
setMandate(isdsEnvelope)
if (isdsEnvelope.dmType === "I") {
isds.addRecipent(acntId, isdsEnvelope.dbIDSender, isdsEnvelope.dmSender, isdsEnvelope.dmSenderAddress, true, recipBoxModel);
} else {
isds.addRecipent(acntId, isdsEnvelope.dbIDSender, isdsEnvelope.dmSender, isdsEnvelope.dmSenderAddress, false, recipBoxModel);
var canUseInitReply = false
if (isdsEnvelope.dmType === "I" || isdsEnvelope.dmType === "A") {
canUseInitReply = true
}
isds.addRecipent(acntId, isdsEnvelope.dbIDSender, isdsEnvelope.dmSender, isdsEnvelope.dmSenderAddress, canUseInitReply, recipBoxModel);
}
/* Set message envelope data and files to attachment model*/
......@@ -358,7 +355,7 @@ Item {
dmRecipientRefNumber.text.toString(), dmRecipientIdent.text.toString(),
dmSenderRefNumber.text.toString(), dmSenderIdent.text.toString(),
false, dmPublishOwnID.checked, dmAllowSubstDelivery.checked,
dmPersonalDelivery.checked, dmType)
dmPersonalDelivery.checked)
}
}
......@@ -588,9 +585,18 @@ Item {
if (dmSenderRefNumber.text === "") {
tabBar.setCurrentIndex(3)
dmSenderRefNumberLabel.color = "red"
dmSenderRefNumber.placeholderText = qsTr("You must fill the value for initiatory message")
dmSenderRefNumber.placeholderText = qsTr("Mandatory for initiatory message")
dmSenderRefNumber.forceActiveFocus()
}
/* Commercial message is reply on initiatory - dmType 79. */
} else if (dmType === 79) {
/* Recipient reference number must be filled. */
if (dmRecipientRefNumber.text === "") {
tabBar.setCurrentIndex(3)
dmRecipientRefNumberLabel.color = "red"
dmRecipientRefNumber.placeholderText = qsTr("Mandatory for reply message")
dmRecipientRefNumber.forceActiveFocus()
}
}
}
} // DataboxList
......@@ -888,6 +894,7 @@ Item {
}
//---Your ref.number---------------------
AccessibleText {
id: dmRecipientRefNumberLabel
font.bold: true
text: qsTr("Your reference number")
}
......
......@@ -394,7 +394,7 @@ void Isds::Tasks::sendMessage(const AcntId &acntId, qint64 dmID,
const QString &dmRecipientRefNumber, const QString &dmRecipientIdent,
const QString &dmSenderRefNumber, const QString &dmSenderIdent,
bool dmOVM, bool dmPublishOwnID, bool dmAllowSubstDelivery,
bool dmPersonalDelivery, const QString &dmType, QSet<QString> &transactIds)
bool dmPersonalDelivery, QSet<QString> &transactIds)
{
debugFuncCall();
......@@ -424,22 +424,27 @@ void Isds::Tasks::sendMessage(const AcntId &acntId, qint64 dmID,
return;
}
/* Mesasge is PDZ init, dmSenderRefNumber must be filled */
if (dmType == "I" && dmSenderRefNumber.isEmpty()) {
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Error sending message"),
tr("Pre-paid transfer charges for message reply have been enabled."),
tr("The sender reference number must be specified in the additional section in order to send the message."));
return;
}
const QList<DataboxModelEntry> dbList = databoxModel->allEntries();
/* Mesasge is PDZ reply, dmRecipientRefNumber must be filled */
if (dmType == "O" && dmRecipientRefNumber.isEmpty()) {
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Error sending message"),
tr("Message uses the offered payment of transfer charges by the recipient."),
tr("The recipient reference number must be specified in the additional section in order to send the message."));
return;
/* Check mandatory fields for initiatory and reply commercial messages. */
foreach (const DataboxModelEntry &db, dbList) {
if (db.dmType() == Isds::Type::MT_I
&& dmSenderRefNumber.isEmpty()) {
/* Message is initiatory PDZ, dmSenderRefNumber must be filled */
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Error sending message"),
tr("Pre-paid transfer charges for message reply have been enabled."),
tr("The sender reference number must be specified in the additional section in order to send the message."));
return;
} else if (db.dmType() == Isds::Type::MT_O
&& dmRecipientRefNumber.isEmpty()) {
/* Message is PDZ reply on initiatory message, dmRecipientRefNumber must be filled */
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Error sending message"),
tr("Message uses the offered payment of transfer charges by the recipient."),
tr("The recipient reference number must be specified in the additional section in order to send the message."));
return;
}
}
Isds::Envelope envelope;
......@@ -459,7 +464,6 @@ void Isds::Tasks::sendMessage(const AcntId &acntId, qint64 dmID,
Isds::Type::BOOL_TRUE : Isds::Type::BOOL_FALSE);
envelope.setDmPersonalDelivery(dmPersonalDelivery ?
Isds::Type::BOOL_TRUE : Isds::Type::BOOL_FALSE);
envelope.setDmType(Isds::str2Char(dmType));
envelope.setDmMessageStatus(Isds::Type::MS_POSTED);
envelope.setDmOVM(dmOVM ? Isds::Type::BOOL_TRUE :
Isds::Type::BOOL_FALSE);
......@@ -529,8 +533,6 @@ void Isds::Tasks::sendMessage(const AcntId &acntId, qint64 dmID,
/* Set total attachment size in KB from attachment model. */
envelope.setDmAttachmentSize(attachModel->dataSizeSum() / 1024);
const QList<DataboxModelEntry> dbList = databoxModel->allEntries();
/* List of unique identifiers. */
QStringList taskIdentifiers;
const QDateTime currentTime(QDateTime::currentDateTimeUtc());
......
......@@ -206,7 +206,6 @@ namespace Isds {
* @param[in] dmPublishOwnID True if add sender name to message.
* @param[in] dmAllowSubstDelivery True if allow acceptance by fiction.
* @param[in] dmPersonalDelivery True if personal delivery.
* @param[in] dmType Message type [K,V,I,O,...].
* @param[in,out] transactIds Send transaction ids.
*/
static
......@@ -219,8 +218,7 @@ namespace Isds {
const QString &dmRecipientRefNumber, const QString &dmRecipientIdent,
const QString &dmSenderRefNumber, const QString &dmSenderIdent,
bool dmOVM, bool dmPublishOwnID, bool dmAllowSubstDelivery,
bool dmPersonalDelivery, const QString &dmType,
QSet<QString> &transactIds);
bool dmPersonalDelivery, QSet<QString> &transactIds);
/*!
* @brief Sent SMS request.
......
......@@ -398,7 +398,7 @@ void IsdsWrapper::sendMessage(const QmlAcntId *qAcntId, qint64 dmID,
const QString &dmRecipientRefNumber, const QString &dmRecipientIdent,
const QString &dmSenderRefNumber, const QString &dmSenderIdent,
bool dmOVM, bool dmPublishOwnID, bool dmAllowSubstDelivery,
bool dmPersonalDelivery, const QString &dmType)
bool dmPersonalDelivery)
{
if (Q_UNLIKELY(qAcntId == Q_NULLPTR)) {
Q_ASSERT(0);
......@@ -413,7 +413,7 @@ void IsdsWrapper::sendMessage(const QmlAcntId *qAcntId, qint64 dmID,
attachModel, dmLegalTitleLaw, dmLegalTitleYear, dmLegalTitleSect,
dmLegalTitlePar, dmLegalTitlePoint, dmToHands, dmRecipientRefNumber,
dmRecipientIdent, dmSenderRefNumber, dmSenderIdent, dmOVM,
dmPublishOwnID, dmAllowSubstDelivery, dmPersonalDelivery, dmType,
dmPublishOwnID, dmAllowSubstDelivery, dmPersonalDelivery,
m_transactIds);
}
......
......@@ -242,7 +242,6 @@ public:
* @param[in] dmPublishOwnID True if add sender name to message.
* @param[in] dmAllowSubstDelivery True if allow acceptance by fiction.
* @param[in] dmPersonalDelivery True if personal delivery.
* @param[in] dmType Message type [K,V,I,O,...].
*/
Q_INVOKABLE
void sendMessage(const QmlAcntId *qAcntId, qint64 dmID,
......@@ -254,7 +253,7 @@ public:
const QString &dmRecipientRefNumber, const QString &dmRecipientIdent,
const QString &dmSenderRefNumber, const QString &dmSenderIdent,
bool dmOVM, bool dmPublishOwnID, bool dmAllowSubstDelivery,
bool dmPersonalDelivery, const QString &dmType);
bool dmPersonalDelivery);
/*!
* @brief Sent SMS request.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment