📄 print.c
字号:
#include "ecrsys.h"
#include "ftype.h"
#include "data.h"
#include "sysdata.h"
#include <stdlib.h>
#include <string.h>
#include "lcd_rpt.h"
void Lcd_Init_Sale(void);
//byte flag_prn,Cal_Len(long num);
/************************************************************************
The receipt print format:
************************************************************************
--------------------------------
12345678901234567890123456789012
--------------------------------
Item Name Price Qty Total
================================
Department01 xxx.xx xx.x xxxx.xx
// First case
PLU0001 xxxxx.xx xx xxxxxx.xx
// Second case
PLU0001 x.xx xx.xx xxx.xx
PLU0001 x.xx xxx.xx xx.xx
// Not support this case
Department01 xxxx.xx
x xxxx.xx
Department01 xxxxx.xx
xxx.xx xxxxxx.xx
// Third case
// Department and PLU print format
Department01 * VOID * -xxxxxx.xx
// VOID operation print format
Department01 xxxxx.xx
* R.M. * xxx.xx -xxxxxx.xx
// Return Merchandise print format
REFUND xxxxx.xx
* Item * xx.x -xxxxxx.xx
// Refund operation print format
1% -xx.xxx%
* Item * -xxxxxx.xx
// Percent operation print format
Auto Per xx.xxx% xxxxxx.xx
Auto Per -xx.xxx% -xxxxxx.xx
// First case
Auto Percent xx.xxx% xxxxxx.xx
Auto Percent -xx.xxx% xxxxxx.xx
// Second case
// Auto Percent print format
* E.C. * -xxxxxx.xx
// Error Correct print format
--------------------------------
When support the ketchen printer, the print format:
12345678901234567890123456789012
Table001____ Clerk01_____ 23:59 // case 2
Department01 xxxx.xxx // Department operation, xxxx.xxx is quantity
Department01 * R.M. * -xxxx.xxx // Return merchandise operation xxxx.xxx is quantity
^^^^^^^^ E.C. ^^^^^^^^ // Error Correct operation
*************************************************************************/
/*------------------------------------------------------------------------------------------*
Print the sale information from the transacton buffer.
*------------------------------------------------------------------------------------------*/
#ifdef OLD
void Sale_Prn(TRANSBUFFDEF tsbf)
{
byte ID;
byte plink;
byte round;
byte peridxtmp;
byte len1, len2, len3, len4;
word Idx;
long price;
long quantity;
long amount;
char *desc_tmp;
ID = (tsbf.ID)&0x1F;
Idx = tsbf.nth;
price = tsbf.price;
quantity = tsbf.quantity;
#ifdef VER_RSNT /* Support the restaurant function */
// Sending the data to the kitchen printer.
Send_KP_Prn(tsbf, POSITIVE); /* Print to the kitchen printer */
#endif /* End VER_RSNT */
if(ID == TS_EC) /* Error Correct operation */
{
amount = price; /* In EC operation, the amount equal to the price */
// prn_Adj(Var_Str_EC, amount, sysflag->sysdots, RPOSI);
Prn_Adj_Ex(Var_Str_EC, amount, sysflag->sysdots, RPOSI, DESC_NEW);
}
else if((ID == TS_PER_ITEM_DEPT) || (ID == TS_PER_ITEM_PLU)) /* Percent after item operation */
{
peridxtmp = (tsbf.ID)>>5;
amount = price; /* In Percent operation, the amount equal to the price */
// memcpy(prn_Buf+1, percent[peridxtmp].desc, MAX_DESC_LEN);
// LongPrnFmt(quantity, PER_DOTS, MAX_PRN_LEN - 1, RIGHTFLUSH);
// prn_Buf[MAX_PRN_LEN] = '%';
// print();
// prn_Adj(Var_Str_Item, amount, sysflag->sysdots, RPOSI);
// Prn_InsMem(percent[peridxtmp].desc, MAX_DESC_LEN, 1, NM_FONT_PRN, FLUSH_LEFT);
Prn_InsImpStr(percent[peridxtmp].desc, 1, MAX_DESC_LEN, FLUSH_LEFT);
LongPrnFmt_Ex(quantity, PER_DOTS, MAX_PRN_LEN - 1, RIGHTFLUSH, NM_FONT_PRN);
Prn_InsStr(Str_Per_Symbol, MAX_PRN_LEN, NM_FONT_PRN, FLUSH_LEFT);
Print_Ex(1);
Prn_Adj_Ex(Var_Str_Item, amount, sysflag->sysdots, RPOSI, DESC_NEW);
}
else if(ID == TS_PER_SUBT) /* Percent after sub total operation */
{
peridxtmp = (tsbf.ID)>>5;
amount = price; /* In Percent operation, the amount equal to the price */
if(Subt_Prn_Flag == 0) /* Print the total information */
{
Get_TVAT(); /* Calculate the VAT or tax value */
prn_REG_TVAT(); /* Print the VAT or tax vaule */
prn_Line('-');
// prn_Adj(Var_Str_Subttl, tmpvars.netamt-amount, sysflag->sysdots, RPOSI);
prn_Tot_Info_Ex(Var_Str_Subttl, tmpvars.netamt-amount, 0);
}
// memcpy(prn_Buf+1, percent[peridxtmp].desc, MAX_DESC_LEN);
// LongPrnFmt(quantity, PER_DOTS, MAX_PRN_LEN - 1, RIGHTFLUSH);
// prn_Buf[MAX_PRN_LEN] = '%';
// print();
// prn_Adj(Var_Str_SubTtl, amount, sysflag->sysdots, RPOSI);
// Prn_InsMem(percent[peridxtmp].desc, MAX_DESC_LEN, 1, NM_FONT_PRN, FLUSH_LEFT);
Prn_InsImpStr(percent[peridxtmp].desc, 1, MAX_DESC_LEN, FLUSH_LEFT);
LongPrnFmt_Ex(quantity, PER_DOTS, MAX_PRN_LEN - 1, RIGHTFLUSH, NM_FONT_PRN);
Prn_InsStr(Str_Per_Symbol, MAX_PRN_LEN, NM_FONT_PRN, FLUSH_LEFT);
Print_Ex(1);
Prn_Adj_Ex(Var_Str_SubTtl, amount, sysflag->sysdots, RPOSI, DESC_NEW);
}
#ifdef REST_PLU_FUNC
else if(ID == TS_PLU_DESC)
{
Prn_InsStr(Str_Desc_PLU_Symbol1, 1, NM_FONT_PRN, FLUSH_LEFT);
Prn_InsImpStr(plu[Idx].desc, 2, MAX_DESC_LEN_EX, FLUSH_LEFT);
Prn_InsStr(Str_Desc_PLU_Symbol2, Get_Desc_Len_Ex(plu[Idx].desc, MAX_DESC_LEN_EX, NO)+2, NM_FONT_PRN, FLUSH_LEFT);
Print_Ex(1);
}
else if((ID == TS_PLU_GIFT) || (ID == TS_RM_PLU_GIFT))
{
Prn_InsStr(Str_Gift_PLU_Symbol2, 1, NM_FONT_PRN, FLUSH_LEFT);
Prn_InsImpStr(plu[Idx].desc, 2, MAX_DESC_LEN_EX, FLUSH_LEFT);
Prn_InsStr(Str_Gift_PLU_Symbol,15, NM_FONT_PRN, FLUSH_LEFT);
Qty_Adjust(quantity);
if(quantity != 1000) /* The quantity is not 1 */
{
LongPrnFmt_Ex(adj_num, adj_dots, MAX_PRN_LEN, RIGHTFLUSH, NM_FONT_PRN);
}
Print_Ex(1);
}
else if(ID == TS_MENU_HEAD)
{
Prn_InsStr(Str_Menu_Head1,1, NM_FONT_PRN, FLUSH_LEFT);
LongPrnFmt_Ex((Idx+1)/10, 0, 21, RIGHTFLUSH, NM_FONT_PRN);
LongPrnFmt_Ex((Idx+1)%10, 0, 22, RIGHTFLUSH, NM_FONT_PRN);
Print_Ex(1);
}
else if(ID == TS_MENU_REAR)
{
Prn_InsStr(Str_Menu_Sub_Qty, 1, NM_FONT_PRN, FLUSH_LEFT);
Qty_Adjust(quantity);
Prn_Adj_Q_Ex(Str_Null, adj_num, adj_dots, MAX_PRN_LEN, DESC_NEW);
Prn_InsStr(Str_Menu_Sub_Amt, 1, NM_FONT_PRN, FLUSH_LEFT);
LongPrnFmt_Ex(price, sysflag->sysdots, MAX_PRN_LEN, RIGHTFLUSH, NM_FONT_PRN);
Print_Ex(1);
prn_Line('*');
}
#endif
#ifdef AUTO_PER /* Support the department auto percent function */
else if((ID == TS_AUTO_PER_DEPT) || (ID == TS_AUTO_PER_PLU)) /* Auto Percent operation */
{
amount = price; /* In Percent operation, the amount equal to the price */
// len1 = strlen(Var_Str_Auto_Per);
// len1 = Get_Desc_Len_Ex(Var_Str_Auto_Per, strlen(Var_Str_Auto_Per)/2, YES);
len1 = Get_Spec_Len(Var_Str_Auto_Per);
len2 = Cal_Len(quantity) + 1; /* A decimal dots */
if(len2 < 5) /* x.xxx% */
len2 = 5;
if(quantity < 0) /* Negative */
len2 ++;
len2 ++; /* '%' */
if(len1 + len2 < 19)
{
// prn_Buf[19] = '%';
// LongPrnFmt(quantity, 3, 18, RIGHTFLUSH);
Prn_InsStr(Str_Per_Symbol, 19, NM_FONT_PRN, FLUSH_LEFT);
LongPrnFmt_Ex(quantity, 3, 18, RIGHTFLUSH, NM_FONT_PRN);
}
else
{
// prn_Buf[len1+len2+1] = '%';
// LongPrnFmt(quantity, 3, len1+len2, RIGHTFLUSH);
Prn_InsStr(Str_Per_Symbol, len1+len2+1, NM_FONT_PRN, FLUSH_LEFT);
LongPrnFmt_Ex(quantity, 3, len1+len2, RIGHTFLUSH, NM_FONT_PRN);
}
// prn_Adj(Var_Str_Auto_Per, amount, sysflag->sysdots, RPOSI);
Prn_Adj_Ex(Var_Str_Auto_Per, amount, sysflag->sysdots, RPOSI, DESC_NEW);
}
#endif /* End AUTO_PER */
else
{
round = (tsbf.flag)>>4;
amount = Sale_Mul(price, sysflag->sysdots, quantity, 3, round, sysflag->sysdots); /* Get the amount */
;/* Judge the amount is illegal or not */
price = labs(price); /* Get the absolute value, for the print price is always positive */
if((ID == TS_RF_SUBT) && (Subt_Prn_Flag == 0)) /* Print the total information */
{
Get_TVAT(); /* Calculate the VAT or tax value */
prn_REG_TVAT(); /* Print the VAT or tax vaule */
prn_Line('-');
// prn_Adj(Var_Str_Subttl, tmpvars.netamt-amount, sysflag->sysdots, RPOSI);
prn_Tot_Info_Ex(Var_Str_Subttl, tmpvars.netamt-amount, 0);
}
if((ID == TS_RF_ITEM_DEPT) || (ID == TS_RF_ITEM_PLU) || (ID == TS_RF_SUBT))
{
// memcpy(prn_Buf+1, refund.desc, MAX_DESC_LEN);
// Prn_InsMem(refund.desc, MAX_DESC_LEN, 1, NM_FONT_PRN, FLUSH_LEFT);
Prn_InsImpStr(refund.desc, 1, MAX_DESC_LEN, FLUSH_LEFT);
len1 = Get_Desc_Len_Ex(refund.desc, MAX_DESC_LEN, NO);
}
else if((ID == TS_DEPT) || (ID == TS_VD_DEPT) || (ID == TS_RM_DEPT))
{
// memcpy(prn_Buf+1, dept[Idx].desc, MAX_DESC_LEN);
// Prn_InsMem(dept[Idx].desc, MAX_DESC_LEN, 1, NM_FONT_PRN, FLUSH_LEFT);
Prn_InsImpStr(dept[Idx].desc, 1, MAX_DESC_LEN_EX, FLUSH_LEFT);
len1 = Get_Desc_Len_Ex(dept[Idx].desc, MAX_DESC_LEN_EX, NO);
}
else //((ID == TS_PLU) || (ID == TS_VD_PLU) || (ID == TS_RM_PLU))
{
plink = plu[Idx].plink;
if(sysflag->RPLDP_flag) /* Print the Linked department when the flag is 1 */
{
// memcpy(prn_Buf+1, dept[plink - 1].desc, MAX_DESC_LEN);
// print();
// Prn_InsMem(dept[plink - 1].desc, MAX_DESC_LEN, 1, NM_FONT_PRN, FLUSH_LEFT);
Prn_InsImpStr(dept[plink - 1].desc, 1, MAX_DESC_LEN_EX, FLUSH_LEFT);
Print_Ex(1);
}
// memcpy(prn_Buf+1, plu[Idx].desc, MAX_DESC_LEN);
// Prn_InsMem(plu[Idx].desc, MAX_DESC_LEN, 1, NM_FONT_PRN, FLUSH_LEFT);
Prn_InsImpStr(plu[Idx].desc, 1, MAX_DESC_LEN_EX, FLUSH_LEFT);
len1 = Get_Desc_Len_Ex(plu[Idx].desc, MAX_DESC_LEN_EX, NO);
}
if((ID == TS_VD_DEPT) || (ID == TS_VD_PLU)) /* VOID operation */
{
// xtr_strcpy(prn_Buf+14, Var_Str_VOID); /* Modified on 2004-04-07 17:18 */
// LongPrnFmt(amount, sysflag->sysdots, RPOSI, RIGHTFLUSH);
// print();
// Prn_InsFmtStr(Var_Str_VOID, 14, strlen(Var_Str_VOID)/2, NULL);
Prn_InsFmtStr(Var_Str_VOID, 14, Get_Spec_Len(Var_Str_VOID), NULL);
LongPrnFmt_Ex(amount, sysflag->sysdots, RPOSI, RIGHTFLUSH, NM_FONT_PRN);
Print_Ex(1);
}
else
{
// len1 = Get_Desc_Len(prn_Buf+1, MAX_DESC_LEN); /* Get the descriptions length */
len2 = Cal_Len2(price, sysflag->sysdots);
Qty_Adjust(quantity);
len3 = Cal_Len2(adj_num, adj_dots);
len4 = Cal_Len2(amount, sysflag->sysdots);
if((len1+len2 < 19) && (len3 + len4 < 12) && (len3 < 5) && ((ID == TS_DEPT) || (ID == TS_PLU)))
/* Print the data in one line */
{
// LongPrnFmt(price, sysflag->sysdots, 19, RIGHTFLUSH);
// LongPrnFmt(amount, sysflag->sysdots, RPOSI, RIGHTFLUSH);
LongPrnFmt_Ex(price, sysflag->sysdots, 19, RIGHTFLUSH, NM_FONT_PRN);
LongPrnFmt_Ex(amount, sysflag->sysdots, RPOSI, RIGHTFLUSH, NM_FONT_PRN);
if(len4 < 8)
{
// LongPrnFmt(adj_num, adj_dots, 24, RIGHTFLUSH);
LongPrnFmt_Ex(adj_num, adj_dots, 24, RIGHTFLUSH, NM_FONT_PRN);
}
else
{
// LongPrnFmt(adj_num, adj_dots, MAX_PRN_LEN - len4 - 1, RIGHTFLUSH);
LongPrnFmt_Ex(adj_num, adj_dots, MAX_PRN_LEN - len4 - 1, RIGHTFLUSH, NM_FONT_PRN);
}
// print();
Print_Ex(1);
}
else /* Print the data in two lines */
{
if(len1+len2 < 19)
// LongPrnFmt(price, sysflag->sysdots, 19, RIGHTFLUSH);
LongPrnFmt_Ex(price, sysflag->sysdots, 19, RIGHTFLUSH, NM_FONT_PRN);
else
// LongPrnFmt(price, sysflag->sysdots, len1+1+1, LEFTFLUSH);
LongPrnFmt_Ex(price, sysflag->sysdots, len1+1+1, LEFTFLUSH, NM_FONT_PRN);
// print();
Print_Ex(1);
if((ID == TS_RM_DEPT) || (ID == TS_RM_PLU)) /* Print the Return Merchandise information */
// xtr_strcpy(prn_Buf+1, Var_Str_RM); /* Modified on 2004-04-07 17:18 */
// Prn_InsFmtStr(Var_Str_RM, 1, strlen(Var_Str_RM)/2, NULL);
Prn_InsFmtStr(Var_Str_RM, 1, Get_Spec_Len(Var_Str_RM), NULL);
else if((ID == TS_RF_ITEM_DEPT) || (ID == TS_RF_ITEM_PLU) || (ID == TS_RF_SUBT)) /* Refund operation */
{
if(ID == TS_RF_SUBT)
// xtr_strcpy(prn_Buf+1, Var_Str_SubTtl); /* Modified on 2004-04-07 17:18 */
// Prn_InsFmtStr(Var_Str_SubTtl, 1, strlen(Var_Str_SubTtl)/2, NULL);
Prn_InsFmtStr(Var_Str_SubTtl, 1, Get_Spec_Len(Var_Str_SubTtl), NULL);
else
// xtr_strcpy(prn_Buf+1, Var_Str_Item); /* Modified on 2004-04-07 17:17 */
// Prn_InsFmtStr(Var_Str_Item, 1, strlen(Var_Str_Item)/2, NULL);
Prn_InsFmtStr(Var_Str_Item, 1, Get_Spec_Len(Var_Str_Item), NULL);
}
// LongPrnFmt(amount, sysflag->sysdots, RPOSI, RIGHTFLUSH);
LongPrnFmt_Ex(amount, sysflag->sysdots, RPOSI, RIGHTFLUSH, NM_FONT_PRN);
if(len4 < 8)
// LongPrnFmt(adj_num, adj_dots, 24, RIGHTFLUSH);
LongPrnFmt_Ex(adj_num, adj_dots, 24, RIGHTFLUSH, NM_FONT_PRN);
else
// LongPrnFmt(adj_num, adj_dots, MAX_PRN_LEN - len4 - 1, RIGHTFLUSH);
LongPrnFmt_Ex(adj_num, adj_dots, MAX_PRN_LEN - len4 - 1, RIGHTFLUSH, NM_FONT_PRN);
// print();
Print_Ex(1);
}
}
}
Sale_Dsp(tsbf);
}
#else
void Sale_Prn(TRANSBUFFDEF tsbf)
{
byte ID;
byte plink;
byte round;
byte peridxtmp;
byte len1, len2, len3, len4;
word Idx;
long price;
long quantity;
long amount;
char *desc_tmp;
ID = (tsbf.ID)&0x1F;
Idx = tsbf.nth;
price = tsbf.price;
quantity = tsbf.quantity;
#ifdef VER_RSNT /* Support the restaurant function */
// Sending the data to the kitchen printer.
Send_KP_Prn(tsbf, POSITIVE); /* Print to the kitchen printer */
#endif /* End VER_RSNT */
if(ID == TS_EC) /* Error Correct operation */
{
amount = price; /* In EC operation, the amount equal to the price */
Prn_Adj_Ex(Var_Str_EC, amount, sysflag->sysdots, RPOSI, DESC_NEW);
}
else if((ID == TS_PER_ITEM_DEPT) || (ID == TS_PER_ITEM_PLU)) /* Percent after item operation */
{
peridxtmp = (tsbf.ID)>>5;
amount = price; /* In Percent operation, the amount equal to the price */
Prn_InsImpStr(percent[peridxtmp].desc, 1, MAX_DESC_LEN, FLUSH_LEFT);
LongPrnFmt_Ex(quantity, PER_DOTS, MAX_PRN_LEN - 1, RIGHTFLUSH, NM_FONT_PRN);
Prn_InsStr(Str_Per_Symbol, MAX_PRN_LEN, NM_FONT_PRN, FLUSH_LEFT);
Print_Ex(1);
Prn_Adj_Ex(Var_Str_Item, amount, sysflag->sysdots, RPOSI, DESC_NEW);
}
else if(ID == TS_PER_SUBT) /* Percent after sub total operation */
{
peridxtmp = (tsbf.ID)>>5;
amount = price; /* In Percent operation, the amount equal to the price */
if(Subt_Prn_Flag == 0) /* Print the total information */
{
Get_TVAT(); /* Calculate the VAT or tax value */
prn_REG_TVAT(); /* Print the VAT or tax vaule */
prn_Line('-');
prn_Tot_Info_Ex(Var_Str_Subttl, tmpvars.netamt-amount, 0);
}
Prn_InsImpStr(percent[peridxtmp].desc, 1, MAX_DESC_LEN, FLUSH_LEFT);
LongPrnFmt_Ex(quantity, PER_DOTS, MAX_PRN_LEN - 1, RIGHTFLUSH, NM_FONT_PRN);
Prn_InsStr(Str_Per_Symbol, MAX_PRN_LEN, NM_FONT_PRN, FLUSH_LEFT);
Print_Ex(1);
Prn_Adj_Ex(Var_Str_SubTtl, amount, sysflag->sysdots, RPOSI, DESC_NEW);
}
#ifdef REST_PLU_FUNC
else if(ID == TS_PLU_DESC)
{
Prn_InsStr(Str_Desc_PLU_Symbol1, 1, NM_FONT_PRN, FLUSH_LEFT);
Prn_InsImpStr(plu[Idx].desc, 2, MAX_DESC_LEN_EX, FLUSH_LEFT);
Prn_InsStr(Str_Desc_PLU_Symbol2, Get_Desc_Len_Ex(plu[Idx].desc, MAX_DESC_LEN_EX, NO)+2, NM_FONT_PRN, FLUSH_LEFT);
Print_Ex(1);
}
else if((ID == TS_PLU_GIFT) || (ID == TS_RM_PLU_GIFT))
{
Prn_InsStr(Str_Gift_PLU_Symbol2, 1, NM_FONT_PRN, FLUSH_LEFT);
Prn_InsImpStr(plu[Idx].desc, 2, MAX_DESC_LEN_EX, FLUSH_LEFT);
Prn_InsStr(Str_Gift_PLU_Symbol,15, NM_FONT_PRN, FLUSH_LEFT);
Qty_Adjust(quantity);
if(quantity != 1000) /* The quantity is not 1 */
{
LongPrnFmt_Ex(adj_num, adj_dots, MAX_PRN_LEN, RIGHTFLUSH, NM_FONT_PRN);
}
Print_Ex(1);
}
else if(ID == TS_MENU_HEAD)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -