<?php

//region urusan tanggal-menanggal
date_default_timezone_set('asia/jakarta');
$date = new DateTime(date("Y-m-d")); // Y-m-d
$date->add(new DateInterval('P30D'));
//endregion

$config["coTransaksiValues"] = array(
    "582" => array(
        "counters" => array(
            "stepCode|tokoID",
            "stepCode|machineID",
            "stepCode|olehID",
            "stepCode|customerID",
            "stepCode|tokoID|placeID",
            "stepCode|tokoID|olehID",
            "stepCode|tokoID|placeID|olehID",
            "stepCode|tokoID|customerID",
            "stepCode|tokoID|placeID|customerID",
            "stepCode|olehID|tokoID",
            "stepCode|placeID",
            "stepCode|placeID|olehID",
        ),
        "formatNota" => "stepCode,placeID,machineID,stepCode|machineID,olehID,stepCode|tokoID|olehID",
        "valueGates" => array(//==sumber nilai yang dikirim kemana2
            "master" => array(//==sumber nilai utama
                "customerID" => "pihakID",
                "customerName" => "pihakName",
                //                "sellerID" => "olehID",
                //                "sellerName" => "olehName",
            ),
            "detail" => array(//===sumber nilai berupa rincian

                // "harga"=>"jual_nppn",
                "harga_nett1" => "harga",
                "harga_net" => "((harga_nett1*qty_unit)-disc)",
                "harga_disc" => "harga-disc",
                "ppn" => "(harga_disc*(ppnFactor/100))",
                "harga_nppn" => "harga_disc+ppn",
                "ppn_net" => "ppn*ppnFactor",
                "harga_nett2" => "(harga_nett1-disc)",

            ),
            "master_dependent" => array(
                "paymentMethod" => array(
                    "credit" => array(
                        "nilai_cash" => "0",
                        "nilai_credit" => "tagihan",
                    ),
                ),
            ),
        ),
        "valueBuilders" => array(
//            "harga_nett3" => "harga_nett2-diskon_tambahan_nilai-creditAmount",
            "grand_total" => "harga_nett2-diskon_tambahan_nilai-add_disc-creditAmount",
            "tagihan" => "harga_nett2-diskon_tambahan_nilai-add_disc-creditAmount",
            "grand_hutang" => "",
            "kembali" => "bayar-grand_total",
            "disc" => "diskon_tambahan_nilai",
        ),
        "additionalMainBuilders" => array(//==per-item
            "harga_nett3" => "harga_nett2-add_disc",
        ),
        "externalValues" => array(
            //            "ongkir" => array(
            //                "mdlName" => "MdlCourier",
            //                "label" => "freight cost",
            //                "startAt" => 1,
            //                "useAt" => 5,
            //                "taxFactor" => 10,
            //                "viewedAtReceipt" => true,
            //            ),
            //            "install" => array(
            //                "label" => "installation",
            //                "startAt" => 1,
            //                "useAt" => 5,
            //                "taxFactor" => 10,
            //                "viewedAtReceipt" => true,
            //            ),
        ),
        "preValidator" => array(
            //            1 => array(
            //                "LockerStock",
            //            ),
        ),
        "preProcessor" => array(

        ),
        "tableIn" => array(
            "master" => array(
                "jenis_master" => "jenisTrMaster",
                "jenis_top" => "jenisTrTop",
                "jenis" => "jenisTr",
                "jenis_label" => "jenisTrName",
                "dtime" => "dtime",
                "fulldate" => "fulldate",
                "oleh_id" => "olehID",
                "oleh_nama" => "olehName",
                "div_id" => "divID",
                "div_nama" => "divName",
                "customers_id" => "pihakID",
                "customers_nama" => "pihakName",

                "cabang_id" => "placeID",
                "cabang_nama" => "placeName",
                "toko_id" => "tokoID",
                "toko_nama" => "tokoName",
                "transaksi_nilai" => "harga_nett2",
                "transaksi_jenis" => "jenisTr",
                "keterangan" => "description",

                "gudang_id" => "gudangID",
                "gudang_nama" => "gudangName",

                "pembayaran_sys" => "paymentMethod",
                "bank_rekening_id" => "paymentMethod_debit_card_cash_account",
                "bank_rekening_nama" => "bank_rekening_nama",

                "seller_id" => "sellerID",
                "seller_nama" => "sellerName",
            ),
            "mainValues" => array(
                "harga" => "harga_jual",
                "jual_nppn" => "jual_nppn",
                "hpp" => "hpp",
                "disc" => "disc",
                "ppn" => "ppn",
                "harga" => "harga",
                "harga_nett" => "harga_nett",
                "diskon_tambahan_nilai" => "diskon_tambahan_nilai",
                "tagihan" => "tagihan",
                "bayar" => "bayar",
            ),
            "detail" => array(
                "dtime" => "dtime",
                "produk_id" => "id",
                "produk_kode" => "code",
                "produk_label" => "label",
                "produk_nama" => "name",
                "produk_ord_jml" => "jml",
                "produk_ord_hrg" => "harga_nett2",
                "satuan" => "satuan",
                "oleh_id" => "olehID",
                "oleh_nama" => "olehName",
                "produk_ord_hpp" => "hpp_produk",
                "produk_ord_laba" => "sub_laba_jual",
            ),
            "detailValues" => array(
                "harga" => "harga",
                "jual_nppn" => "jual_nppn",
                "hpp" => "hpp",
                "disc" => "disc",
                "ppn" => "ppn",
                "harga_nett" => "harga_nett",
            ),
        ),
        "tableIn_static" => array(
            "master" => array(
                "trash" => 0,
            ),
            "detail" => array(
                "trash" => 0,
                "produk_jenis" => "produk",
            ),
        ),
        "components" => array(),
        "postProcessor" => array(
            "582" => array(
                "master" => array(),
                "detail" => array(

                ),
            ),
        ),

        // jembatan/gerbang tambahan untuk dieksekusi oleh CORE
        "coreBuilder" => array(
            "582" => array(
                "main" => array(
                    // "kas" => "grand_total",
                    // "piutang_dagang" => "nilai_credit",
                    // "hutang_ke_konsumen" => "-creditAmount",
                    // "penjualan" => "grand_total",
                   //  "ppn_out" => ".0",
//                    "hpp" => "hpp",
//                     "persediaan_produk" => "-hpp",
//                     "diskon" => "add_disc",
                    //----------
                    // "paymentMethod_cash" => "cash_account",
                    // "paymentMethod_cash__label" => "cash_account__label",
                ),
                "items" => array(
                    // "persediaan_produk_item" => "-sub_hpp",
                    // "produk_qty" => "-qty",
                    // "produk_nilai" => "hpp",
                ),
            ),
        ),
    ),
    "982" => array(
        "counters"          => array(
            "stepCode|tokoID",
            "stepCode|olehID",
            "stepCode|machineID",
            "stepCode|customerID",
            "stepCode|tokoID|placeID",
            "stepCode|tokoID|olehID",
            "stepCode|tokoID|placeID|olehID",
            "stepCode|tokoID|customerID",
            "stepCode|tokoID|placeID|customerID",
            "stepCode|olehID|tokoID",
            "stepCode|placeID",
            "stepCode|placeID|olehID",
        ),
        "formatNota"        => "stepCode,machineID,stepCode|machineID,stepCode|tokoID|placeID,olehID,stepCode|tokoID|olehID",
        "valueGates"        => array(//==sumber nilai yang dikirim kemana2
            "master" => array(//==sumber nilai utama
                "customerID" => "pihakID",
                "customerName" => "pihakName",
            ),
            "detail" => array(//===sumber nilai berupa rincian
            ),
            "master_dependent" => array(
                "returnMethod" => array(
                    "voucher" => array(
                        "nilai_voucher" => "grand_total",
                    ),
                    "cash" => array(
                        "nilai_voucher" => "0",
                    ),
                ),
            ),
        ),
        "valueBuilders"     => array(
            "grand_total" => "harga_nett2-diskon_tambahan_nilai-add_disc-creditAmount",
            "tagihan" => "grand_total",
            "grand_hutang" => "",
            "kembali" => "bayar-grand_total",
            "disc" => "diskon_tambahan_nilai",
            "return_notes" => ".voucher hanya berlaku selama 24 jam sejak dilakukan return",
        ),
        "preProcessor"      => array(),
        "tableIn"           => array(
            "master"       => array(
                "jenis_master" => "jenisTrMaster",
                "jenis_top"    => "jenisTrTop",
                "jenis"        => "jenisTr",
                "jenis_label"  => "jenisTrName",
                "div_id"       => "divID",
                "div_nama"     => "divName",
                "dtime"        => "dtime",
                "fulldate"     => "fulldate",
                "oleh_id"      => "olehID",
                "oleh_nama"      => "olehName",
                "customers_id"   => "pihakID",
                "customers_nama" => "pihakName",

                "cabang_id"       => "placeID",
                "cabang_nama"     => "placeName",
                "toko_id"         => "tokoID",
                "toko_nama"       => "tokoName",
                "transaksi_nilai" => "nilai_cancel",
                "transaksi_jenis" => "jenisTr",
                "keterangan"      => "description",

                "gudang_id"         => "gudangID",
                "gudang_nama"       => "gudangName",

                "pembayaran_sys"        => "paymentMethod",
                "bank_rekening_id"      => "paymentMethod_debit_card_cash_account",
                "bank_rekening_nama"    => "bank_rekening_nama",

                "seller_id"         => "sellerID",
                "seller_nama"       => "sellerName",

                "reference_jenis"       => "referenceJenis",
                "reference_id"          => "referenceID",
                "reference_nomer"       => "referenceNomer",

            ),
            "mainValues"   => array(
                "debet"  => "debet",
                "kredit" => "kredit",

                "harga" => "harga_jual",
                "jual_nppn" => "jual_nppn",
                "hpp" => "hpp",
                "disc" => "disc",
                "ppn" => "ppn",
                "harga" => "harga",
                "harga_nett" => "harga_nett",
                "diskon_tambahan_nilai" => "diskon_tambahan_nilai",
                "tagihan" => "tagihan",
                "bayar" => "bayar",

            ),
            "detail"       => array(
                "dtime"          => "dtime",
                "produk_id"      => "id",
                "produk_kode"    => "code",
                "produk_label"   => "label",
                "produk_nama"    => "name",
                "produk_ord_jml" => "jml",
                "produk_ord_hrg" => "harga",
                "hpp"            => "harga",
                "satuan"         => "satuan",
            ),
            "detailValues" => array(
                "debet"  => "debet",
                "kredit" => "kredit",

                "harga" => "harga",
                "jual_nppn" => "jual_nppn",
                "hpp" => "hpp",
                "disc" => "disc",
                "ppn" => "ppn",
                "harga_nett" => "harga_nett",

            ),
        ),
        "tableIn_static"    => array(
            "master" => array(
                "trash" => 0,
            ),
            "detail" => array(
                "trash"        => 0,
                "produk_jenis" => "account",
            ),
        ),
        "components"        => array(//kosong baca dari builder helper lihat he_accounting
        ),
        "relativeComponets" => true,//untuk baca dari session builder helper relative jurnal
        "postProcessor"     => array(//kosong baca dari builder helper lihat he_accounting
        ),
        // jembatan/gerbang tambahan untuk dieksekusi oleh CORE
        "coreBuilder" => array(
            "982" => array(
                "main" => array(
                    "return_penjualan" => "-harga_nett2",
                    // "piutang_dagang" => "nilai_credit",
                    // "hutang_ke_konsumen" => "-creditAmount",
                    // "penjualan" => "grand_total",
                    //  "ppn_out" => ".0",
                    // "hpp" => "hpp",
                    //                     "persediaan_produk" => "-hpp",
                    //                     "diskon" => "add_disc",
                    //----------
                    // "paymentMethod_cash" => "cash_account",
                    // "paymentMethod_cash__label" => "cash_account__label",
                ),
                "items" => array(
                    // "persediaan_produk_item" => "-sub_hpp",
                    // "produk_qty" => "-qty",
                    // "produk_nilai" => "hpp",
                ),
            ),
        ),
    ),
);