Repository: Accenture/sfmc-devtools (js)

Issue:
[BUG] In the doc .md files for Data Extensions, Decimal field type has only presicion, not scale 
### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

.json files retrieved for Data Extensions, for Decimal fields, contain both Scale and Max Length (Precision). But doc .md files take only value from Max Length field. So if the Decimal field has length 18 and scale 8, in doc .md file, only Max Length of 18 is included and scale 8 is ignored.

### Expected Behavior

If Decimal field have precision 18 and scale 8, I prefer to see it in doc .md file in the same way as in SFMC UI - as 18,8. It would be valuable, when sharing the schama of the tables with teams outside SFMC.

### Steps To Reproduce

1. Retrieve Data Extensions.
2. Open .md file for one of the Data Extensions with Decimal fields.
3. Previed .md file.
4. See that only precision is shown in Max Lenght field, and scal is ignored.


### Version

5.2.0

### Environment

- OS: Windows 11
- Node: 18.15.0
- npm: 9.8.1


### Participation

- [X] I am willing to submit a pull request for this issue.

### Additional comments

_No response_

Pull request:
Bugfix/1097 in the doc md files for `dataExtension`s decimal field type has only precision not scale
# PR details

## What changes did you make? (Give an overview)

- closes #1097



## Checklist

- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- n/a test scripts updated
- n/a Wiki updated (if applicable)


Patch:
diff --git a/lib/metadataTypes/DataExtension.js b/lib/metadataTypes/DataExtension.js
index 07dfe363..86fe9e34 100644
--- a/lib/metadataTypes/DataExtension.js
+++ b/lib/metadataTypes/DataExtension.js
@@ -1215,7 +1215,11 @@ class DataExtension extends MetadataType {
             for (const element of fieldsJson) {
                 const newJsonElement = {};
                 for (const field of fieldsToKeep) {
-                    newJsonElement[field] = element[field];
+                    if (field === 'MaxLength' && element.FieldType === 'Decimal') {
+                        newJsonElement.MaxLength = `${element.MaxLength},${element.Scale}`;
+                    } else {
+                        newJsonElement[field] = element[field];
+                    }
                 }
                 newJson.push(newJsonElement);
             }


Test patch:
diff --git a/test/resources/9999999/dataExtension/build-expected.json b/test/resources/9999999/dataExtension/build-expected.json
index f31d2e87..21d43fdb 100644
--- a/test/resources/9999999/dataExtension/build-expected.json
+++ b/test/resources/9999999/dataExtension/build-expected.json
@@ -44,6 +44,22 @@
             "IsRequired": true,
             "IsPrimaryKey": true,
             "FieldType": "Text"
+        },
+        {
+            "Name": "decimalField",
+            "DefaultValue": "",
+            "MaxLength": 6,
+            "Scale": 3,
+            "IsPrimaryKey": false,
+            "IsRequired": true,
+            "FieldType": "Decimal"
+        },
+        {
+            "Name": "numberField",
+            "DefaultValue": "",
+            "IsPrimaryKey": false,
+            "IsRequired": true,
+            "FieldType": "Number"
         }
     ],
     "r__folder_ContentType": "dataextension",
diff --git a/test/resources/9999999/dataExtension/retrieve-expected.json b/test/resources/9999999/dataExtension/retrieve-expected.json
index bf80cd12..c8c945cc 100644
--- a/test/resources/9999999/dataExtension/retrieve-expected.json
+++ b/test/resources/9999999/dataExtension/retrieve-expected.json
@@ -44,6 +44,22 @@
             "IsRequired": true,
             "IsPrimaryKey": true,
             "FieldType": "Text"
+        },
+        {
+            "Name": "decimalField",
+            "DefaultValue": "",
+            "MaxLength": 6,
+            "Scale": 3,
+            "IsPrimaryKey": false,
+            "IsRequired": true,
+            "FieldType": "Decimal"
+        },
+        {
+            "Name": "numberField",
+            "DefaultValue": "",
+            "IsPrimaryKey": false,
+            "IsRequired": true,
+            "FieldType": "Number"
         }
     ],
     "r__folder_ContentType": "dataextension",
