Fixes for Zoho imports

This commit is contained in:
David Bomba 2021-09-06 15:08:41 +10:00
parent 79ef62fefb
commit e719c659ea
4 changed files with 6 additions and 5 deletions

View File

@ -62,7 +62,7 @@ class BaseTransformer
public function getClient($client_name, $client_email) {
$clients = $this->maps['company']->clients;
$clients = $clients->where( 'name', $client_name );
$clients = $clients->where( 'id_number', $client_name );
if ( $clients->count() >= 1 ) {
return $clients->first()->id;

View File

@ -42,7 +42,7 @@ class ClientTransformer extends BaseTransformer {
'work_phone' => $this->getString( $data, 'Phone' ),
'private_notes' => $this->getString( $data, 'Notes' ),
'website' => $this->getString( $data, 'Website' ),
'id_number' => $this->getString( $data, 'Customer ID'),
'address1' => $this->getString( $data, 'Billing Address' ),
'address2' => $this->getString( $data, 'Billing Street2' ),
'city' => $this->getString( $data, 'Billing City' ),

View File

@ -38,7 +38,7 @@ class InvoiceTransformer extends BaseTransformer {
$transformed = [
'company_id' => $this->maps['company']->id,
'client_id' => $this->getClient( $this->getString( $invoice_data, 'Company Name' ), null ),
'client_id' => $this->getClient( $this->getString( $invoice_data, 'Customer ID' ), null ),
'number' => $this->getString( $invoice_data, 'Invoice Number' ),
'date' => isset( $invoice_data['Invoice Date'] ) ? date( 'Y-m-d', strtotime( $invoice_data['Invoice Date'] ) ) : null,
'due_date' => isset( $invoice_data['Due Date'] ) ? date( 'Y-m-d', strtotime( $invoice_data['Due Date'] ) ) : null,
@ -59,7 +59,7 @@ class InvoiceTransformer extends BaseTransformer {
'notes' => $this->getString( $record, 'Item Description' ),
'cost' => $this->getFloat( $record, 'Item Price' ),
'quantity' => $this->getFloat( $record, 'Quantity' ),
'discount' => $this->getFloat( $record, 'Discount Amount' ),
'discount' => $this->getString( $record, 'Discount Amount' ),
'is_amount_discount' => true,
];
}

View File

@ -111,7 +111,8 @@ class DeletePayment
//If the invoice is deleted we only update the meta data on the invoice
//and reduce the clients paid to date
$paymentable_invoice->updatePaidToDate($net_deletable * -1)
$paymentable_invoice->service()
->updatePaidToDate($net_deletable * -1)
->save();
$paymentable_invoice->client