---
tags: mPOS
---
<style>
table.outerT > tbody > tr > td,
table.outerT > tbody > tr{
border: 0px;
}
</style>
# mPOS 促銷 MM → THD/TDL
[toc]
----
## 商品輸入
### 商品登入 Transaction.data.detailCode (TDL.CODE) = 'R'

<table>
<thead><tr>
<th colspan='4'>Transaction.data (TDL) </th></tr>
<tr><th>detailCode (code)</th></tr>
</thead>
<tbody>
<tr><td>R</td></tr>
</tbody>
</table>
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>Product</th></tr>
<tr><th>vipPrice</th></tr>
</thead>
<tbody>
<tr><td><code>vipPrice</code></td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='3'>Transaction.data (TDL) </th></tr>
<tr><th>normalAmt</th></tr>
</thead>
<tbody>
<tr><td colspan='2'><code>vipPrice</code></td></tr>
</tbody>
</table>
</td>
</table>
---
### 折抵項 Transaction.data.detailCode (TDL.CODE) = 'M'

<table>
<thead><tr>
<th colspan='4'>Transaction.data (TDL) </th></tr>
<tr><th>detailCode (code)</th><th>normalAmt</th><th>taxIncludeAmt <br/> (amount)</th><th>salesPromotionAmt (sp_amt)</th></tr>
</thead>
<tbody>
<tr><td>M</td><td>0</td><td><i>sum(</i>mmShareDiscountAmt<i>)</i></td><td>0</td></tr>
</tbody>
</table>
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>MM</th></tr>
<tr><th>storeBounds</th></tr>
</thead>
<tbody>
<tr><td><code>補貼款</code></td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>storeBounds (STORE_BOUNDS)</th></tr>
</thead>
<tbody>
<tr><td><code>補貼款</code></td></tr>
</tbody>
</table>
</td>
</table>
<table class="outerT">
<td>
<pre>
Product : {
"mm":[
...,
{
...,
"mmType": <span style="color:red"><mmType></span>,
"storeBounds":<span style="color:red"><storeBounds></span>,
"promoteName":<span style="color:red"><promoteName></span>
}
]
}</pre>
</td>
<td>→</td>
<td>
<pre>
Transaction : {
...
"data": [
{ ... ,
"detailCode": "R",
"price": {
...
"mmShareDiscountAmt": <i>mmShareDiscountAmt</i>,
...
},
...
},
... ,
{
...
"pluNo": <span style="color:blue">""</span>,
"pluSpec": <span style="color:blue">""</span>,
"name": <span style="color:red"><promoteName></span>,
"storeBounds": <span style="color:red"><storeBounds></span>,
"mmType": <span style="color:red"><mmType></span>,
"groupNo": <span style="color:blue">"0"</span>,
"detailCode": <span style="color:red">"M"</span>,
"salesPromotionQuantity": <span style="color:blue">0</span>,
"price": {
"taxIncludeAmt": <span style="color:red"><i>Σ mmShareDiscountAmount</i></span>,
},
...
}
]
}</pre>
</td>
</table>
---
## 買送 MM_TYPE: N
> General column values for MM_TYPE = N
<table>
<thead><tr>
<th colspan='3'>Transaction.data (TDL) </th></tr>
<tr><th>taxIncludeAmt (amount)</th><th>salesPromotionAmt (sp_amt)</th></tr>
</thead>
<tbody>
<tr><td>normalAmt * quantity</td><td>taxIncludeAmt + mmShareDiscountAmt</td></tr>
</tbody>
</table>
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>mmShareDiscountAmt</th></tr>
</thead>
<tbody>
<tr><td><code>mmShareDiscountAmt</code></td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='3'>Transaction (THD) </th></tr>
<tr><th>totalDiscountAmount</th><th>promotionDiscountAmount</th></tr>
</thead>
<tbody>
<tr><td colspan='2'><i>sum(</i> <code>mmShareDiscountAmt</code> <i>)</i></td></tr>
</tbody>
</table>
</td>
</table>
----
### 買送 - 固定售價 MM_TYPE: N , AMT_TYPE: F
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>MM</th></tr>
<tr><th>MM_TYPE</th><th>AMT_TYPE</th></tr>
</thead>
<tbody>
<tr><td>N</td><td>F</td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>MM_TYPE</th><th>PRICE_TYPE</th></tr>
</thead>
<tbody>
<tr><td>N</td><td>N</td></tr>
</tbody>
</table>
</td>
</table>
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>MM</th></tr>
<tr><th>group<x>qty</th><th>g<x>ShareValue</th></tr>
</thead>
<tbody>
<tr><td><code>qty</code></td><td><code>val</code></td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>mmShareDiscountAmt (MM_DIS_SH) </th></tr>
</thead>
<tbody>
<tr><td><code>qty</code> * <code>val</code> * -1</td></tr>
</tbody>
</table>
</td>
</table>
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>MM</th></tr>
<tr><th>MM_AMOUNT</th></tr>
</thead>
<tbody>
<tr><td><code>amt</code></td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction (THD) </th></tr>
<tr><th>subtotal</th></tr>
</thead>
<tbody>
<tr><td><code>amt</code></td></tr>
</tbody>
</table>
</td>
</table>
### ↳ 加 滿額促
THD

