⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sale2.c

📁 一款收款机C源代码!因为是几年前的代码了
💻 C
📖 第 1 页 / 共 5 页
字号:
//								dc_jrnl_len = 0;
//							}
//							else
//							{
////								elec_jrnl = (ELECJRNLHEADDEF *)(&(dc_jrnl[dc_jrnl_last]));
//								elec_jrnl = get_jrnl_head(dc_jrnl_last_ptr);
//								tmp = elec_jrnl->length;
//								dc_jrnl_last = (dc_jrnl_last +tmp) % Max_Dc_Jrnl_No;
//							}
//						}
						cnt ++;
						store_head_step = 2;
						store_dc_item((TRANSBUFFDEF *)(&elec_jrnl_head), cnt);
						store_head_step = 0;
					}
					cnt ++;
					store_dc_item(&transbuff[i-1], cnt);
					cnt ++;
					store_dc_item(&transbuff[i], cnt);
					break;

				case TS_PER_SUBT:
					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;
//								dc_jrnl_len = 0;
//							}
//							else
//							{
////								elec_jrnl = (ELECJRNLHEADDEF *)(&(dc_jrnl[dc_jrnl_last]));
//								elec_jrnl = get_jrnl_head(dc_jrnl_last_ptr);
//								tmp = elec_jrnl->length;
//								dc_jrnl_last = (dc_jrnl_last +tmp) % Max_Dc_Jrnl_No;
//							}
//						}
						cnt ++;
						store_head_step = 2;
						store_dc_item((TRANSBUFFDEF *)(&elec_jrnl_head), cnt);
						store_head_step = 0;
					}
					cnt ++;
					store_dc_item(&transbuff[i], cnt);
					break;

				default:
					break;
			}
		} // end for
		if(cnt > Max_Dc_Jrnl_No)
		{
			dc_jrnl_first = dc_jrnl_last = 0;
			dc_jrnl_len = 0;
		}
		else
		{
			if(cnt != 0)
			{
//				elec_jrnl = (ELECJRNLHEADDEF *)(&(dc_jrnl[dc_jrnl_last]));
//				elec_jrnl->length = cnt;
				store_head_step = 3;
				fls_store_dc_item((byte *)(&elec_jrnl_head), cnt);
				store_head_step = 0;
			}
			dc_jrnl_last -= dc_jrnl_first;
			dc_jrnl_first = 0;
		}
	}

	/* Update the R.M. journal */
	elec_jrnl_head.ID = TS_RM_JRNL;
	if(Max_Rm_Jrnl_No >= 2)			/* If the length smaller than 2, not to store the R.M. journal */
	{
		cnt = 0;
//		cnt ++;
//		store_rm_item((TRANSBUFFDEF *)(&elec_jrnl_head), cnt);
		for(i = 0; i < TnsBf_Len; i ++)
		{
			ID = transbuff[i].ID & 0x1F;
			switch(ID)
			{
				case TS_RM_DEPT:
				case TS_RM_PLU:
					if(cnt == 0)
					{
//						if(rm_jrnl_len != 0)
//						{
////							elec_jrnl = (ELECJRNLHEADDEF *)(&(rm_jrnl[rm_jrnl_first]));
//							elec_jrnl = get_jrnl_head(rm_jrnl_first_ptr);
//							if(elec_jrnl->length == Max_Rm_Jrnl_No)			/* Only store one transaction buffer */
//							{
//								rm_jrnl_first = rm_jrnl_last = 0;
//								rm_jrnl_len = 0;
//							}
//							else
//							{
////								elec_jrnl = (ELECJRNLHEADDEF *)(&(rm_jrnl[rm_jrnl_last]));
//								elec_jrnl = get_jrnl_head(rm_jrnl_last_ptr);
//								tmp = elec_jrnl->length;
//								rm_jrnl_last = (rm_jrnl_last +tmp) % Max_Rm_Jrnl_No;
//							}
//						}
						cnt ++;
						store_head_step = 2;
						store_rm_item((TRANSBUFFDEF *)(&elec_jrnl_head), cnt);
						store_head_step = 0;
					}
					cnt ++;
					store_rm_item(&transbuff[i], cnt);
					#ifdef	REST_PLU_FUNC			/* Also store the slave PLU */
					{
						byte	abc;
						byte	tmpid;
						for(abc = i + 1; abc < TnsBf_Len; abc ++)
						{
							tmpid = transbuff[abc].ID & 0x1F;
							if((tmpid == TS_PLU_DESC) || (tmpid == TS_RM_PLU_GIFT))		/* The slave PLU */
							{
								cnt ++;
								store_rm_item(&transbuff[abc], cnt);
							}
							else			/* Not the slave PLU, break */
							{
								break;
							}
						}
					}
					#endif
					break;

				#ifdef	REST_PLU_FUNC
				case	TS_MENU_HEAD:	/* The menu operation, check it whether it is the return merchandise operation */
					if((transbuff[i+1].ID&0x1F) == TS_RM_PLU)			/* The return merchandise operation */
					{
						if(cnt == 0)
						{
							cnt ++;
							store_head_step = 2;
							store_rm_item((TRANSBUFFDEF *)(&elec_jrnl_head), cnt);
							store_head_step = 0;
						}
						{
							byte	tmpid;
							while(i < TnsBf_Len)
							{
								cnt ++;
								store_rm_item(&transbuff[i], cnt);
								tmpid = transbuff[i].ID & 0x1F;
								if(tmpid == TS_MENU_REAR)
									break;
								i ++;
							}
						}
					}
					break;
				#endif

				default:
					break;
			}
		} // end for
		if(cnt > Max_Rm_Jrnl_No)
		{
			rm_jrnl_first = rm_jrnl_last = 0;
			rm_jrnl_len = 0;
		}
		else
		{
			if(cnt != 0)
			{
//				elec_jrnl = (ELECJRNLHEADDEF *)(&(rm_jrnl[rm_jrnl_last]));
//				elec_jrnl->length = cnt;
				store_head_step = 3;
				fls_store_rm_item((byte *)(&elec_jrnl_head), cnt);
				store_head_step = 0;
			}
			rm_jrnl_last -= rm_jrnl_first;
			rm_jrnl_first = 0;
		}
	}
}
#endif /* End ELEC_JRNL */

