hokky 3 tháng trước cách đây
mục cha
commit
edbcf8eea1

+ 46 - 180
resources/views/front/dabory/erp/revenue/sales.blade.php

@@ -89,6 +89,21 @@
                                             </button>
                                         </div>
                                     </div>
+                                    <div class="form-group d-flex flex-column mb-2">
+                                        <label class="m-0">{{ $formB['FormVars']['Title']['SorderNo'] }}</label>
+                                        <div class="d-flex">
+                                            <input type="text" class="rounded w-100 radius-r0" id="sorder-no-txt"
+                                                maxlength="{{ $formB['FormVars']['MaxLength']['SorderNo'] }}"
+                                                {{ $formB['FormVars']['Required']['SorderNo'] }}>
+                                                <button type="button"
+                                                    class="btn-dark rounded btn-open-modal border-0 radius-l0 col-3 window company-modal-btn"
+                                                    data-target="sorder"
+                                                    data-clicked="get_override_supplier_id"
+                                                    data-variable="companyModal">
+                                                    <i class="icon-folder-open"></i>
+                                                </button>
+                                            </div>
+                                    </div>
                                 </div>
                             </div>
                         </div>
@@ -256,7 +271,7 @@
                             @endif
                         </div>
 
-                        <div class="table-responsive mt-2" style="height:400px;" id="scroll-area">
+                        <div class="table-responsive mt-2" style="height:200px;" id="scroll-area">
                             <table class="table-row sales-table">
                                 <thead id="sales-table-head">
                                     @include('front.dabory.erp.partial.make-thead', [
@@ -361,9 +376,10 @@
         window.onload = async function () {
             ThumbArr = [];
             make_dynamic_table_css('.sales-table', make_dynamic_table_px(formB['ListVars']['Size']))
+
             $('#sales-date').val(date_to_sting(new Date()))
             $('#stock-date').val(date_to_sting(new Date()))
-            Btype.get_storage_name_and_branch_name()
+            var test = Btype.get_storage_name_and_branch_name()
             let sgroup_pick = await get_api_data('sgroup-pick', { Page: [ { Id:  parseInt(window.User['SgroupId']) } ] });
             window.User['SgroupName'] = sgroup_pick['data']['Page'][0]['SgroupName'];
 
@@ -475,24 +491,6 @@
             $('#up-btn').prop('disabled', false);
         }
 
-<<<<<<< HEAD
-=======
-
-        function save_data_when_entering_text() {
-            let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
-            let index = $(tr).prevAll().length
-
-            bd_page[index].ConfirmDate = $(tr).children('td:eq(12)').find('input').val()
-            bd_page[index].DeliDate = $(tr).children('td:eq(13)').find('input').val()
-            bd_page[index].Ref1 = $(tr).children('td:eq(14)').find('input').val()
-            bd_page[index].Ref2 = $(tr).children('td:eq(15)').find('input').val()
-        }
-
-        // start body act btn
-        function override_btn_bd_act_multi_update() {
-            Btype.btn_bd_act_multi_update('.sales-table')
-        }
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
 
         function save_data_when_entering_text() {
             let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
@@ -504,17 +502,18 @@
         }
 
         async function btn_bd_act_add() {
-            console.log('btn_bd_act_add');
-            if (parseInt($(`#frm`).find(`input[name="Id"]`).val()) == 0) {
-                iziToast.error({
-                    title: 'Error',
-                    message: @json(_e('Action failed')),
-                });
-                return;
-            }
-            if (! Btype.last_item_added_check('#sales-table-body')) {
-                add_tr();
-            }
+            Btype.btn_act_save('#sales-form #frm', async function () {
+                if (parseInt($(`#frm`).find(`input[name="Id"]`).val()) == 0) {
+                    iziToast.error({
+                        title: 'Error',
+                        message: @json(_e('Action failed')),
+                    });
+                    return;
+                }
+                if (! Btype.last_item_added_check('#sales-table-body')) {
+                    add_tr();
+                }
+            });
         }
 
         function btn_bd_act_body_copy(parameter_name) {
@@ -538,19 +537,10 @@
         }
 
         function btn_act_new() {
-<<<<<<< HEAD
             data_init()
             if (formB['SlipCommonSetup']['IsNewRecAutoSlipNo']) {
                 get_last_slip_no()
             }
-=======
-            console.log('btn_act_new');
-            data_init()
-
-            // if (formB['SlipCommonSetup']['IsNewRecAutoSlipNo']) {
-                get_last_slip_no()
-            // }
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
         }
 
         function btn_act_copy_to_another(parameter_name) {
@@ -609,7 +599,6 @@
                     first_thumb = first_sales['TurboThumb']
                 }
             }
-<<<<<<< HEAD
             const itmtot_amt = bd_page.reduce((accumulator, bd) => {
                 return accumulator + parseFloat(bd.SalesSupply) + parseFloat(bd.SalesVat) // 합계금액 (공급가액 + 세액)
             }, 0)
@@ -617,17 +606,6 @@
             const total_qty = bd_page.reduce((accumulator, bd) => {
                 return accumulator + parseFloat(bd.SalesQty)
             }, 0)
-=======
-            // console.log('first_sales : ', bd_page[0]);
-            const itmtot_amt = bd_page.reduce((accumulator, bd) => {
-                // return accumulator + parseFloat(bd.SalesSupply) + parseFloat(bd.SalesVat) // 합계금액 (공급가액 + 세액)
-                return accumulator + parseFloat(bd.SalesSupply)
-            }, 0)
-
-            // const total_qty = bd_page.reduce((accumulator, bd) => {
-            //     return accumulator + parseFloat(bd.PorderQty)
-            // }, 0)
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
             let id = parseInt($(`#frm`).find(`input[name="Id"]`).val());
             let parameter = {
                 Id: id,
@@ -661,17 +639,12 @@
                 VatRate: vat_rate,
                 VatName: vat_name,
                 SgroupName: window.User['SgroupName'],
-<<<<<<< HEAD
                 // FirstThumb : first_thumb,
                 TotalQty : String(Number(total_qty) - 0)
             }
 
             if (typeof first_thumb !== 'undefined') {
                 parameter.FirstThumb = first_thumb;
-=======
-                //TotalQty : String(Number(total_qty) - 0),
-                FirstThumb : first_thumb
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
             }
             if (id < 0) {
                 parameter = { Id: id }
@@ -680,12 +653,6 @@
             } else {
                 delete parameter.UpdatedOn;
             }
-<<<<<<< HEAD
-=======
-
-            console.log('save : ', parameter);
-
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
             return parameter;
         }
 
@@ -762,17 +729,6 @@
             $('#our-contact-select').html(our_contact);
         }
 
-<<<<<<< HEAD
-=======
-        // function set_vat_type_rate($this, msg = true) {
-        //     let vate_rate = $($this).find('option:selected').data('viewvatrate');
-        //     console.log('vate_rate : ', vate_rate);
-        //     $('#vat-type-rate-text').val(vate_rate + '%')
-
-        //     if (parseInt($(`#frm`).find(`input[name="Id"]`).val()) == 0 || ! msg) return;
-        // }
-
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
         function set_vat_type_rate($this, msg = true) {
             let vate_rate = $($this).find('option:selected').data('viewvatrate');
             $('#vat-type-rate-text').val(vate_rate + '%')
@@ -804,7 +760,6 @@
                 SalesSupply: String(bd.SalesSupply),
                 SalesVat: String(bd.SalesVat),
                 SalesSum: String(bd.SalesSum),
-<<<<<<< HEAD
                 // ConfirmDate: isEmpty(bd.ConfirmDate) ? '' : moment(bd.ConfirmDate).format('YYYYMMDD'),
                 // DeliDate: isEmpty(bd.DeliDate) ? '' : moment(bd.DeliDate).format('YYYYMMDD'),
                 // DiscountRate: String(discount_rate),
@@ -814,11 +769,6 @@
                 Ref2: bd.Ref2,
                 SorderMemo: bd.SorderMemo,
                 Ip: window.User['Ip']
-=======
-                CostPrc: String(bd.CostPrc),
-                Ip: window.User['Ip'],
-                FirstThumb: bd.TurboThumb
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
             }
 
             if (id < 0) {
@@ -851,7 +801,6 @@
             Btype.btn_act_save('#sales-form #frm', async function () {
                 let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
                 let index = $(tr).prevAll().length
-<<<<<<< HEAD
                 // if (bd_page[index].SorderBdId == 0) {
                 //     console.log('bd_page[index] : ', bd_page[index]);
                 //     iziToast.error({
@@ -870,26 +819,6 @@
                     Btype.call_bd_act_api([ get_bd_parameter(bd_page[index]) ], function (page) {
                         bd_page[index].Id = page[0].Id;
 
-=======
-
-                if (bd_page[index].SorderBdId == 0) {
-                    iziToast.error({
-                        title: 'Error',
-                        message: @json(_e('Action failed')),
-                    });
-                    return;
-                };
-
-                // 필수텍스트가 안비어있으고 fouces out == 다음 tr 추가
-                if (! dom_required_check($(tr).find(`input`))) {
-                    if ($($this).data('last')) {
-                        let seq_no = await Btype.get_last_seq_no('sales', $('#auto-slip-no-txt').val())
-                        bd_page[index].SeqNo = seq_no;
-                    }
-                    Btype.call_bd_act_api([ get_bd_parameter(bd_page[index]) ], function (page) {
-                        bd_page[index].Id = page[0].Id;
-
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
                         body_act_success_callback($this, tr);
                         Btype.check_the_checkbox_when_changing($this, false)
                     });
@@ -900,6 +829,7 @@
                     });
                 }
             });
+            scrollToTop();
         }
 
         function body_act_success_callback($this, tr) {
@@ -967,7 +897,6 @@
         }
 
         function create_bd_page() {
-            console.log('create_bd_page()');
             let html = []
             let qty_total = 0, supply_total = 0, vat_amt_vat_total = 0, sum_total = 0;
             bd_page.forEach(bd => {
@@ -1017,11 +946,7 @@
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                         class="text-${formB.ListVars['Align'].SorderPrc}" ${formB.ListVars['Hidden'].SorderPrc}
                         >
-<<<<<<< HEAD
                         <input type="text" class="text-${formB.ListVars['Align'].SorderPrc} border-0 bg-white" value="${format_conver_for(bd.CostPrc, formB.ListVars['Format'].SorderPrc)}" readonly
-=======
-                        <input type="text" class="text-${formB.ListVars['Align'].SorderPrc} border-0 bg-white" value="${format_conver_for(bd.SorderPrc, formB.ListVars['Format'].SorderPrc)}" readonly
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
                         onchange="Btype.check_the_checkbox_when_changing(this)"
                         onfocusout="override_amt_calc_txt_is_changed()"
                         require>
@@ -1045,11 +970,7 @@
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                         class="text-${formB.ListVars['Align'].SumAmt}" ${formB.ListVars['Hidden'].SumAmt}
                         >
-<<<<<<< HEAD
                         <input type="text" class="text-${formB.ListVars['Align'].SumAmt} border-0 bg-white" value="${format_conver_for(bd.SalesSum, formB.ListVars['Format'].SumAmt)}" readonly
-=======
-                        <input type="text" class="text-${formB.ListVars['Align'].SumAmt} border-0 bg-white" value="${format_conver_for(bd.SorderSum, formB.ListVars['Format'].SumAmt)}" readonly
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
                         onchange="Btype.check_the_checkbox_when_changing(this)"
                         onfocusout="override_custom_sum_amt()"
                         required>
@@ -1057,18 +978,6 @@
                     <td
                         class="text-${formB.ListVars['Align'].StdSalesPrc}" ${formB.ListVars['Hidden'].StdSalesPrc}>${format_conver_for(bd.StdSalesPrc, formB.ListVars['Format'].StdSalesPrc)}
                     </td>
-<<<<<<< HEAD
-=======
-
-                    <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
-                        class="text-${formB.ListVars['Align'].DeliDate}" ${formB.ListVars['Hidden'].DeliDate}
-                        >
-                        <input type="date" class="text-${formB.ListVars['Align'].DeliDate} border-0 bg-white" value="${isEmpty(bd.DeliDate) ? '' : moment(bd.DeliDate).format('YYYY-MM-DD')}" readonly
-                        onchange="Btype.check_the_checkbox_when_changing(this)"
-                        onfocusout="save_data_when_entering_text()"
-                        required>
-                    </td>
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
                     <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                         class="text-${formB.ListVars['Align'].Ref1}" ${formB.ListVars['Hidden'].Ref1}
                         >
@@ -1085,11 +994,7 @@
                         onfocusout="save_data_when_entering_text()">
                     </td>
                     <td
-<<<<<<< HEAD
-                        class="text-${formB.ListVars['Align'].SorderMemo}" ${formB.ListVars['Hidden'].SorderMemo}>
-=======
-                        class="text-${formB.ListVars['Align'].SorderMemo}" ${formB.ListVars['Hidden'].SordderMemo}>
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
+                        class="text-${formB.ListVars['Align'].SalesMemo}" ${formB.ListVars['Hidden'].SorderMemo}>
                         <textarea style="max-height: 30px;" class="rounded w-100 bg-white memo-textarea" id="memo-textarea-${bd.Id}"
                             ondblclick="Btype.dblclick_memo_textarea(this, ${bd.Id})" role="button" readonly>${bd.SorderMemo}</textarea>
                     </td>
@@ -1184,18 +1089,7 @@
                 <td
                     class="text-${formB.ListVars['Align'].StdSalesPrc}" ${formB.ListVars['Hidden'].StdSalesPrc}>
                 </td>
-<<<<<<< HEAD
-=======
-                <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
-                    class="text-${formB.ListVars['Align'].DeliDate}" ${formB.ListVars['Hidden'].DeliDate}
-                    >
-                    <input type="date" class="text-${formB.ListVars['Align'].DeliDate} border-0 bg-white" readonly
-                    value="${moment().format('YYYY-MM-DD')}"
-                    onchange="Btype.check_the_checkbox_when_changing(this)"
-                    onfocusout="save_data_when_entering_text()"
-                    required>
-                </td>
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
+
                 <td onkeydown="Btype.handleEnterPressedinTabCell(event)"
                     class="text-${formB.ListVars['Align'].Ref1}" ${formB.ListVars['Hidden'].Ref1}
                     >
@@ -1251,17 +1145,14 @@
         }
 
         function set_item_data_to_textbox(item) {
-<<<<<<< HEAD
             let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
             $(tr).children('td:eq(2)').find('input').val(item.ItemCode)
             $(tr).children('td:eq(3)').find('input').val(item.ItemName)
             $(tr).children('td:eq(4)').text(item.SubName)
             $(tr).children('td:eq(5)').text(item.CountUnit)
             $(tr).children('td:eq(6)').find('input').val()
-            // $(tr).children('td:eq(7)').find('input').val(parseFloat(item.PurchPrc).toFixed(window.User['PurchPrcPoint']))
-            // $(tr).children('td:eq(11)').text(parseFloat(item.SalesPrc).toFixed(window.User['PurchPrcPoint']))
-            $(tr).children('td:eq(7)').find('input').val(parseFloat(item.PurchPrc).toFixed(window.User['SalesPrcPoint'])) //표준매출가
-            $(tr).children('td:eq(10)').text(parseFloat(item.SalesPrc).toFixed(window.User['SalesPrcPoint']))
+            $(tr).children('td:eq(7)').find('input').val(parseFloat(item.PurchPrc).toFixed(window.User['PurchPrcPoint']))
+            $(tr).children('td:eq(11)').text(parseFloat(item.SalesPrc).toFixed(window.User['PurchPrcPoint']))
             let index = $(tr).prevAll().length;
             bd_page[index].ItemId = item.Id
             bd_page[index].ItemCode = item.ItemCode
@@ -1269,8 +1160,8 @@
             bd_page[index].SubName = item.SubName
             bd_page[index].CountUnit = item.CountUnit
             bd_page[index].SorderPrc = item.SalesPrc
-            bd_page[index].CurrPurchPrc = item.PurchPrc
-            bd_page[index].CurrSalesPrc = item.SalesPrc // override_amt_calc_txt_is_changed();
+            bd_page[index].CurrPurchPrc = item.SalesPrc
+            bd_page[index].CurrSalesPrc = item.PurchPrc// override_amt_calc_txt_is_changed();
 
             if (!ThumbArr) { // item 받아왔을 때만 bd_page에 TurboThumb 저장
                 bd_page[index].TurboThumb = item.TurboThumb
@@ -1281,42 +1172,16 @@
                 bd_page[index].SorderMemo = item.ItemMemo
             }
 
-            // if (bd_page[index].Id === 0) {
-            //     $(tr).children('td:eq(16)').find('textarea').val(item.ItemMemo)
-            //     bd_page[index].SalesMemo = item.ItemMemo
-=======
-            console.log('item : ', item);
-            let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
-            // $(tr).children('td:eq(2)').find('input').val(item.ItemCode)
-            // $(tr).children('td:eq(3)').find('input').val(item.ItemName)
-            // $(tr).children('td:eq(4)').text(item.SubName)
-            // $(tr).children('td:eq(5)').text(item.CountUnit)
-            // $(tr).children('td:eq(6)').find('input').val()
-            // $(tr).children('td:eq(7)').find('input').val(parseFloat(item.PurchPrc).toFixed(window.User['PurchPrcPoint']))
-            // $(tr).children('td:eq(11)').text(parseFloat(item.PurchPrc).toFixed(window.User['PurchPrcPoint']))
-            // let index = $(tr).prevAll().length;
-            // bd_page[index].ItemId = item.Id
-            // bd_page[index].ItemCode = item.ItemCode
-            // bd_page[index].ItemName = item.ItemName
-            // bd_page[index].SubName = item.SubName
-            // bd_page[index].CountUnit = item.CountUnit
-            // bd_page[index].StdSalesPrc = item.PurchPrc
-            // bd_page[index].StdPurchPrc = item.PurchPrc// override_amt_calc_txt_is_changed();
-            // bd_page[index].TurboThumb = item.TurboThumb
-
-            // if (bd_page[index].Id === 0) {
-            //     $(tr).children('td:eq(16)').find('textarea').val(item.ItemMemo)
-            //     bd_page[index].PorderMemo = item.ItemMemo
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
-            // }
+            if (bd_page[index].Id === 0) {
+                $(tr).children('td:eq(16)').find('textarea').val(item.ItemMemo)
+                bd_page[index].SalesMemo = item.ItemMemo
+            }
 
             return $(tr).children('td:eq(6)').find('input')
         }
 
         function update_hd_ui(response) {
-            console.log('update_hd_ui');
             if (isEmpty(response.data) || response.data.apiStatus) {
-                console.log('isEmpty(response.data) || response.data.apiStatus');
                 $('#modal-slip').modal('hide');
                 return;
             }
@@ -1325,16 +1190,12 @@
 
             let hd_page = response.data.HdPage[0]
             bd_page = response.data.BdPage ?? []
-<<<<<<< HEAD
             let thumb = response.data.HdPage[0]['FirstThumb']
 
             if(!thumb){
                 ThumbArr = thumb;
             }
 
-=======
-            console.log('response : ', response);
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
             $('#Id').val(hd_page.Id)
             $('#auto-slip-no-txt').val(hd_page.SalesNo)
             $('#sales-date').val(moment(to_date(hd_page.SalesDate)).format('YYYY-MM-DD'))
@@ -1383,6 +1244,11 @@
             $('#modal-slip').modal('hide');
         }
 
+        function scrollToTop() {
+            var scrollArea = document.getElementById("scroll-area");
+            scrollArea.scrollTop = 0;
+        }
+
         const salesModal = {!! json_encode($salesModal) !!};
         const companyModal = {!! json_encode($companyModal) !!};
         const itemModal = {!! json_encode($itemModal) !!};

+ 32 - 23
resources/views/front/dabory/erp/revenue/sorder.blade.php

@@ -71,8 +71,9 @@
                                     <div class="form-group d-flex flex-column mb-2">
                                         <label class="m-0 ">{{ $formB['FormVars']['Title']['Buyer'] }}</label>
                                         <div class="d-flex">
+                                            <input type="hidden" id="seller-id-txt" value="1">
                                             <input type="text" id="buyer-txt" data-id="0" class="rounded w-100 radius-r0" autocomplete="off"
-                                            onkeydown="company_model_show_cell_enter_key(event, 'BB')"
+                                            onkeydown="company_model_show_cell_enter_key(event, '')"
                                                    maxlength="{{ $formB['FormVars']['MaxLength']['Buyer'] }}"
                                                 {{ $formB['FormVars']['Required']['Buyer'] }}>
                                             <button type="button"
@@ -327,10 +328,7 @@
 <script src="{{ csset('/js/modals-controller/b-type/common.js') }}"></script>
     <script>
         window.onload = async function () {
-<<<<<<< HEAD
             ThumbArr = [];
-=======
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
             //await Btype.fetch_slip_form_book(query['QueryVars']['FilterValue']);
             make_dynamic_table_css('.sorder-table', make_dynamic_table_px(formB['ListVars']['Size']))
 
@@ -339,7 +337,6 @@
             Btype.get_storage_name_and_branch_name()
             // let data = await Btype.get_slip_form_init()
             slipInit = @json($slipFormInitCacheData);
-            // console.log('slipInit : ', slipInit);
             formB['SlipCommonSetup'] = slipInit['SlipCommonSetup']
             await Btype.create_deal_type_select_box_options(slipInit.DealTypePage)
             await Btype.create_vat_type_select_box_options(slipInit.VatRatePage)
@@ -516,11 +513,7 @@
         }
 
         async function add_td_last_tap_out($this, id) {
-<<<<<<< HEAD
             Btype.btn_act_save('#sorder-form #frm', async function () {
-=======
-            Btype.btn_act_save('#squote-form #frm', async function () {
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
                 let tr = $(`input[name='bd-cursor-state']:checked`).closest('tr')
                 let index = $(tr).prevAll().length
 
@@ -528,10 +521,6 @@
                 if (bd_page[index].ItemId != 0 && ! dom_required_check($(tr).find(`input`))) {
                     if ($($this).data('last')) {
                         let seq_no = await Btype.get_last_seq_no('sorder', $('#auto-slip-no-txt').val())
-<<<<<<< HEAD
-=======
-                        console.log('seq_no : ', seq_no);
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
                         bd_page[index].SeqNo = seq_no;
                     }
 
@@ -539,10 +528,6 @@
                         bd_page[index].Id = page[0].Id;
                         body_act_success_callback($this, tr);
                         Btype.check_the_checkbox_when_changing($this, false)
-<<<<<<< HEAD
-=======
-                        // Btype.btn_act_save('#sorder-form #frm');
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
                     });
                 } else {
                     iziToast.error({
@@ -683,6 +668,7 @@
             const vat_rate = $('#vat-type-select').find('option:selected').data('vatrate')
             const vat_name = slipInit['VatRatePage'].filter(page => page['Id'] === Number($('#vat-type-select').val()))[0]['VatName']
             let first_item = ''
+            let first_thumb = ''
 
             if (bd_page.length > 0) {
                 const first_sorder = bd_page[0]
@@ -719,6 +705,7 @@
                 BranchId: window.User['BranchId'],
                 StorageId: window.User['StorageId'],
                 BuyerId: parseInt($('#buyer-txt').data('id')),
+                SellerId: parseInt($('#seller-id-txt').val()),
                 VatRateId: parseInt($('#vat-type-select').val()),
                 BuyerContact: $('#buyer-txt').data('contact'),
                 PayTerms: $('#payTerms-select').val(),
@@ -752,10 +739,6 @@
                 delete parameter.UpdatedOn;
             }
 
-<<<<<<< HEAD
-=======
-            console.log('save : ', parameter)
->>>>>>> 79e2e07b19fcabaccbe8bd7b4812a3a803613323
             return parameter;
         }
 
@@ -765,9 +748,34 @@
             $('#auto-slip-no-txt').val(moment(new Date()).format('YYMMDD') + '-' + response.data.LastSlipNo)
         }
 
+
         async function get_override_supplier_id(company_id) {
-            await get_supplier_id(company_id, '#buyer-txt');
-            $('#buyer-contact-txt').val($('#buyer-txt').data('contact'))
+            await get_local_supplier_id(company_id, '#buyer-txt');
+        }
+
+        async function get_local_supplier_id(supplier_id, dom_val = '#supplier-txt') {
+            let response = await get_api_data('company-pick', {
+                Page : [
+                    {Id: Number(supplier_id) }
+                ]
+            })
+
+            if (response.data.Page) {
+                const company = response.data.Page[0];
+                $(dom_val).data('id', company.Id);
+                $(dom_val).val(company.CompanyName);
+                $(dom_val).data('contact', company.MainContact);
+
+                $('#buyer-contact-txt').val($('#buyer-txt').data('contact'))
+                $('#seller-id-txt').val(company.SellerId)
+
+                $('#modal-company.show').modal('hide');
+
+                return company
+            }
+
+
+
         }
 
         async function create_etc_select_box_options(data) {
@@ -1197,6 +1205,7 @@
             $('#buyer-txt').data('id', hd_page.BuyerId)
             $('#buyer-txt').data('contact', hd_page.BuyerContact)
             $('#buyer-contact-txt').val(hd_page.BuyerContact)
+            $('#seller-id-txt').val(hd_page.SellerId)
 
             $('#deal-type-select').val(hd_page.DealTypeId)
             $('#vat-type-select').val(hd_page.VatRateId)