fix: format prices in notifications, change partial payment label, and add session holding notify API
This commit is contained in:
@@ -175,11 +175,13 @@ const sendClassReminderSms = async (receiver, className, time, place = '', userI
|
||||
});
|
||||
};
|
||||
|
||||
const { formatPrice } = require('../paymentAmount');
|
||||
|
||||
const sendInvoiceCreatedSms = async (receiver, payload, userId = null) => {
|
||||
const resolvedUserId = userId || await resolveUserIdByPhone(receiver);
|
||||
const data = typeof payload === 'object' && payload !== null ? payload : { amount: payload };
|
||||
const fullNameLabel = data.fullName || 'کارآموز';
|
||||
const amountLabel = data.amount != null ? String(data.amount) : '';
|
||||
const amountLabel = data.amount != null ? formatPrice(data.amount) : '';
|
||||
const courseLabel = data.course || '-';
|
||||
|
||||
return sendTemplateSms({
|
||||
@@ -203,6 +205,7 @@ const sendInvoiceCreatedSms = async (receiver, payload, userId = null) => {
|
||||
|
||||
const sendPaymentStatusChangedSms = async (receiver, payload, userId = null) => {
|
||||
const data = payload || {};
|
||||
const amountLabel = data.amount != null ? formatPrice(data.amount) : '';
|
||||
return sendTemplateSms({
|
||||
templateKey: 'paymentStatusChanged',
|
||||
receiver,
|
||||
@@ -213,7 +216,7 @@ const sendPaymentStatusChangedSms = async (receiver, payload, userId = null) =>
|
||||
slotValues: {
|
||||
fullName: data.fullName || 'کارآموز',
|
||||
status: data.statusLabel || data.status || '-',
|
||||
amount: data.amount != null ? String(data.amount) : '',
|
||||
amount: amountLabel,
|
||||
invoiceCode: data.invoiceCode || '',
|
||||
course: data.course || '-'
|
||||
}
|
||||
@@ -222,16 +225,17 @@ const sendPaymentStatusChangedSms = async (receiver, payload, userId = null) =>
|
||||
|
||||
const sendPaymentReminderSms = async (receiver, payload, userId = null) => {
|
||||
const data = payload || {};
|
||||
const amountLabel = data.amount != null ? formatPrice(data.amount) : '-';
|
||||
return sendTemplateSms({
|
||||
templateKey: 'paymentReminder',
|
||||
receiver,
|
||||
userId,
|
||||
subject: 'یادآوری سررسید پرداخت',
|
||||
body: `یادآوری: مبلغ ${data.amount || '-'} تومان تا ${data.dueDate || '-'} سررسید دارد.`,
|
||||
body: `یادآوری: مبلغ ${amountLabel} تومان تا ${data.dueDate || '-'} سررسید دارد.`,
|
||||
relatedEvent: 'payment.reminder_due',
|
||||
slotValues: {
|
||||
fullName: data.fullName || 'کارآموز',
|
||||
amount: data.amount != null ? String(data.amount) : '',
|
||||
amount: data.amount != null ? formatPrice(data.amount) : '',
|
||||
dueDate: data.dueDate || '',
|
||||
invoiceCode: data.invoiceCode || '',
|
||||
course: data.course || '-'
|
||||
@@ -241,16 +245,17 @@ const sendPaymentReminderSms = async (receiver, payload, userId = null) => {
|
||||
|
||||
const sendTransactionRecordedSms = async (receiver, payload, userId = null) => {
|
||||
const data = payload || {};
|
||||
const amountLabel = data.amount != null ? formatPrice(data.amount) : '-';
|
||||
return sendTemplateSms({
|
||||
templateKey: 'transactionRecorded',
|
||||
receiver,
|
||||
userId,
|
||||
subject: 'ثبت تراکنش',
|
||||
body: `تراکنش به مبلغ ${data.amount || '-'} تومان ثبت شد.`,
|
||||
body: `تراکنش به مبلغ ${amountLabel} تومان ثبت شد.`,
|
||||
relatedEvent: 'payment.transaction_added',
|
||||
slotValues: {
|
||||
fullName: data.fullName || 'کارآموز',
|
||||
amount: data.amount != null ? String(data.amount) : '',
|
||||
amount: data.amount != null ? formatPrice(data.amount) : '',
|
||||
invoiceCode: data.invoiceCode || '',
|
||||
transactionCode: data.transactionCode || '',
|
||||
receiptNumber: data.receiptNumber || ''
|
||||
|
||||
Reference in New Issue
Block a user