@@ -4,6 +4,7 @@ import { parse } from "csv-parse/sync";
44import fs from "fs" ;
55import { DateTime } from "luxon" ;
66import { execSync } from 'child_process' ;
7+ import { isEmpty } from 'lodash'
78
89import { createInvoice } from "./createInvoice" ;
910import { createPayment } from "./createPayment" ;
@@ -46,10 +47,10 @@ const processedData: ProcessedData[] = (orders as Order[])
4647 return {
4748 eventpopId : item [ 'Order #' ] ,
4849 customer : {
49- name : item [ "Buyer Name" ] ,
50+ name : taxInfo ?. [ "Billing Name" ] ?? item [ "Buyer Name" ] ,
5051 taxId : taxInfo ?. [ "Billing Tax ID" ] ?? null ,
5152 address : taxInfo ?. [ "Billing Address" ] ?? null ,
52- branch : 'สำนักงานใหญ่' ,
53+ branch : taxInfo ?. [ "Billing Branch" ] ?? 'สำนักงานใหญ่' ,
5354 email : orderWithEmail [ item [ 'Order #' ] ]
5455 } ,
5556 ticket : {
@@ -66,9 +67,9 @@ const processedData: ProcessedData[] = (orders as Order[])
6667 zone : 'Asia/Bangkok' ,
6768 setZone : true ,
6869 }
69- ) . toISO ( ) ! ) . toISOString ( )
70+ ) . toISO ( ) ! ) . toISOString ( ) ,
71+ witholdingTax : Number ( item [ "Withholding Tax" ] ) > 0 ? Number ( item [ "Withholding Tax" ] ) : null
7072 } ,
71- isWitholdingTax : Number ( item [ "Withholding Tax" ] ) > 0
7273 } satisfies ProcessedData
7374 } )
7475
@@ -85,13 +86,13 @@ const pickedData = processedData
8586 "#38704-3267295" , // bank, tax
8687 "#38704-3225968" , // credit
8788 "#38704-3215101" , // bank,
88- "#38704-3288940" , // out of scope
89+ "#38704-3288940" , // out of scope,
90+ "#38704-3251019" , // company
91+ "#38704-3215560" // company
8992
9093 ] . includes ( o . eventpopId )
9194)
9295
93- console . log ( pickedData )
94-
9596; ( async ( ) => {
9697 let index = 1
9798 for await ( const item of pickedData ) {
0 commit comments