/* Process the weight PLU */
byte	Weight_PLU_Process(void)
{
	byte	tmp_buf[BAR_BUFF_LEN];
	long	tmp;
	long	price;
	int	Idx;

	if((pluenflag) || (Void_flag) || (Mul_flag))
	{
		errorType(ERR_KEY_SEQ);
		return (NG);
	}
	tmp = get_wgt_pric(BCDbuf);			/* Get the weight or the price from the bar code */
	if(sysflag->wgt_bar.flag == PRIC)
		sysflag->wgt_bar.reg_amount = tmp;
	else // wgt_bar.flag == WGT
		sysflag->wgt_bar.reg_count = tmp;
	memcpy(tmp_buf, BCDbuf, BAR_BUFF_LEN);
	Do_Weight_PLU(tmp_buf, BCDbuf);
	if ((Idx = SC_SearchIndex(BCDbuf)) < 0)
		{errorType(ERR_BAR_EXIST); return (NG);}
	else
	{
		Idx = Sindex[Idx];
		if(plu[Idx].price == 0)
		{
			errorType(ERR_ZERO_TRANS);
			return (NG);
		}
		lnum = Idx + 1;		/* The index number */
		numcnt = 4;				/* Set a not zero data */
	}
	if(sysflag->wgt_bar.flag == PRIC)
	{
		sysflag->wgt_bar.reg_count = Sale_Div(sysflag->wgt_bar.reg_amount, sysflag->sysdots, plu[Idx].price, sysflag->sysdots, sysflag->xCount_round, 3);		/* Get the quantity */
	}
	else
	{
		sysflag->wgt_bar.reg_amount = Sale_Mul(sysflag->wgt_bar.reg_count, 3, plu[Idx].price, sysflag->sysdots, sysflag->xCount_round, 2);			/* Get the amount */
	}
	if(sysflag->wgt_bar.reg_count != 1000)
	{
		Mul_flag = 1;
		tmp_count = sysflag->wgt_bar.reg_count;
	}
	sysflag->wgt_bar.reg_flag = 1;
	return (OK);
}

