Reklame.php 2.03 KB
<?php

/**
 * @Author: irul
 * @Date:   2019-09-23 15:20:24
 * @Last Modified by:   irul
 * @Last Modified time: 2019-10-01 23:43:20
 */

namespace Integrasi\Reklame\Base;

use \Illuminate\Database\Eloquent\ModelNotFoundException;
use \JsonRPC\Exception\ServerErrorException;

/**
 * Class utama yang digunakan untuk integrasi reklame.
 */
class Reklame extends AbstractClass
{
	/**
	 * Fungsi untuk menyimpan data IPR yang dikirim dari Perizinan
	 * ke dalam tbl pad_sptpd.
	 *
	 * Algoritma secara umum:
	 * 1. Cek Pajak join PajakTarif
	 * 2. Get WP
	 * 3. Get OP (create/update)
	 * 4. Create SPT/SPTPD
	 * 5. Create Rincian (depend on)
	 */
	public static function setIpr($payload)
	{
		throw new ServerErrorException(
			"Silahkan dibuat dan disesuaikan dengan kondisi yang ada disuatu wilayah");
	}

	// ===================================================================== //

	/**
	 * Mendapatkan informasi reklame menggunakan key ID.
	 *
	 * ID di sini merupakan:
	 * - ID pada tabel pad_spt jika tidak ada table pad_sptpd.
	 * - ID pada tabel pad_sptpd jika ada table pad_sptpd.
	 */
	public static function getById($id)
	{
		$data = Helper::getPendataanById($id);
		if (!$data) {
			throw new ModelNotFoundException(MSG_NOT_FOUND);
		}
		return Helper::pajakInfo($data);
	}

	/**
	 * Mendapatkan informasi reklame menggunakan key IPR ID.
	 *
	 * IPR ID merupkan ID unik milik perizinan yang digunakan
	 * sebagai key antara perizinan dengan pajak.
	 */
	public static function getByIprId($iprId)
	{
		$data = Helper::getPendataanByIprId($iprId);
		if (!$data) {
			throw new ModelNotFoundException(MSG_NOT_FOUND);
		}
		return Helper::pajakInfo($data);
	}

	/**
	 * Mendapatkan informasi reklame menggunakan
	 * key Invoice Number (Nomor Bayar/sptno).

	 * Invoice Number atau biasa dikenal dengan Nomor Bayar atau Nomor SPT.
	 */
	public static function getByInvoiceNumber($invoiceNumber)
	{
		$data = Helper::getPendataanByInvoiceNumber($invoiceNumber);
		if (!$data) {
			throw new ModelNotFoundException(MSG_NOT_FOUND);
		}
		return Helper::pajakInfo($data);
	}
}