📄 sale2.c
字号:
/* The sale mode tax shift key function */
void Do_STAXSFT(word KeyCode)
{
if((CurrMode != REGISTER) && (CurrMode != TRAINING))
{errorType(ERR_KEY_ILLEGAL);numcnt=0;return;}
if(sysflag->Tax_System == 0) /* The VAT mode, error */
{errorType(ERR_KEY_ILLEGAL);numcnt=0;return;}
if((!NewTrans) && (numcnt == 0)) /* When the Trans is not start and input no digit, clear the display */
{
Clr_Dsp_Data();
RightDisp(0,sysflag->sysdots);
}
if(Tax_Emp_Flag) /* Clear the tax exempt flag */
{
Tax_Emp_Flag = 0;
Do_TaxEmp();
}
if(KeyCode == KD_TAXSFT1)
{
shift_flag[0] = !shift_flag[0];
Do_Shift(0);
// shift1_flag = !shift1_flag;
// Do_Shift1();
}
else if(KeyCode == KD_TAXSFT2)
{
shift_flag[1] = !shift_flag[1];
Do_Shift(1);
// shift2_flag = !shift2_flag;
// Do_Shift2();
}
else if(KeyCode == KD_TAXSFT3)
{
shift_flag[2] = !shift_flag[2];
Do_Shift(2);
}
else // KeyCode == KD_TAXSFT4
{
shift_flag[3] = !shift_flag[3];
Do_Shift(3);
// shift3_flag = !shift3_flag;
// Do_Shift3();
}
}
/* When the GrandTotal is overflow, deal with it */
void GndTtl_OvrFlw_Deal(void)
{
/* Remain */
}
#ifdef RCPT_REPRN /* Support the receipt reprint function */
/* Reprint the receipt */
void RePrn_Rcpt(byte new_disp_flag)
{
byte i;
byte tax_round;
byte tax_mode;
byte mode = 0; /* In the Retail mode or in the Restaurant mode */
TVATDEF tax_rate[MAX_VAT_NUM];
#if SW_VER == SW_NE2
return; /* No need the reprint function */
#endif
Rcpt_Reprn_Flag = 1;
/*****************************************************/
/* Save the data */
memset((void*)&tmpvars,0,sizeof(Inter_Var));
tax_round = sysflag->tax_round;
sysflag->tax_round = transtvat.round;
tax_mode = sysflag->Tax_System;
sysflag->Tax_System = transtvat.flag;
if(sysflag->Tax_System == 1) /* Tax mode */
{
memcpy(tax_rate, Tax, MAX_TAX_NUM*sizeof(TVATDEF));
for(i = 0; i < MAX_TAX_NUM; i ++)
Tax[i].rate = transtvat.rate[i];
}
else /* VAT mode */
{
memcpy(tax_rate, VAT, MAX_VAT_NUM*sizeof(TVATDEF));
for(i = 0; i < MAX_VAT_NUM; i ++)
VAT[i].rate = transtvat.rate[i];
}
#ifdef VER_RSNT /* Support the Restaurant function */
currtable = transtvat.table_no;
if(currtable != NUL_VLU)
{
mode = work_mode;
work_mode = RSNT;
prn_LstSpndAmt_flag = 0;
}
#endif /* End VER_RSNT */
memcpy(transbuff, BakTnsBf, MAX_TNSBF_LEN*sizeof(TRANSBUFFDEF));
/*****************************************************/
for(i = 0; i < BakTnsBf_Len; i ++)
{
if((transbuff[i].ID&0x1F) == TS_EC) /* Error correct operation, not to print it */
continue;
Sale_Prn(transbuff[i]);
Update_Tmpvars(transbuff[i], POSITIVE); /* Update the structure variable tmpvars */
}
xtr_strcpy(prn_Buf+1,Str_Minus_Line); /* Modified on 2004-04-07 17:30 */
print();
Get_TVAT(); /* Calculate the VAT or tax value */
prn_REG_TVAT(); /* Print the VAT or tax vaule */
// prn_Line('-');
// memcpy(prn_Buf+1,Str_Minus_Line,MAX_PRN_LEN); /* Print one line */
xtr_strcpy(prn_Buf+1,Str_Minus_Line); /* Modified on 2004-04-07 17:30 */
print();
// prn_Adj(Var_Str_Subttl,tmpvars.netamt,sysflag->sysdots,RPOSI);
prn_Tot_Info_Ex(Var_Str_Subttl, tmpvars.netamt, 0);
prn_Tot_Qty(transbuff, BakTnsBf_Len); /* Print the total quantity */
prn_Stamp(); /* Print the sale stamp */
if(Rcpt_RePrn_Cnt != 0)
Rcpt_RePrn_Cnt --;
/*****************************************************/
/* Revert the data */
#ifdef VER_RSNT /* Support the Restaurant function */
if(currtable != NUL_VLU)
{
work_mode = mode;
prn_LstSpndAmt_flag = 1;
}
currtable = NUL_VLU;
#endif /* End VER_RSNT */
if(sysflag->Tax_System == 1) /* Tax mode */
memcpy(Tax, tax_rate, MAX_TAX_NUM*sizeof(TVATDEF));
else
memcpy(VAT, tax_rate, MAX_VAT_NUM*sizeof(TVATDEF));
sysflag->Tax_System = tax_mode;
sysflag->tax_round = tax_round;
memset((void*)&tmpvars,0,sizeof(Inter_Var));
SndTnsBf_Len = 0; /* Clear the second transaction buffer */
memcpy(BakTnsBf, transbuff, MAX_TNSBF_LEN*sizeof(TRANSBUFFDEF));
/*****************************************************/
Rcpt_Reprn_Flag = 0;
if(new_disp_flag)
{
Clr_Dsp_Data();
RightDisp(0, sysflag->sysdots);
}
}
#endif /* End RCPT_REPRN */
#ifdef ELEC_JRNL /* Support the electronic journal function */
/* Store the sale journal item */
void store_sale_item(TRANSBUFFDEF *tsbf, byte new_len)
{
byte tmp;
word posi;
ELECJRNLHEADDEF *elec_jrnl;
if(TnsBf_Len == 0) /* This is for the end a empty tables transaction */
return;
if(new_len > Max_Sale_Jrnl_No) /* FULL */
return;
// posi = (sale_jrnl_last + new_len - 1) % Max_Sale_Jrnl_No;
// if((posi == sale_jrnl_first) && (sale_jrnl_len != 0))
// {
// elec_jrnl = (ELECJRNLHEADDEF *)(&sale_jrnl[sale_jrnl_first]);
// tmp = elec_jrnl->length;
// sale_jrnl_first = (sale_jrnl_first+tmp) % Max_Sale_Jrnl_No;
// sale_jrnl_len -= tmp;
// }
// memcpy(&(sale_jrnl[posi]), tsbf, sizeof(TRANSBUFFDEF));
fls_store_sale_item((byte *)tsbf, new_len);
// sale_jrnl_len ++;
}
/* Store the discount journal item */
void store_dc_item(TRANSBUFFDEF *tsbf, byte new_len)
{
byte tmp;
word posi;
ELECJRNLHEADDEF *elec_jrnl;
if(new_len > Max_Dc_Jrnl_No) /* FULL */
return;
// posi = (dc_jrnl_last + new_len - 1) % Max_Dc_Jrnl_No;
// if((posi == dc_jrnl_first) && (dc_jrnl_len != 0))
// {
// elec_jrnl = (ELECJRNLHEADDEF *)(&dc_jrnl[dc_jrnl_first]);
// tmp = elec_jrnl->length;
// dc_jrnl_first = (dc_jrnl_first+tmp) % Max_Dc_Jrnl_No;
// dc_jrnl_len -= tmp;
// }
// memcpy(&(dc_jrnl[posi]), tsbf, sizeof(TRANSBUFFDEF));
fls_store_dc_item((byte *)tsbf, new_len);
// dc_jrnl_len ++;
}
/* Store the R.M. journal item */
void store_rm_item(TRANSBUFFDEF *tsbf, byte new_len)
{
byte tmp;
word posi;
ELECJRNLHEADDEF *elec_jrnl;
if(new_len > Max_Rm_Jrnl_No) /* FULL */
return;
// posi = (rm_jrnl_last + new_len - 1) % Max_Rm_Jrnl_No;
// if((posi == rm_jrnl_first) && (rm_jrnl_len != 0))
// {
// elec_jrnl = (ELECJRNLHEADDEF *)(&rm_jrnl[rm_jrnl_first]);
// tmp = elec_jrnl->length;
// rm_jrnl_first = (rm_jrnl_first+tmp) % Max_Rm_Jrnl_No;
// rm_jrnl_len -= tmp;
// }
// memcpy(&(rm_jrnl[posi]), tsbf, sizeof(TRANSBUFFDEF));
fls_store_rm_item((byte *)tsbf, new_len);
// rm_jrnl_len ++;
}
/*----------------------------------------------------------------------*
Update the electronic jornal.
*----------------------------------------------------------------------*/
void Update_Elec_Jrnl(void)
{
byte i;
byte ID;
byte cnt;
byte tmp;
word j;
ELECJRNLHEADDEF elec_jrnl_head, *elec_jrnl;
ELECJRNLTVATDEF elec_jrnl_tvat_head;
ELECJRNLTVATDEF2 elec_jrnl_tvat2_head;
#ifdef DEBUG_TEST
// word kkk;
#endif
/* Electronic journals head */
elec_jrnl_head.receipt_no = sysflag->RcptNum;
if(sysflag->clerk_mode)
elec_jrnl_head.clerk_no = currclerk;
else
elec_jrnl_head.clerk_no = NUL_VLU;
#ifdef VER_RSNT /* Support the restaurant function */
if(transtvat.table_no)
elec_jrnl_head.table_no = transtvat.table_no;
else
elec_jrnl_head.table_no = NUL_VLU;
#else /* Else VER_RSNT */
elec_jrnl_head.table_no = NUL_VLU;
#endif /* End VER_RSNT */
disint();
elec_jrnl_head.year = GetYear();
elec_jrnl_head.month = GetMonth();
elec_jrnl_head.day = GetDay();
elec_jrnl_head.hour = GetHour();
elec_jrnl_head.minute = GetMinute();
enint();
/* Update the sale journal */
elec_jrnl_head.ID = TS_SALE_JRNL;
#ifdef DEBUG_TEST
// Clr_Dsp_Data();
// for(kkk = 0; kkk < 700; kkk ++)
// {
// if(kkk)
// {
// elec_jrnl_head.receipt_no ++;
// if(elec_jrnl_head.receipt_no == 10000)
// elec_jrnl_head.receipt_no = 1;
// }
// RightDisp(kkk+1, 0);
#endif
if((Max_Sale_Jrnl_No >= 2) && (TnsBf_Len)) /* If the length smaller than 2, not to store the sale journal */
{
elec_jrnl_head.length = TnsBf_Len + 1; /* The electronic journal head */
// if(sysflag->Tax_System) /* Tax mode */
if(transtvat.flag) /* Tax mode */
{
for(i = 0; i < MAX_TAX_NUM; i ++)
{
if(tmpvars.TVATAmt[i] != 0)
break;
}
if(i < MAX_TAX_NUM) /* The tax amount not zero */
{
elec_jrnl_head.ID |= (0x20); /* 0010 0000B, the tax flag */
elec_jrnl_head.length ++;
elec_jrnl_tvat_head.ID = TS_ELEC_JRNL_TVAT;
elec_jrnl_tvat_head.round = transtvat.round;
for(i = 0; i < MAX_TAX_NUM; i ++)
// elec_jrnl_tvat_head.rate[i] = (transtvat.rate)[i];
Long2Bcd(elec_jrnl_tvat_head.rate[i], (transtvat.rate)[i], 3);
}
else
elec_jrnl_head.ID |= 0x00; /* 0000 0000B, not include the tax */
}
else /* VAT mode */
{
if(sysflag->Elec_Jrnl_VAT_Flag == 0) /* Can not to must store the VAT information */
elec_jrnl_head.ID |= 0x00; /* 0000 0000B, not include the VAT */
else
{
for(i = 0; i < MAX_VAT_NUM; i ++)
{
if(tmpvars.TVATAmt[i] != 0)
break;
}
if(i < MAX_VAT_NUM)
{
elec_jrnl_head.ID |= (0x40); /* 0100 0000B, the VAT flag */
elec_jrnl_head.length += 2;
elec_jrnl_tvat_head.ID = TS_ELEC_JRNL_TVAT;
elec_jrnl_tvat_head.round = sysflag->tax_round;
for(i = 0; i < MAX_TAX_NUM; i ++)
// elec_jrnl_tvat_head.rate[i] = (transtvat.rate)[i];
Long2Bcd(elec_jrnl_tvat_head.rate[i], (transtvat.rate)[i], 3);
elec_jrnl_tvat2_head.ID = TS_ELEC_JRNL_TVAT2;
for(i = MAX_TAX_NUM; i < MAX_VAT_NUM; i ++) /* For the tax number is smaller than VAT number */
// elec_jrnl_tvat2_head.rate[i-MAX_TAX_NUM] = (transtvat.rate)[i];
Long2Bcd(elec_jrnl_tvat2_head.rate[i-MAX_TAX_NUM], (transtvat.rate)[i], 3);
}
else
elec_jrnl_head.ID |= 0x00; /* 0000 0000B, not include the tax */
}
}
/*---------------------------------------------------------*/
cnt = 0;
for(i = 0; i < TnsBf_Len; i ++)
{
if(cnt == 0) /* Store the sale journal head */
{
// if(sale_jrnl_len != 0)
// {
//// elec_jrnl = (ELECJRNLHEADDEF *)(&(sale_jrnl[sale_jrnl_first]));
// elec_jrnl = get_jrnl_head(sale_jrnl_first_ptr);
// if(elec_jrnl->length == Max_Sale_Jrnl_No) /* Only store one transaction buffer */
// {
// sale_jrnl_first = sale_jrnl_last = 0;
// sale_jrnl_len = 0;
// }
// else
// {
//// elec_jrnl = (ELECJRNLHEADDEF *)(&(sale_jrnl[sale_jrnl_last]));
// elec_jrnl = get_jrnl_head(sale_jrnl_last_ptr);
// tmp = elec_jrnl->length;
// sale_jrnl_last = (sale_jrnl_last +tmp) % Max_Sale_Jrnl_No;
// }
// }
cnt ++;
store_head_step = 1;
store_sale_item((TRANSBUFFDEF *)(&elec_jrnl_head), cnt);
store_head_step = 0;
if((elec_jrnl_head.ID & 0x60) != 0) /* 0110 0000B, Test the VAT or the tax */
{
cnt ++;
store_sale_item((TRANSBUFFDEF *)(&elec_jrnl_tvat_head), cnt);
}
if((elec_jrnl_head.ID & 0x40) != 0) /* 0100 0000B, Test the VAT */
{
cnt ++;
store_sale_item((TRANSBUFFDEF *)(&elec_jrnl_tvat2_head), cnt);
}
}
cnt ++;
store_sale_item(&transbuff[i], cnt);
}
if(cnt > Max_Sale_Jrnl_No) /* This case will not occur in the flash journal version */
{
sale_jrnl_first = sale_jrnl_last = 0;
sale_jrnl_len = 0;
}
else
{
sale_jrnl_last -= sale_jrnl_first; /* Equal to sale_jrnl_last = sale_jrnl_len */
sale_jrnl_first = 0;
}
}
#ifdef DEBUG_TEST
// if((kkk > 600) && (kkk < 610))
// {
// Uart_WriteByte(PORT0, 0x55);
// Uart_WriteByte(PORT0, (dword)sale_jrnl_last_ptr);
// Uart_WriteByte(PORT0, (dword)sale_jrnl_last_ptr>>8);
// Uart_WriteByte(PORT0, (dword)sale_jrnl_last_ptr>>16);
// Uart_WriteByte(PORT0, (dword)sale_jrnl_last_ptr>>24);
// Uart_WriteByte(PORT0, 0xAA);
// }
// }
#endif
/* Update the discount journal */
elec_jrnl_head.ID = TS_DC_JRNL;
if(Max_Dc_Jrnl_No >= 2) /* If the length smaller than 2, not to store the discount journal */
{
cnt = 0;
// cnt ++;
// store_dc_item((TRANSBUFFDEF *)(&elec_jrnl_head), cnt);
for(i = 0; i < TnsBf_Len; i ++)
{
ID = transbuff[i].ID & 0x1F;
switch(ID)
{
case TS_PER_ITEM_DEPT:
case TS_PER_ITEM_PLU:
if(cnt == 0)
{
// if(dc_jrnl_len != 0)
// {
//// tmp = dc_jrnl[dc_jrnl_last].length;
//// elec_jrnl = (ELECJRNLHEADDEF *)(&(dc_jrnl[dc_jrnl_first]));
// elec_jrnl = get_jrnl_head(dc_jrnl_first_ptr);
// if(elec_jrnl->length == Max_Dc_Jrnl_No) /* Only store one transaction buffer */
// {
// dc_jrnl_first = dc_jrnl_last = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -