---
# System prepended metadata

title: 合約新功能文件

---

## 合約新功能文件 

### API

#### POST [api2/contract/edit/{id}/save]

##### resquest

``` json
新增payload參數

        {
            'additions':{
                'bills_drafts':"合約的帳單草稿json"    
            }        
        }

```
#### GET api/contract/createBillDraft

##### resquest

``` json


        {
            
            
            
        }


```

##### response
![image](https://hackmd.io/_uploads/BypzlPlQA.png)

``` json
{
    "data":{

            "date_expire":"繳費期限 [bill.date_expire]",
            "date_start":"帳單週期初始日 [bill.date_start]",
            "date_end":"帳單週期結束日 [bill.date_end]",
            "theory_date_start":"帳單週期分母初始日 [bill.theory_date_start]",
            "theory_date_end":"帳單週期分母結束日 [bill.theory_date_end]",
            "data":"json，billData，帳單生活費用（不算租金押金）(deprecated but save) [bill.data]",  //??這是什麼費用
            "note":"帳單說明(標題) [bill.note]",
            "remark":"帳單備註 [bill.date_expire_remark]",
            "status": "0封存1草稿2應到帳16已到帳",  
            "attachment":{"陣列":"附件陣列"},
            "fees":{"陣列":"租金費用生活費用"},
            "custom_fees":{"陣列":"客製費用"},
        },
    {

            "date_expire":"繳費期限 [bill.date_expire]",
            "date_start":"帳單週期初始日 [bill.date_start]",
            "date_end":"帳單週期結束日 [bill.date_end]",
            "theory_date_start":"帳單週期分母初始日 [bill.theory_date_start]",
            "theory_date_end":"帳單週期分母結束日 [bill.theory_date_end]",
            "data":"json，billData，帳單生活費用（不算租金押金）(deprecated but save) [bill.data]",
            "note":"帳單說明(標題) [bill.note]",
            "remark":"帳單備註 [bill.date_expire_remark]",
            "status": "0封存1草稿2應到帳16已到帳",  
            "attachment":{"陣列":"附件陣列"},
            "fees":{"陣列":"租金費用生活費用"},
            "custom_fees":{"陣列":"客製費用"},      
        }
    }
}
///////////////
"attachment":{
    "0":{        
        "type": "附件副檔名",
        "url": "附件url(不含網域)"
    }
}
/////////////
// 資料會改成，不管有沒有值或用不用到，都會拋給前端
// 
"fees":{
    "0":{
        "item_id": null,
        "type": "income=0收入/expense=1支出  [item.fee_type]", // 要先用buildCustomFeesData轉換成'fee_type'
        "label": "前端顯示費用",
        "name":"中文為主，租金/水費/電費。後端對應費用key [item.name]",
        "add_by": "bills.edit=1手動新增,else=2來自合約 [detail.source]",
        "is_specified_amount": "true/false, 直接告訴前端總金額[detail.is_reading_total_price_directly]",
        "is_taxable": "0=不計稅,1=計稅, [detail.is_taxable]",
        "unit": "meter=度數,month=月費, [detail.unit_type]", // null時前端用不到
        "amount": {
            "base_number":"<int> 0, [detail.total_price]",
            "base_currency": "<string> TWD,[detail.currency]"
        },
        "amount_per_unit": { 
            "base_number":"<int> 0, [detail.unit_price]", // null時前端用不到
            "base_currency": "<string> TWD,"
        }
        "electricity_unit_options":{"陣列":"電費差異處理"}
}
//////////
"custom_fees":{
    "0":{
        "item_id": 0,
        "type": "income=0收入/expense=1支出  [item.fee_type]", // 要先用buildCustomFeesData轉換成'fee_type'
        "label": "前端顯示費用",
        "name":"使用者命名為主，跟label一樣。後端對應費用key [item.name]",
        "add_by": "bills.edit=1手動新增,else=2來自合約 [detail.source]",
        "is_specified_amount": "true/false, 直接告訴前端總金額[detail.is_reading_total_price_directly]",
        "is_taxable": "0=不計稅,1=計稅, [detail.is_taxable]",
        "unit": "meter=度數,month=月費, [detail.unit_type]", // 可null
        "amount": {
            "base_number":"<int> 0, [detail.total_price]",
            "base_currency": "<string> TWD,[detail.currency]"
        },
        "amount_per_unit": { 
            "base_number":"<int> 0, [detail.unit_price]",// 可null
            "base_currency": "<string> TWD,"
        }
    }
}
//////////
"electricity_unit_options":{
    {
        "label": '一般',
        "base_currency": 'TWD',
        "base_number": 12
    },
    {
        "label": '夏季',
        "base_currency": 'TWD',
        "base_number": 123
    }
}


    {
        'data':{
            'list':[
                {
                    'note' : "固定第一期",//帳單標題
                    "expire_date":"2024/12/2", //繳費期限
                    "cycle_start_date":"2024/1/1",//帳單週期初始日
                    "cycle_end_date":"2024/2/12", //帳單週期結束日
                    "fees":[
                        //租金 
                        {
                            "id": "123",
                            "label": "租金",
                            "type": "income",
                            "is_specified_amount": false, //是否自訂金額
                            "unit": "month", // month 月 or meter 度數
                            
                            //自訂或是依照月份計算的總數
                             "amount": {
                              "base_currency": "TWD",
                              "base_number": 12800
                            },
                            //月份或是度數的基本值
                            "amount_per_unit": {
                              "base_currency": "TWD",
                              "base_number": 12800
                            },
                            "amount_of_used":1 //x月份基數
                         },
                        //電費
                         {
                            "id": "222",
                            "label": "電費",
                            "type": "income",
                            "is_specified_amount": false, //是否自訂金額
                            "unit": "meter", // month 月 or meter 度數
                            
                            //自訂或是依照月份計算的總數
                             "amount": {
                              "base_currency": "TWD",
                              "base_number": 12800
                            },
                            //月份或是度數的基本值 
                            "amount_per_unit": {
                              "base_currency": "TWD",
                              "base_number": 12800
                            },
                            "amount_of_used":1 //x月份基數
                             
                             //***電費會需要額外電費費用資訊
                            "electricity_unit_options": [
                                {
                                    "label": '一般',
                                    "base_currency": 'TWD',
                                    "base_number": 12
                                },
                                {
                                    "label": '夏季',
                                    "base_currency": 'TWD',
                                    "base_number": 123
                                }
                            ],},
                    ],
                    'custom_fees':[
                        {
                            "type": "income",
                            "label": "第四臺",
                            "add_by": "bills.edit",
                            "is_specified_amount": true,
                            "amount": {
                                "base_number":0,
                                "base_currency": "TWD"
                            },
                    "item_id": "WhWeQxcuGu=UGsr8"
                    }
                    ]
                    "remark":"", //帳單備註
                    "attachment":[  //圖片上傳
                        {
                        "type": "img",
                        "url": "https://d1h2hzes3rmzug.cloudfront.net/12/c0/12c03d77ea5094c6b37602c748635ec0.jpeg"
                        }
                    ],
                    "status": "darft" // darft草稿，unreceived應到帳，received已到帳，archived封存

                }
                        
            ]

        }
        
        
        
        
        
        
    }
```

送出form格式