TDL

<table>
<thead><tr>
<th colspan='3'>Transaction.data (TDL)</th></tr>
<tr><th>MM_TYPE</th><th>PRICE_TYPE</th><th>mmShareDiscountAmt (MM_DIS_SH)</th></tr>
</thead>
<tbody>
<tr>
<td> N</td><td> <b>D</b></td><td> 0</td>
</tr>
</tbody>
</table>
<table class="outerT">
<td>
<table>
<thead>
<tr><th colspan='1'>MM_PLU</th></tr>
<tr><th>DM_PRICE</th></tr>
</thead>
<tbody>
<tr><td><code>dmPrice</code></td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>taxIncludeAmt <br/>(AMOUNT) </th><th>salesPromotionAmt <br/>(SP_AMT) </th></tr>
</thead>
<tbody>
<tr ><td colspan='2'><code>dmPrice</code></td></tr>
</tbody>
</table>
</td>
</table>
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.Data</th></tr>
<tr><th>normalAmt</th><th>taxIncludeAmount</th></tr>
</thead>
<tbody>
<tr>
<td><code>normalAmt</code></td>
<td><code>amount</code></td>
</tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction (THD) </th></tr>
<tr><th>totalDiscountAmount</th><th>promotionDiscountAmount</th></tr>
</thead>
<tbody>
<tr><td colspan="2"><code>amount</code> - <code>normalAmt</code></tr>
</tbody>
</table>
</td>
</table>
----
### 買送 - 折讓額 MM_TYPE: N , AMT_TYPE: C
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>MM</th></tr>
<tr><th>MM_TYPE</th><th>AMT_TYPE</th></tr>
</thead>
<tbody>
<tr><td>N</td><td>C</td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>MM_TYPE</th><th>PRICE_TYPE</th></tr>
</thead>
<tbody>
<tr><td>N</td><td>N</td></tr>
</tbody>
</table>
</td>
</table>
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>MM</th></tr>
<tr><th>MM_AMOUNT</th></tr>
</thead>
<tbody>
<tr><td><code>amt</code></td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction (THD) </th></tr>
<tr><th>totalDiscountAmount</th><th>promotionDiscountAmount</th></tr>
</thead>
<tbody>
<tr><td colspan="2"><code>amt</code> * -1</td></tr>
</tbody>
</table>
</td>
</table>
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='3'>MM</th></tr>
<tr><th>group<x>qty</th><th>g<x>ShareValue</th></tr>
</thead>
<tbody>
<tr><td><code>qty</code></td><td><code>val</code></td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>mmShareDiscountAmt (MM_DIS_SH) </th></tr>
</thead>
<tbody>
<tr><td><code>qty</code> * <code>val</code> * -1</td></tr>
</tbody>
</table>
</td>
</table>
----
### 買送 - 折扣率 MM_TYPE: N , AMT_TYPE: D
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>MM</th></tr>
<tr><th>MM_TYPE</th><th>AMT_TYPE</th></tr>
</thead>
<tbody>
<tr><td>N</td><td>D</td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>MM_TYPE</th><th>PRICE_TYPE</th></tr>
</thead>
<tbody>
<tr><td>N</td><td>N</td></tr>
</tbody>
</table>
</td>
</table>
> 總折扣額 = 總商品金額 * (1-mmAMOUNT/100) * (-1)
<table class="outerT">
<td>
<table>
<thead><tr>
<th>MM</th><th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>MM_AMOUNT</th><th>normalAmt</th></tr>
</thead>
<tbody>
<tr>
<td><code>mmAmt</code> (1 ~ 99)</td>
<td><code>itemAmt</code></td>
</tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction (THD)</th></tr>
<tr><th>totalDiscountAmt</th><th>promotionDiscountAmt</th></tr>
</thead>
<tbody>
<tr><td colspan='2'> <i>sum</i>(<code>itemAmt</code>) * (1-<code>mmAmt</code>/100) * -1</td></tr>
</tbody>
</table>
</td>
</table>
#### If MM.shareEquFlag (IF_EQU_DIV) == 1
>分攤金額計算公式 = 總折扣額 * 各單品金額 / 總商品金額
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction (THD)</th></tr>
<tr><th>totalDiscountAmt</th></tr>
</thead>
<tbody>
<tr><td colspan='2'> <code>discAmt</code></td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>mmShareDiscountAmt (MM_DIS_SH)</th></tr>
</thead>
<tbody>
<tr>
<td> <code>discAmt</code> * normalAmt / <i>sum</i>(normalAmt)</td>
</tr>
</tbody>
</table>
</td>
</table>
:::info
?? Not sure how calculation goes with `shareEquFlag = 0` using `g<x>_sharevalue`
:::
<!-- <table class="outerT">
<td>
<table>
<thead><tr>
<th>MM</th></tr>
<tr><th>MM_AMOUNT</th></tr>
</thead>
<tbody>
<tr><td><code>amt</code> (1 ~ 99)</td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>mmShareDiscountAmt (MM_DIS_SH) </th></tr>
</thead>
<tbody>
<tr><td> taxIncludeAmt * (1 - (<code>amt</code>/100)) * -1 </td></tr>
</tbody>
</table>
</td>
</table> -->
<!-- #### Else if shareEquFlag == 0
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='3'>MM</th></tr>
<tr><th>shareEquFlag</th><th>MM_AMOUNT</th><th>g<x>ShareValue</th></tr>
</thead>
<tbody>
<tr><td>0</td><td><code>amt</code></td><td><code>shareVal</code></td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>mmShareDiscountAmt (MM_DIS_SH) </th></tr>
</thead>
<tbody>
<tr><td>taxIncludeAmt * 1 - (<code>amt</code>)/100 * -1 </td></tr>
</tbody>
</table>
</td>
</table> -->
----
## 特價 MM_TYPE: D , AMT_TYPE: null
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>MM</th></tr>
<tr><th>MM_TYPE</th><th>AMT_TYPE</th></tr>
</thead>
<tbody>
<tr><td>D</td><td></td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>MM_TYPE</th><th>PRICE_TYPE</th></tr>
</thead>
<tbody>
<tr><td></td><td>D</td></tr>
</tbody>
</table>
</td>
</table>
<table class="outerT">
<td>
<table>
<thead>
<tr><th colspan='1'>MM</th></tr>
<tr><th>DM_PRICE</th></tr>
</thead>
<tbody>
<tr><td><code>dmPrice</code></td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>taxIncludeAmt <br/>(AMOUNT) </th><th>salesPromotionAmt <br/>(SP_AMT) </th></tr>
</thead>
<tbody>
<tr ><td colspan='2'><code>dmPrice</code></td></tr>
</tbody>
</table>
</td>
</table>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL) </th></tr>
<tr><th>mmShareDiscountAmount</th></tr>
</thead>
<tbody>
<tr><td>0</td></tr>
</tbody>
</table>
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.Data</th></tr>
<tr><th>normalAmt</th><th>taxIncludeAmount</th></tr>
</thead>
<tbody>
<tr>
<td><code>normalAmt</code></td>
<td><code>amount</code></td>
</tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction (THD) </th></tr>
<tr><th>totalDiscountAmount</th><th>promotionDiscountAmount</th></tr>
</thead>
<tbody>
<tr><td colspan="2"><code>amount</code> - <code>normalAmt</code></tr>
</tbody>
</table>
</td>
</table>
----
## 門號套餐 MM_TYPE: B , AMT_TYPE: C
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>MM</th></tr>
<tr><th>MM_TYPE</th><th>AMT_TYPE</th></tr>
</thead>
<tbody>
<tr><td>B</td><td>C</td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>MM_TYPE</th><th>PRICE_TYPE</th></tr>
</thead>
<tbody>
<tr><td>B</td><td>N</td></tr>
</tbody>
</table>
</td>
</table>
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>MM</th></tr>
<tr><th>MM_AMOUNT</th></tr>
</thead>
<tbody>
<tr><td><code>amt</code></td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction (THD) </th></tr>
<tr><th>totalDiscountAmount</th><th>promotionDiscountAmount</th></tr>
</thead>
<tbody>
<tr><td colspan="2"><code>amt</code> * -1</td></tr>
</tbody>
</table>
</td>
</table>
>分攤金額計算公式 = 總折扣額 * 各單品金額 / 總商品金額
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction (THD)</th></tr>
<tr><th>totalDiscountAmt</th></tr>
</thead>
<tbody>
<tr><td colspan='2'> <code>discAmt</code></td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>mmShareDiscountAmt (MM_DIS_SH)</th></tr>
</thead>
<tbody>
<tr>
<td> <code>discAmt</code> * normalAmt / <i>sum</i>(normalAmt)</td>
</tr>
</tbody>
</table>
</td>
</table>
----
## 門號可攜 (全館折抵) MM_TYPE: T , AMT_TYPE: null
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>MM</th></tr>
<tr><th>MM_TYPE</th><th>AMT_TYPE</th></tr>
</thead>
<tbody>
<tr><td>T</td><td></td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>MM_TYPE</th><th>PRICE_TYPE</th></tr>
</thead>
<tbody>
<tr><td>T</td><td>N</td></tr>
</tbody>
</table>
</td>
</table>
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>MM</th></tr>
<tr><th>MM_AMOUNT</th></tr>
</thead>
<tbody>
<tr><td><code>amt</code></td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction (THD) </th></tr>
<tr><th>promotionDiscountAmount</th></tr>
</thead>
<tbody>
<tr><td colspan="2"><code>amt</code> * -1</td></tr>
</tbody>
</table>
</td>
</table>
<table>
<thead><tr>
<th colspan='2'>Transaction (THD) </th></tr>
<tr><th>totalDiscountAmount</th></tr>
</thead>
<tbody>
<tr><td colspan="2">0</td></tr>
</tbody>
</table>
<table>
<thead><tr>
<th colspan='3'>Transaction.data (TDL)</th></tr>
<tr><th>mmShareDiscountAmt (MM_DIS_SH)</th><th>salesPromotionAmt</th><th>salesPromotionQuantity</th></tr>
</thead>
<tbody>
<tr>
<td> 0</td><td> 0</td><td> 0</td>
</tr>
</tbody>
</table>
----
## 滿額 MM_TYPE: F , AMT_TYPE: A/S/P
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>MM</th></tr>
<tr><th>MM_TYPE</th><th>AMT_TYPE</th></tr>
</thead>
<tbody>
<tr><td>F</td><td>A/S/P</td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>MM_TYPE</th><th>PRICE_TYPE</th></tr>
</thead>
<tbody>
<tr><td>F</td><td>D</td></tr>
</tbody>
</table>
</td>
</table>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>mmShareDiscountAmt (MM_DIS_SH)</th></tr>
</thead>
<tbody>
<tr>
<td> 0</td>
</tr>
</tbody>
</table>
<table class="outerT">
<td>
<table>
<thead>
<tr><th colspan='1'>MM_PLU</th></tr>
<tr><th>DM_PRICE</th></tr>
</thead>
<tbody>
<tr><td><code>dmPrice</code></td></tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.data (TDL)</th></tr>
<tr><th>taxIncludeAmt <br/>(AMOUNT) </th><th>salesPromotionAmt <br/>(SP_AMT) </th></tr>
</thead>
<tbody>
<tr ><td colspan='2'><code>dmPrice</code></td></tr>
</tbody>
</table>
</td>
</table>
<table class="outerT">
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction.Data</th></tr>
<tr><th>normalAmt</th><th>taxIncludeAmount</th></tr>
</thead>
<tbody>
<tr>
<td><code>normalAmt</code></td>
<td><code>amount</code></td>
</tr>
</tbody>
</table>
</td>
<td>→</td>
<td>
<table>
<thead><tr>
<th colspan='2'>Transaction (THD) </th></tr>
<tr><th>totalDiscountAmount</th><th>promotionDiscountAmount</th></tr>
</thead>
<tbody>
<tr><td colspan="2"><code>amount</code> - <code>normalAmt</code></tr>
</tbody>
</table>
</td>
</table>