Skip to content

Commit

Permalink
Merge pull request #2441 from CAFECA-IO/feature/default_invoice_type
Browse files Browse the repository at this point in the history
Feature/default invoice type
  • Loading branch information
Luphia authored Sep 16, 2024
2 parents e78b26d + 0247aab commit c994adc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iSunFA",
"version": "0.8.1+12",
"version": "0.8.1+13",
"private": false,
"scripts": {
"dev": "next dev",
Expand Down
2 changes: 1 addition & 1 deletion src/constants/invoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export enum InvoiceType {
// Info: (20240718 - Jacky) 進項三聯式、電子計算機統一發票
PURCHASE_TRIPLICATE_AND_ELECTRONIC = 'PurchaseTriplicateAndElectronic',

// Info: (20240718 - Jacky) 銷項二聯式、二聯式收銀機統一發票
// Info: (20240718 - Jacky) 進項二聯式、二聯式收銀機統一發票
PURCHASE_DUPLICATE_CASH_REGISTER_AND_OTHER = 'PurchaseDuplicateCashRegisterAndOther',

// Info: (20240718 - Jacky) 三聯式、電子計算機及三聯式收銀機統一發票及一般稅額計算之電子發票之銷貨退回或折讓證明單
Expand Down
13 changes: 9 additions & 4 deletions src/pages/api/v1/company/[companyId]/invoice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,22 @@ import { InvoiceType } from '@/constants/invoice';
import { loggerError, loggerRequest } from '@/lib/utils/logger_back';
import { APIName, APIPath } from '@/constants/api_connection';
import { validateRequest } from '@/lib/utils/request_validator';
import { EventType } from '@/constants/account';

// Info: (20240416 - Murky) Body傳進來會是any
function formatInvoice(invoice: IInvoice) {
// Deprecate ( 20240522 - Murky ) For demo purpose, AICH need to remove projectId and contractId
const now = Date.now(); // Info: (20240807 - Jacky) for fake unique invoice number
const invoiceTypeValues = Object.values(InvoiceType); // Info: (20240807 - Jacky) for fake invoice type
const randomIndex = Math.floor(Math.random() * invoiceTypeValues.length);
// Info: (20240916 - Jacky) default invoice type is PURCHASE_TRIPLICATE_AND_ELECTRONIC
let invoiceType = InvoiceType.PURCHASE_TRIPLICATE_AND_ELECTRONIC;
// Info: (20240916 - Jacky) if eventType is INCOME, then invoice type is SALES_TRIPLICATE_INVOICE
if (invoice.eventType === EventType.INCOME) {
invoiceType = InvoiceType.SALES_TRIPLICATE_INVOICE;
}
const formattedInvoice = {
...invoice,
number: now.toString(),
type: invoiceTypeValues[randomIndex],
number: now.toString() + invoice.journalId,
type: invoiceType,
vendorTaxId: 'temp fake id',
deductible: true,
projectId: invoice.projectId ? invoice.projectId : null,
Expand Down

0 comments on commit c994adc

Please sign in to comment.