#ifdef	REST_PLU_FUNC
byte Chk_MenuBuff_Full(byte tmp_length)
{
   if(TnsBf_Len+tmp_length >= (Max_TnsBf_Len-1))			/* Save one byte for reserved, such as auto percent and so on */
	{														/* Indicate the transaction buffer length */
		errorType(ERR_FULL_ITEM);
		return(NG);
	}

	return (OK);
}
byte  cal_sale_plu_length(word Idx)           /*cal do_plu*/
{
	byte plu_length;
	byte j;
	word tmp_idx;
	byte id_order;
	byte plink;
	plu_length=0;
	id_order=TS_NULL;

	if(plu[Idx].attr.inht == 0)					/* Inhibit attribute, continue */
		return (0);
	plu_length++;
	plink = plu[Idx].plink;										/*calculate the length of main plu*/
/*1>没有考虑到禁止PLU,不占缓冲区
  2>没有考虑到赠送plu的void处理.*/	
	for(j=0;j<MAX_PLUTAB_NO;j++)           	/*DESC PLU*/
	{
		if((Idx+1)==plu_relation_tab[j].mainplu)
		{
			tmp_idx=plu_relation_tab[j].slaveplu;/*calculate the length of slave plu*/
			if(tmp_idx==0)
				continue;
				
			if(plu[tmp_idx-1].attr.mode==PLU_DESC)
			{
				if(plu[tmp_idx-1].attr.inht==0)
				{
					continue;
				}
				plu_length++; 
			}
			if((plu[tmp_idx-1].attr.mode==PLU_GIFT)&&(Void_flag==0))
			{
				if(plu[tmp_idx-1].attr.inht==0)
				{
					continue;
				}
				plu_length++; 
			}				          			
		}
	} 

   #ifdef AUTO_PER			/* Support the department auto percent function */
//	if((transbuff[TnsBf_Len-1].ID == TS_PLU_DESC)||(transbuff[TnsBf_Len-1].ID == TS_PLU_GIFT))   									
   {
   	id_order=TS_PLU; 
   }  
	if(Void_flag==1)
	{
		id_order=TS_VD_PLU;
   }	
   if(RM_flag==1)
	{
		id_order=TS_RM_PLU;
   }	
   if((dept[plink-1].per_rate != 0) && (sysflag->Auto_Per_Use_Flag == 1) &&( id_order==TS_PLU ))
   	plu_length++;
   #endif
   return(plu_length);
///////////////*calculate the length of menu end*///////////////////////// 	
}


byte cal_menu_len(word Idx,byte length)
{
	byte i,j;
   word tmp_idx;
//   word tmp_slave_idx;
   byte tmp_length;
   byte inht_count;

   menu_length=0;
   inht_count=0;
	tmp_length=0;

	for(i=0;i<length;i++)
   {
   	tmp_idx=Menu_Table[Idx].menu_plu[i];	/*get PLU no*/
//            	if((tmp_idx == 0) || (tmp_idx > Max_Plu_No))
//		    			{errorType(ERR_DIGIT_ILLEGAL);break;}

   	if(plu[tmp_idx-1].attr.inht==0)/*process the habit plu*/
		{
			inht_count++;
			continue;
		}
		tmp_idx--;
		tmp_length+=cal_sale_plu_length(tmp_idx);
	}
	if(inht_count==length)
	{
		errorType(ERR_MENU_INBT);
		return(NG);
	}  

/////////////////*calculate the length of menu*///////////////////////// 				
   menu_length=tmp_length+1+1; 		/* 头和尾, 所以长度加了2 */
   return(OK);
}

/* Get the last operation's ID */
byte	get_last_oper_id(void)
{
	byte	i = 0;
	byte	id;
	byte	id_order = TS_NULL;

	if(TnsBf_Len)
	{
		i = TnsBf_Len;
		while(i)
		{
			i --;
			id = transbuff[i].ID & 0x1F;
			if((id != TS_PLU_DESC) && (id != TS_PLU_GIFT) && (id != TS_RM_PLU_GIFT) 
				&& (id != TS_AUTO_PER_DEPT) && (id != TS_AUTO_PER_PLU))
			{
				id_order = id;
				break;
			}
		}
	}
	id_order_posi = i;
	return (id_order);
}
#endif

void	prn_pre_item_head(void)
{
	if(sysflag->prn_tab_pre_posi == 1)			/* Print the sales item when open a active table */
		return;
//	prn_Line('=');
	memcpy(prn_Buf+1, Str_Pre_Item, MAX_PRN_LEN);
	print();
}

/* Print the previous item */
void	prn_tbl_pre_item(void)
{
	byte			i;
	Inter_Var	bak_tmpvars;

	prn_tab_pre_flag = 1;
	if(Flag_Prn_Head)
		prn_pre_item_head();
	/*****************************************************/
					/* Save the data */
	memcpy(&bak_tmpvars, &tmpvars, sizeof(Inter_Var));
	memset(&tmpvars, 0, sizeof(Inter_Var));
	/*****************************************************/

	for(i = 0; i < table_awake_len; i ++)
	{
		if((transbuff[i].ID&0x1F) == TS_EC)		/* Error correct operation, not to print it */
			continue;
		Update_Tmpvars(transbuff[i], POSITIVE);	/* Update the structure variable tmpvars */
		Sale_Prn(transbuff[i]);
	}

	/*****************************************************/
					/* Revert the data */
	memcpy(&tmpvars, &bak_tmpvars, sizeof(Inter_Var));
	/*****************************************************/
	prn_tab_pre_flag = 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -