hokky 1 місяць тому
батько
коміт
7cb1c554c5

+ 36 - 0
app/Http/Controllers/Front/Dabory/Erp/BasicSettings/MonthlySettleController.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace App\Http\Controllers\Front\Dabory\Erp\BasicSettings;
+
+use App\Helpers\Utils;
+use App\Models\Parameter\FormA;
+use App\Models\Parameter\Modal;
+use App\Http\Controllers\Controller;
+use App\Exceptions\ParameterException;
+
+class MonthlySettleController extends Controller
+{
+    public function index()
+    {
+        try {
+            $monthArr = [
+                "1월", "2월", "3월", "4월", "5월", "6월",
+                "7월", "8월", "9월", "10월", "11월", "12월"
+            ];
+            $formA = new FormA(request('bpa'));
+        } catch (ParameterException $e) {
+            return redirect()->route('dashboard')->with('error', $e->getMessage());
+        }
+
+//         dump($formA->getData());
+
+        $menuCode = Utils::bpaDecoding(request('bpa'))['menu_code'];
+
+        return view('front.dabory.erp.basic-settings.monthly-settle',
+            array_merge(
+                compact('menuCode'),
+                $formA->getData(),
+                compact('monthArr'))
+            );
+    }
+}

+ 61 - 0
dabory/para/erp/ko_KR/form/form-a/monthly-settle.json

@@ -0,0 +1,61 @@
+{
+    "General": {
+        "Title": "월별 재정산(마감)",
+        "ActApi": "monthly-settle"
+    },
+
+    "SelectButtonOptions": [
+        {
+            "Value": "new",
+            "Caption": "추가"
+        },
+        {
+            "Value": "del",
+            "Caption": "삭제"
+        },
+        {
+            "Value": "copy",
+            "Caption": "복사"
+        }
+    ],
+
+    "//FormVars": "ListVars[0]-Title, ListVars[1]-Format, ListVars[2]-MaxLength, ListVars[3]-Required",
+    "FormVars": [
+        {
+            "ReCalulationButton": "재정산 실행",
+            "IsBalBuyer": "매출 원장 재정산",
+            "IsBalSupplier": "매입 원장 재정산",
+            "IsBalItem": "수불 원장 재정산",
+            "IsBalReward": "적립금 원장 재정산",
+            "IsBalCredit": "충전금 원장 재정산",
+            "YyyyMm": "정산년월"
+        },
+        {
+            "ReCalulationButton": "",
+            "IsBalBuyer": "",
+            "IsBalSupplier": "",
+            "IsBalItem": "",
+            "IsBalReward": "",
+            "IsBalCredit": "",
+            "YyyyMm": ""
+        },
+        {
+            "ReCalulationButton": "0",
+            "IsBalBuyer": "0",
+            "IsBalSupplier": "0",
+            "IsBalItem": "0",
+            "IsBalReward": "0",
+            "IsBalCredit": "0",
+            "YyyyMm": ""
+        },
+        {
+            "ReCalulationButton": "",
+            "IsBalBuyer": "",
+            "IsBalSupplier": "",
+            "IsBalItem": "",
+            "IsBalReward": "",
+            "IsBalCredit": "",
+            "YyyyMm": "required"
+        }
+    ]
+}

+ 137 - 0
resources/views/front/dabory/erp/basic-settings/monthly-settle.blade.php

@@ -0,0 +1,137 @@
+@extends('layouts.master')
+@section('title', $formA['General']['Title'])
+@section('content')
+    <div class="content">
+        <div class="row">
+            <div class="col-xl-12">
+                <h2>{{ $formA['General']['Title'] }}</h2>
+                <div class="card" id="monthly-settle-form">
+                    <div class="card-body mt-2" id="frm">
+                        <input type="hidden" id="Id" name="Id" value="0">
+                        <div class="d-flex align-items-center mb-2">
+                            <input type="checkbox" value="bal_buyer" class="text-center mr-1" id="is-bal-buyer-check" checked>
+                            <label class="mb-0" for="is-bal-buyer-check">{{ $formA['FormVars']['Title']['IsBalBuyer'] }}</label>
+                        </div>
+                        <div class="d-flex align-items-center mb-2">
+                            <input type="checkbox" value="bal_supplier" class="text-center mr-1" id="is-bal-supplier-check" checked>
+                            <label class="mb-0" for="is-bal-supplier-check">{{ $formA['FormVars']['Title']['IsBalSupplier'] }}</label>
+                        </div>
+                        <div class="d-flex align-items-center mb-2">
+                            <input type="checkbox" value="bal_item" class="text-center mr-1" id="is-bal-item-check" checked>
+                            <label class="mb-0" for="is-bal-item-check">{{ $formA['FormVars']['Title']['IsBalItem'] }}</label>
+                        </div>
+                        <div class="d-flex align-items-center mb-2">
+                            <input type="checkbox" value="bal_reward" class="text-center mr-1" id="is-bal-reward-check" checked>
+                            <label class="mb-0" for="is-bal-reward-check">{{ $formA['FormVars']['Title']['IsBalReward'] }}</label>
+                        </div>
+                        <div class="d-flex align-items-center mb-2">
+                            <input type="checkbox" value="bal_credit" class="text-center mr-1" id="is-bal-credit-check" checked>
+                            <label class="mb-0"
+                            for="is-bal-credit-check">{{ $formA['FormVars']['Title']['IsBalCredit'] }}</label>
+                        </div>
+
+                        <div class="form-group mb-3" {{ $formA['FormVars']['Hidden']['YyyyMm'] }}>
+                            <label>{{ $formA['FormVars']['Title']['YyyyMm'] }}</label>
+                            <br>
+                            <input type="text" id="yyyy-txt" data-copy="true"
+                                maxlength="{{ $formA['FormVars']['MaxLength']['YyyyMm'] }}"
+                                {{ $formA['FormVars']['Required']['YyyyMm'] }}>
+                            @php $todayMonth = date('n');@endphp
+                            <select id = "mm-select">
+                                @foreach($monthArr as $index => $month)
+                                    <option value="{{ $index + 1 }}" @if($todayMonth == $index + 1) selected @endif>
+                                        {{ $month }}
+                                    </option>
+                                @endforeach
+                            </select>
+                        </div>
+
+                        <div class="btn-group">
+                            <button type="button" class="btn btn-sm btn-primary monthly-settle"
+                                    data-value="re_calculation"
+                                    {{ $formA['FormVars']['Hidden']['ReCalulationButton'] }}>
+                                    {{ $formA['FormVars']['Title']['ReCalulationButton'] }}
+                            </button>
+                        </div>
+
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+@endsection
+
+
+@section('js')
+<script src="{{ csset('/js/modals-controller/a-type/common.js') }}"></script>
+<script>
+    $(document).ready(async function() {
+        $('.monthly-settle').on('click', function () {
+            switch( $(this).data('value') ) {
+                case 're_calculation': MonthlySettleForm.btn_re_cal('#monthly-settle-form #frm', undefined, 'MonthlySettleForm'); break;
+            }
+        });
+
+    });
+
+    (function( MonthlySettleForm, $, undefined ) {
+        MonthlySettleForm.formA = {!! json_encode($formA) !!};
+
+        MonthlySettleForm.parameter = function () {
+            let id = Number($('#monthly-settle-form').find('#Id').val());
+            const yyyy = $('#monthly-settle-form').find('#yyyy-txt').val();
+            const mm = $('#monthly-settle-form').find('#mm-select').val();
+            const parameters = [];
+
+            $('#monthly-settle-form').find('input[type="checkbox"]:checked').each(function() {
+                parameters.push({
+                    TableName: $(this).val(),
+                    BalYyyyMm: yyyy+mm
+                });
+            });
+
+            console.log('parameters : ', parameters);
+            return parameters;
+        }
+
+        MonthlySettleForm.fetch_monthly_settle = async function (id) {
+            let response = await get_api_data(MonthlySettleForm.formA['General']['PickApi'], {
+                Page: [ { Id: id } ]
+            })
+
+            MonthlySettleForm.set_monthly_settle_ui(response)
+        }
+
+        MonthlySettleForm.set_monthly_settle_ui = function (response) {
+            if (isEmpty(response.data) || response.data.apiStatus) {
+                $('#modal-setting_monthly_settle').modal('hide');
+                return;
+            }
+
+            let monthly_settle = response.data.Page[0];
+
+            $('#monthly-settle-form').find('#Id').val(monthly_settle.Id)
+            $('#monthly-settle-form').find('#monthly_settle-name-txt').val(monthly_settle.IgroupName)
+            $('#monthly-settle-form').find('#monthly_settle-code-txt').val(monthly_settle.IgroupCode)
+            $('#monthly-settle-form').find('#monthly_settle-slug-txt').val(monthly_settle.IgroupSlug)
+            $(`input:radio[name=is-end-level]:input[value=${monthly_settle.IsEndLevel}]`).prop('checked', true);
+
+            $('#modal-setting_monthly_settle').modal('hide');
+        }
+
+        MonthlySettleForm.btn_re_cal = async function () {
+            // console.log('api_url', MonthlySettleForm.formA['General']['ActApi']);
+            const parameters = MonthlySettleForm.parameter();
+            let data;
+            let response;
+            for (const parameter of parameters) {
+                data = parameter;
+                response = await get_api_data('monthly-settle', data);
+                console.log('response : ', response);
+            }
+        }
+
+    }( window.MonthlySettleForm = window.MonthlySettleForm || {}, jQuery ));
+
+</script>
+@endsection

+ 0 - 1
resources/views/front/dabory/erp/coupon-credit/credit.blade.php

@@ -530,7 +530,6 @@
             bd_page.forEach(bd => {
                 if (hd_page.FromBuyerId === bd.BuyerId) {
                     bd.RewardAmt = -Math.abs(bd.RewardAmt);
-                    console.log('받는 사람', bd);
                 }
             });
 

+ 15 - 10
resources/views/front/dabory/erp/coupon-credit/reward.blade.php

@@ -307,7 +307,7 @@
             }))
             .done(function(response) {
                 let d = response.data
-                console.log('response : ', response);
+                console.log(response);
                 if (d.Page) {
                     set_as_response_id(d.Page[0].Id)
                     callback();
@@ -476,9 +476,10 @@
         function create_bd_page() {
             let html = []
             let sum_total = 0;
-            const reward_amt =
-            bd_page.forEach(bd => {
-                sum_total += parseFloat(bd.CreditAmt);
+
+            bd_page.forEach((bd, index) => {
+                console.log('bd.CreditAmt('+index+') : ', bd.RewardAmt);
+                sum_total += parseFloat(bd.RewardAmt);
 
                 // 품목코드, 수량, 단가, 공급가액, 세액, 합계금액
                 html.push (
@@ -532,12 +533,6 @@
             // console.log('bd_page : ', bd_page);
             // console.log('hd_page.id : ', hd_page.Id);
 
-            bd_page.forEach(bd => {
-                if (hd_page.FromBuyerId === bd.BuyerId) {
-                    bd.RewardAmt = -Math.abs(bd.RewardAmt);
-                    console.log('받는 사람', bd);
-                }
-            });
             $('.save-button').prop('disabled', true);
             $('#Id').val(hd_page.Id)
             $('#auto-slip-no-txt').val(hd_page.RewardNo)
@@ -563,6 +558,16 @@
 
             $('#sgroup-id-select').val(hd_page.SgroupId)
             $('#our-contact-select').val(hd_page.OurContact)
+
+            if($('#is-transfer-check').val() == 1){
+                bd_page.forEach(bd => {
+                    // 전송처리시 주는고객 적립금 - 처리
+                    if (hd_page.FromBuyerId === bd.BuyerId) {
+                        bd.RewardAmt = -Math.abs(bd.RewardAmt);
+                    }
+                });
+            }
+
             Btype.set_slip_no_btn_disabled()
             // table body에 데이터 추가
             create_bd_page();

+ 1 - 0
routes/dabory.php

@@ -51,6 +51,7 @@ Route::middleware(['check.gate.token', 'app.token.manager'])->group(function ()
         Route::get('/dabory/erp/basic-settings/branch', Utils::makeFrontRoute('/dabory/erp/basic-settings/branch'));
         Route::get('/dabory/erp/basic-settings/my-users', Utils::makeFrontRoute('/dabory/erp/basic-settings/my-users'));
         Route::get('/dabory/erp/basic-settings/item-optpro', Utils::makeFrontRoute('/dabory/erp/basic-settings/item-optpro'));
+        Route::get('/dabory/erp/basic-settings/monthly-settle', Utils::makeFrontRoute('/dabory/erp/basic-settings/monthly-settle'));
 
         Route::get('/dabory/erp/list-type/list-media1', Utils::makeFrontRoute('/dabory/erp/list-type/list-media1'));
         Route::get('/dabory/erp/etc/media', Utils::makeFrontRoute('/dabory/erp/etc/media'));