diff --git a/test/resources/9999999/dataExtension/retrieve-expected.md b/test/resources/9999999/dataExtension/retrieve-expected.md
index fda321a2..4f222148 100644
--- a/test/resources/9999999/dataExtension/retrieve-expected.md
+++ b/test/resources/9999999/dataExtension/retrieve-expected.md
@@ -4,7 +4,7 @@
 
 **Folder:** Data Extensions/
 
-**Fields in table:** 4
+**Fields in table:** 6
 
 **Sendable:** Yes (`ContactKey` to `Subscriber Key`)
 
@@ -16,3 +16,5 @@
 | LastName | Text | 50 | - | + |  |
 | EmailAddress | EmailAddress | 254 | - | - |  |
 | ContactKey | Text | 50 | + | - |  |
+| decimalField | Decimal | 6,3 | - | - |  |
+| numberField | Number |  | - | - |  |
diff --git a/test/resources/9999999/dataExtension/template-expected.json b/test/resources/9999999/dataExtension/template-expected.json
index 5c3cd96b..c2513cfa 100644
--- a/test/resources/9999999/dataExtension/template-expected.json
+++ b/test/resources/9999999/dataExtension/template-expected.json
@@ -44,6 +44,22 @@
             "IsRequired": true,
             "IsPrimaryKey": true,
             "FieldType": "Text"
+        },
+        {
+            "Name": "decimalField",
+            "DefaultValue": "",
+            "MaxLength": 6,
+            "Scale": 3,
+            "IsPrimaryKey": false,
+            "IsRequired": true,
+            "FieldType": "Decimal"
+        },
+        {
+            "Name": "numberField",
+            "DefaultValue": "",
+            "IsPrimaryKey": false,
+            "IsRequired": true,
+            "FieldType": "Number"
         }
     ],
     "r__folder_ContentType": "dataextension",
diff --git a/test/resources/9999999/dataExtension/update-expected.json b/test/resources/9999999/dataExtension/update-expected.json
index bc10677a..7106168c 100644
--- a/test/resources/9999999/dataExtension/update-expected.json
+++ b/test/resources/9999999/dataExtension/update-expected.json
@@ -41,6 +41,22 @@
             "IsPrimaryKey": true,
             "FieldType": "Text"
         },
+        {
+            "Name": "decimalField",
+            "DefaultValue": "",
+            "MaxLength": 6,
+            "Scale": 3,
+            "IsPrimaryKey": false,
+            "IsRequired": true,
+            "FieldType": "Decimal"
+        },
+        {
+            "Name": "numberField",
+            "DefaultValue": "",
+            "IsPrimaryKey": false,
+            "IsRequired": true,
+            "FieldType": "Number"
+        },
         {
             "Name": "testField",
             "DefaultValue": "",
diff --git a/test/resources/9999999/dataExtensionField/retrieve-DataExtension.CustomerKey=testExisting_dataExtension-response.xml b/test/resources/9999999/dataExtensionField/retrieve-DataExtension.CustomerKey=testExisting_dataExtension-response.xml
index 3ffc1b3e..c927c225 100644
--- a/test/resources/9999999/dataExtensionField/retrieve-DataExtension.CustomerKey=testExisting_dataExtension-response.xml
+++ b/test/resources/9999999/dataExtensionField/retrieve-DataExtension.CustomerKey=testExisting_dataExtension-response.xml
@@ -93,6 +93,41 @@
                     <CustomerKey>testExisting_dataExtension</CustomerKey>
                 </DataExtension>
             </Results>
+            <Results xsi:type="DataExtensionField">
+                <PartnerKey xsi:nil="true" />
+                <ObjectID>7b7ef009-4b85-455b-9bdf-b7bef93791d7</ObjectID>
+                <CustomerKey>[testExisting_dataExtension].[numberField]</CustomerKey>
+                <Name>numberField</Name>
+                <Scale>0</Scale>
+                <DefaultValue />
+                <IsRequired>true</IsRequired>
+                <Ordinal>5</Ordinal>
+                <IsPrimaryKey>false</IsPrimaryKey>
+                <FieldType>Number</FieldType>
+                <DataExtension>
+                    <PartnerKey xsi:nil="true" />
+                    <ObjectID xsi:nil="true" />
+                    <CustomerKey>testExisting_dataExtension</CustomerKey>
+                </DataExtension>
+            </Results>
+            <Results xsi:type="DataExtensionField">
+                <PartnerKey xsi:nil="true" />
+                <ObjectID>c5d553cc-2c2a-464d-953d-6901be040f20</ObjectID>
+                <CustomerKey>[testExisting_dataExtension].[decimalField]</CustomerKey>
+                <Name>decimalField</Name>
+                <Scale>3</Scale>
+                <DefaultValue />
+                <MaxLength>6</MaxLength>
+                <IsRequired>true</IsRequired>
+                <Ordinal>4</Ordinal>
+                <IsPrimaryKey>false</IsPrimaryKey>
+                <FieldType>Decimal</FieldType>
+                <DataExtension>
+                    <PartnerKey xsi:nil="true" />
+                    <ObjectID xsi:nil="true" />
+                    <CustomerKey>testExisting_dataExtension</CustomerKey>
+                </DataExtension>
+            </Results>
         </RetrieveResponseMsg>
     </soap:Body>
-</soap:Envelope>
\ No newline at end of file
+</soap:Envelope>
diff --git a/test/resources/9999999/dataExtensionField/retrieve-response.xml b/test/resources/9999999/dataExtensionField/retrieve-response.xml
index 3ffc1b3e..c927c225 100644
--- a/test/resources/9999999/dataExtensionField/retrieve-response.xml
+++ b/test/resources/9999999/dataExtensionField/retrieve-response.xml
@@ -93,6 +93,41 @@
                     <CustomerKey>testExisting_dataExtension</CustomerKey>
                 </DataExtension>
             </Results>
+            <Results xsi:type="DataExtensionField">
+                <PartnerKey xsi:nil="true" />
+                <ObjectID>7b7ef009-4b85-455b-9bdf-b7bef93791d7</ObjectID>
+                <CustomerKey>[testExisting_dataExtension].[numberField]</CustomerKey>
+                <Name>numberField</Name>
+                <Scale>0</Scale>
+                <DefaultValue />
+                <IsRequired>true</IsRequired>
+                <Ordinal>5</Ordinal>
+                <IsPrimaryKey>false</IsPrimaryKey>
+                <FieldType>Number</FieldType>
+                <DataExtension>
+                    <PartnerKey xsi:nil="true" />
+                    <ObjectID xsi:nil="true" />
+                    <CustomerKey>testExisting_dataExtension</CustomerKey>
+                </DataExtension>
+            </Results>
+            <Results xsi:type="DataExtensionField">
+                <PartnerKey xsi:nil="true" />
+                <ObjectID>c5d553cc-2c2a-464d-953d-6901be040f20</ObjectID>
+                <CustomerKey>[testExisting_dataExtension].[decimalField]</CustomerKey>
+                <Name>decimalField</Name>
+                <Scale>3</Scale>
+                <DefaultValue />
+                <MaxLength>6</MaxLength>
+                <IsRequired>true</IsRequired>
+                <Ordinal>4</Ordinal>
+                <IsPrimaryKey>false</IsPrimaryKey>
+                <FieldType>Decimal</FieldType>
+                <DataExtension>
+                    <PartnerKey xsi:nil="true" />
+                    <ObjectID xsi:nil="true" />
+                    <CustomerKey>testExisting_dataExtension</CustomerKey>
+                </DataExtension>
+            </Results>
         </RetrieveResponseMsg>
     </soap:Body>
-</soap:Envelope>
\ No newline at end of file
+</soap:Envelope>