hr dan payroll
This commit is contained in:
@@ -29,8 +29,17 @@ class PurchaseService
|
||||
return array($amount,$accountId);
|
||||
}
|
||||
|
||||
private function assertPurchasePaymentSchema()
|
||||
{
|
||||
$missing=array();
|
||||
foreach(array('bank_charge_amount','bank_charge_account_id','total_cash_out')as$column)if(!$this->CI->db->field_exists($column,'supplier_payments'))$missing[]=$column;
|
||||
if(!$this->CI->db->table_exists('purchase_payment_sources'))$missing[]='purchase_payment_sources';
|
||||
if($missing)throw new BusinessException('Struktur database pembayaran pembelian belum diperbarui ('.implode(', ',$missing).'). Jalankan: php index.php migrate latest');
|
||||
}
|
||||
|
||||
public function prepayOrderWithBankCharge($poId,$date,array$sources,$reference,$notes,$user,$bankCharge=0,$bankChargeAccount=0)
|
||||
{
|
||||
$this->assertPurchasePaymentSchema();
|
||||
return$this->CI->transactionservice->run(function()use($poId,$date,$sources,$reference,$notes,$user,$bankCharge,$bankChargeAccount){
|
||||
$po=$this->CI->db->query('SELECT * FROM purchase_orders WHERE id=? FOR UPDATE',array((int)$poId))->row();
|
||||
if(!$po||!in_array($po->status,array('approved','partially_received'),true))throw new BusinessException('PO belum disetujui atau sudah selesai.');
|
||||
@@ -57,6 +66,7 @@ class PurchaseService
|
||||
|
||||
public function settleSupplierInvoiceMultiWithBankCharge($id,array$sources,$paymentDate,$reference,$user,$bankCharge=0,$bankChargeAccount=0)
|
||||
{
|
||||
$this->assertPurchasePaymentSchema();
|
||||
$bill=$this->CI->db->get_where('supplier_invoices',array('id'=>(int)$id))->row();if(!$bill)throw new BusinessException('Invoice supplier tidak ditemukan.');
|
||||
$po=$this->CI->db->select('po.*')->from('supplier_invoice_lines sil')->join('purchase_order_lines pol','pol.id=sil.po_line_id')->join('purchase_orders po','po.id=pol.purchase_order_id')->where('sil.supplier_invoice_id',$id)->limit(1)->get()->row();
|
||||
$alreadyPaid=$po&&in_array($po->payment_timing,array('prepaid','on_receipt'),true)&&$po->paid_amount>=$bill->total-.001;
|
||||
@@ -88,6 +98,7 @@ class PurchaseService
|
||||
|
||||
public function paymentMultiWithBankCharge($supplierId,$date,array$sources,array$allocations,$allowAdvance,$user,$reference,$bankCharge=0,$bankChargeAccount=0)
|
||||
{
|
||||
$this->assertPurchasePaymentSchema();
|
||||
return$this->CI->transactionservice->run(function()use($supplierId,$date,$sources,$allocations,$allowAdvance,$user,$reference,$bankCharge,$bankChargeAccount){
|
||||
$supplier=$this->CI->db->get_where('suppliers',array('id'=>(int)$supplierId))->row();if(!$supplier)throw new BusinessException('Supplier tidak ditemukan.');
|
||||
list($valid,$gross)=$this->purchasePaymentSources($sources);list($charge,$chargeAccount)=$this->purchaseBankCharge($bankCharge,$bankChargeAccount);
|
||||
|
||||
Reference in New Issue
Block a user