---
# System prepended metadata

title: Create Form4 Memo

---

# Create Form4 Memo

1. CREATE MEMO 🔗 **PATCH: api/memos-real/**
```
{
    "form": 3,
    "loa": "",  # input loa custom 
    "is_permission": false,
    "loa_group": null,   # input loa not custom 
    "from_profile": {profile_id},
    "cc_list": [{profile_id}, ..],
    "to": [{profile_id}, ..],
    "announce_location": [{location_id}, ..],
    "announce_division": [{division_id}, ..],
    "announce_department": [{department_id}, ..],
    "ready": True,
}
```


2. CREATE FORM4 🔗 **POST: api/memos-form4/**
```
    **CHOICES**
    
    NEW_CUSTOMER = 'New customer'  # ขอแต่งตั้งลุกค้าใหม่
    PERMANENT_INCREASE = 'Permanent increase'  # ขอเพิ่มวงเงินถาวร
    TEMPORARY_INCREASE = 'Temporary increase'  # ขอเพิ่มวงเงินชั่วคราว
    
    PURPOSE_CHOICES = (
        (NEW_CUSTOMER, 'New customer'),
        (PERMANENT_INCREASE, 'Permanent increase'),
        (TEMPORARY_INCREASE, 'Temporary increase'),
    )
    
    ___________________________________________________________
    
    COMPANY = 'Company'  # บริษัท
    PARTNERSHIP = 'Partnership'  # หจก
    SHOP = 'SHOP'  # ร้านค้า/บุคคลธรรมดา
    
    TYPE_BUSINESS_CHOICES = (
        (COMPANY, 'Company'),
        (PARTNERSHIP, 'Partnership'),
        (SHOP, 'SHOP'),
    )
    
    ___________________________________________________________
    
    CHECK = 'Check'  # เช็ค
    BANK_TRANSFER = 'Bank Transfer'  # โอนเงิน
    CASH = 'Cash'  # เงินสด
    
    PAYMENT_METHOD_CHOICES = (
        (CHECK, 'Check'),
        (BANK_TRANSFER, 'Bank Transfer'),
        (CASH, 'Cash'),
    )
```

```
    
{
    "memo": {memo_id},
    "purpose": null, # PURPOSE_CHOICES
    "company_name_th": "",
    "company_name_en": "",
    "company_address": "",
    "company_tel": "",
    "type_business": null,  # TYPE_BUSINESS_CHOICES
    "type_business_detail": "",
    "required_document": [],  # Input int 1-8
    "required_document_detail": "",
    "proposed_credit_limit": 0,
    "proposed_credit_term": 0,
    "billing_condition": "",
    "payment_method": null, # PAYMENT_METHOD_CHOICES
    "outstanding": 0,
    "overdue": 0,
    "purchase_amount": 0,
    "total_amount": 0,
    "exceeded_amount": 0,
    "add_credit_limit": 0,
    "from_credit_limit": 0,
    "new_credit_limit": 0,
}
```

3. UPDATE 🔗 **PATCH: api/memos-form4/{id}/**

4. APPROVE MEMO 

🔗 **POST: api/approval-memo/** 
🔗 **POST: api/guest-approval-memo/**

วิธีการ approve ของคนสุดท้ายจะต่างจากเพื่อนคือ ถ้า approve ต้องเลือก 3 เงื่อนไข
ดูจากตัวแปร is_last_loa = True ซึ่ง data ที่ต้องส่งไปจะต้องเป็นแบบนี้
ส่วนถ้า is_last_loa = False ให้ส่งโดยวิธีปกติ

```
    # อนุมัติวงเงิน
{
    'memo_id': {memo_id},
    'approve_status': True,
    'reason': None,
    'is_approve': True,
    'is_reject': False,
    'is_sell_for_cash': False,
    'approve_amount': 0,
    'credit_day': 0
}

    # ไม่อนุมัติ
{
    'memo_id': {memo_id},
    'approve_status': True,
    'reason': "ไปทำมาใหม่",
    'is_approve': False,
    'is_reject': True,
    'is_sell_for_cash': False,
    'approve_amount': 0,
    'credit_day': 0
}    

    # ขายเป็นเงินสดเท่านั้น
{
    'memo_id': {memo_id},
    'approve_status': True,
    'reason': null,
    'is_approve': False,
    'is_reject': False,
    'is_sell_for_cash': True,
    'approve_amount': 0,
    'credit_day': 0
}  

```

<hr>

5. Example Context PDF Form 4 📝
For use variable in PDF

```
{
    "memo_number":"1234",
    "created_at":"09-Sep-2020",
    "prepare_by_name":"Ratthanan Paethanomnit",
    "prepare_by_position":"หัวหน้าแผนก",
    "arrival_date":"09-Sep-2020",
    "purpose":"New customer",
    "company_name_th":"โคเดียม",
    "company_name_en":"CODIUM",
    "company_address":"865 Rama I Rd, Wang Mai, Pathum Wan District, Bangkok 10330",
    "company_tel":"0-2612-3838",
    "type_business":"Company",
    "type_business_detail":"Software as a Service",
    "required_document":[
        1,
        4
    ],
    "required_document_detail":"ต้องการทำเรื่องมาก",
    "proposed_credit_limit":Decimal("100.00"),
    "proposed_credit_term":Decimal("100.00"),
    "billing_condition":"กรอกเยอะมาก",
    "payment_method":"Check",
    "reason_item":"อยากสมัครมากๆ",
    "outstanding":Decimal("100.00"),
    "overdue":Decimal("100.00"),
    "purchase_amount":Decimal("100.00"),
    "total_amount":Decimal("100.00"),
    "exceeded_amount":Decimal("100.00"),
    "approve_amount":Decimal("0.00"),
    "credit_day":"None",
    "is_approve":False,
    "is_reject":False,
    "is_sell_for_cash":False,
    
    "company":{
        "id":1,
        "sequence":0,
        "name":"บริษัท บางกอกโคมัตสุ เซลล์ จำกัด",
        "name_en":"Bankgkok Komatsu Sales",
        "address":"28/9 หมู่ 3 ถนนบางนา-ตราด กม.23 ต.บางเสาธง อ.บางเสาธง จ.สมุทรปราการ 10570",
        "address_en":"28/9 Moo 3 Bangna-Trad Road Km.23, Bangsaothong, Bangsaothong, Samutprakarn 10570",
        "tel":"0-2-663-2666",
        "fax":"0-2663-2566",
        "website":"www.bangkokkomatsusales.com"
    },
    
    "signatures_data":[
        {
            "full_name":"Ratthanan Paethanomnit",
            "position":"หัวหน้าแผนก",
            "profile":1,
            "padding":0,
            "contact_name":"None",
            "level_id":1,
            "level":1,
            "comment":"",
            "text":"Prepared by"
        }
    ],
    "signature_odd":1
}
```